Micro-controller detect 24 VAC

Status
Not open for further replies.

This is where simulations and real world circuit design drift apart. The V2 logic supply in LTSpice is a clamped hard voltage source. In reality it may consist/likely consist of an NPN pass transistor forward biased to supply (source) the current to a circuit. Think of it like a diving board at a swimming pool. You can pull like hell downwards and it will stay firm. However pushing it up lifts it off its stand easily.

Even with a 10K resistor in series with the 24VAC input, it could reverse bias the pass transistor in the regulator thus causing the voltage to lift where the regulator ceases to work. It cannot sink current due to this reverse biasing of the pass transistor. This can put a high voltage on the rest of the circuit run from the same regulator.

A clamping zener across the output of the regulator would help such lift. A 5.1V zener is stable enough to deal with this as it is the best of both worlds with Zener and Avalanche breakdown.

If you can use a Linear Tech regulator instead of a library voltage source as LT Spice will simulate the problem correctly.
 
This is where simulations and real world circuit design drift apart....

If you can use a Linear Tech regulator instead of a library voltage source as LT Spice will simulate the problem correctly.

I didn't do that, but I was one step ahead of you

The peak current that flows through the 10K resistor and through the clamp diode is only about 3mA, which is much less than the PIC draws, to say nothing about the "minimum load" resistors at the output of the LM317, so no, the Vdd will not be "lifted".

If you had simulated the circuit like I did, you would have seen that!!!!

btw-If you relied only on the PIC's internal input protection diode, the "lifting" issue would be the same as with the external Schottky clamp. Being very old school, I'm really nervous about injecting +3mA or -3.7mA into a CMOS input pin. That is why I suggested using the external clamp diodes.
 
Last edited:
Microchip incorporated the internal clamp diodes for just this situation. There is no need for external diodes. Microchip have published circuits with a pin connected to 240VAC with just a resistor to limit current. There is no need to be "nervous about injecting +3mA or -3.7mA into a CMOS input pin" as the current will be in the order of 1μA, the clamp diodes will ensure that. If you don't trust me then hear it from the horses mouth here.

Mike.
 
Mike,

You obviously dont bother to read the posts... I am aware of and referenced AN521 in post 18 in this thread.

The current injected into the PIC pin is a direct function of the external series resistor and the voltage the resistor is connected to. In this case the peak voltage is 1.414*24V = 34V. With the 10K I suggested, if it were not for the Schottky clamps, the current into and out of the pin (that would flow through the internal static protection diodes) would indeed be ~+-3ma. With the Schottky clamps, the current injected into the PIC's input is pA.

Without using the external clamp diodes, you propose to limit the current to 1ua , the external resistor would have to be 34V/1uA = 34megΩ. This would make the PIC input very high impedance, and would be extremely sensitive to noise pickup. Witness all the posts on these forums about "How come my PIC does XXXX when I switch an inductive load".

Microchip says that it is ok to inject up to 500uA into most, but not all input pins. At 500uA, the external resistor would have to be 34V/0.5mA = 68K. Now consider that the OP wants a pull-down resistor because he has a series switch between the 24Vac and the input. That is a reason to reduce the series resistor to 10K, so that the voltage divider created between the series resistor and the shunt pull-down resistor (47K) doesn't materially reduce the dv/dt at the input.

Microchip incorporated the internal clamp diodes for just this situation..
No, the internal diodes are there for static protection. AN521 says that oh-by-way, it is ok to inject a small amount of current.
 
Last edited:
, so no, the Vdd will not be "lifted".

If you had simulated the circuit like I did, you would have seen that!!!!

Really! If you look at my attachment (which I did simulate BTW) with a standard LT 5V reg you maybe in for a surprise. I am assuming your PIC draws much less than 3mA. It will do eventually with your circuit. Even if you did use a 317 (which I didn't see mentioned) with low value resistors, it's still bad practice.

Note how the 5V is lifted on the positive AC cycle even with a 10K load.

If you care to look at the internal layout of the reg, the PNP & NPN transistors go reverse biased when the output is lifted. It will more than likely take the regulator out too.



 
Last edited:
hi,
Looking at the OP's +5V reg , ie a LM317 which requires a minimum Iout of 3mA, plus the actual load of the Vset divider resistors of 5mA a more realistic simulation for the project would be as the attached image.

Which includes the required decoupling, this results in a 'spike' of around 1mV, which will not lift or damage the LM317.

I would go with MikeML on this one.

E,
 

Attachments

  • AAesp04.gif
    38.7 KB · Views: 124

Not only bad design, but a serious oversight. I wouldn't employ someone who made such an assumption as god knows what else would be overlooked or assumed.
Certainly in medical/military electronics, the "Oh it will be OK" is simply not an option.

Probably OK for an amateur who wants to turn a bulb on when a switch is pressed.
 
Perhaps you would like to point out the areas of bad design, so that we can all learn.?

This simple regulator is not for military or medical use, its to power a PIC thats being used by the OP to detect a 24Vrms sinewave voltage.

Your circuit shows a disembodied voltage regulator with no loading at all,???

I am trying to figure out what the purpose of such a regulator would be.?

EDIT:

I see now that you have modified your original 'design'

BTW its 24V RMS, LTS requires a Vpeak value to give accurate results.
 

I think the LT Spice attachment shows enough. Aren't we not here to encourage good design practice and not some botch that another may copy and fail in their application. Otherwise why bother having a Homework Help section and just encourage newbies to replace a mains regulator with a big resistor, diode and a cap. Sure that will work.

Regulators based on the 78 series designs (one of the most popular regulator series around) would suffer the same as the regulator I chose. I didn't have a spice model for those at hand otherwise I would have used that in my sim. I suggest you look deeper in the datasheets at what you are using. That regulator just happens to be one I have used in the past because making it variable is more simple that the 317.

I later modified the circuit to include a 10K load to represent the kind of load a simple micro would use when doing small tasks. So it's not exactly disembodied.

So OK the OP used 24VRMS and I incorrectly chose 24Vpeak Doesn't that make the problem I was highlighting worse now as its peak voltage is 24 x 1.41?

There are better and more reliable circuit wise ways to detect a signal above the supply of the monitoring circuit.
 
You still have not told me whats wrong with my regulator circuit and where is the bad design practice.??

This project is not in the Homework section.??

I am prepared to listen to any detailed comment of whats wrong with the LM317 circuit I posted.

With regards to the type of regulator you used, its not the one that the OP has posted.?

It would be more helpful if you focussed on the OP's requirement rather than including non relevant comments as this.

and just encourage newbies to replace a mains regulator with a big resistor, diode and a cap. Sure that will work

E.
 
I figure if the Microchip engineers say it's good then that's good enough for me. I missed the fact that you referred to it earlier. However, I still don't understand why you are sticking to your position on this!! Why is your position better than Microchips engineers?

Mike.
 

hi Mike,

Personally I would use the Microsoft method, its simpler and effective

The technical point I am disputing is with WTP, is the claimed 'regulator output lift' damage to the regulator, which would occur , if this is correct, it would happen using either MikeML's or the Microsoft method of clamping.

Eric
 
Why do people think that regulators will have problems when there output voltage exceeds there input voltage? This happens every time something is turned off!! The capacitors hold the voltage and nothing smokes.

Mike.
 

Microsoft? Since when did they appear in the discussion? Too much wine maybe! That would explain alot about your answers!
 
Why do people think that regulators will have problems when there output voltage exceeds there input voltage? This happens every time something is turned off!! The capacitors hold the voltage and nothing smokes.

Mike.

Because anyone who knows how to design a decent regulator will have a diode backwards across Vin & Vout to discharge the regulated output once the input is removed.
 
Microsoft? Since when did they appear in the discussion? Too much wine maybe! That would explain alot about your answers!

Yes, we all make typo's, but you were able to follow its meaning.

I am still waiting for an explanation on why you consider my simple LM317 regulator is wrong and of a bad design, this is the third time I have asked you this question.??

BTW: I dont drink alcohol

E.
 

I think I have made my point on more than one occasion Your solution may work relying on the output impedance of a 317 with its resistors, but it's far from good practice for others to learn from for reasons I have already explained. I am just trying to justify good engineering. Something that's so missing in our under grads.

If one person learns from this and reads beyond the bickering, then I will be happy with that. What I have posted isn't incorrect. Just good engineering observations.
 


No where do I rely on the output impedance of a 317.

The resistors on the LM317 are as specified in the datasheet of the 317.

You still are unable to give a reasonable answer to my question regarding the 'bad design' or give details of to justify good engineering

I do not see any point in discussing this point with you any further.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…