Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Micro-controller detect 24 VAC

Status
Not open for further replies.

ibwev

Member
On a previous post, it was suggested that a 100K to 1 Mega Ohm resistor be used to reduce a 24 VAC signal to a level safe enough for PIC16F690 to detect when the 24 VAC signal is on. A 100 K resistor works great when I troubleshoot the circuit without a debugger; however, when I use Pickit 2 debugger, the debugger does not recognize when the 24 VAC signal goes high (it does recognize a high signal when I tie the input pin to 5 VDC). I am trying not to fry my debugger. Should I reduce the resistor size to allow enough current for the Pic to recognize a high signal? If so, how do I calculate the correct resistor size?

24VAC.png
 
The resistor needs to limit the peak current into the pin to be below the pin clamp current level. You get that number from the Electrical Specifications section of the data sheet. I would suggest keeping it below 10% of that number.

The peak current is calculated from the peak voltage, which is ~35V for 24VAC.

Ten % of 20mA is 2mA. 35V/2mA is 17K. I would try 20K.
 
Here is how I would do it:

Using the two Schottky diodes means that only a few nA of current ever flows into/out-of the CMOS input pin. The pin voltage is clamped <5.2V and > -0.2V. The current through the 10K is ~3mA for good noise immunity. Ideally, the CMOS input pin is the kind that has built-in hysteresis.
 

Attachments

  • DR39.jpg
    DR39.jpg
    286.6 KB · Views: 191
CMOS.png

Is there a Cmos component that may be purchased or should I construct it using 2 transistors? If there is a component, please recommend one. I am having a hard time finding one on DigiKey.
 
View attachment 73398

Is there a Cmos component that may be purchased or should I construct it using 2 transistors? If there is a component, please recommend one. I am having a hard time finding one on DigiKey.

What you have in the picture; both transistors are turned on and VDC will be shorted to ground. (When VDC gets above 1.2 volts both transistors will turn on)
 
What you have in the picture; both transistors are turned on and VDC will be shorted to ground.

Thanks for the correction, this should be better.

Cmos1.png

Is there a component that may be purchased for the outlined parts in red? If so, please suggest one.

I am trying to do a series of instructions when the pic detects a 24 VAC signal.
 
Why do you ask for a solution and then ignore the replies. Your "solution" will produce exactly the same results as a 20k resistor from the AC to the pin. In both cases the pic will see a 50Hz (or 60Hz) square wave - I.E. 10mS on and then 10mS off.

Also, depending on the fets used your circuit may still short the supply.

Mike.
 
why are you not using isolation? are you sure that is a good idea? do AC and DC share reference point?
 
Why do you ask for a solution and then ignore the replies.

I did not think I was ignoring any replies.
-The very first thread resulted from a suggestion of a previous post.
-Thread #2 allowed the pin to go high but when the 24 VAC signal stopped, the pin remained high.
-Thread #3 I have a hard time understanding. I am a novice and am trying my best to work through this circuit. In order to better understand Thread #3, I thought it would be wise to understand more about "Cmos input". I researched it and thought I understood it and posted Thread #4.

In both cases the pic will see a 50Hz (or 60Hz) square wave - I.E. 10mS on and then 10mS off.

I factored the square wave of alternating current in my program.
 
why are you not using isolation?
I have used an opto-isolator to switch a 24 VAC signal using a pic but how do I reverse the process and send a 5 VDC signal to the pic when a 24 VAC signal is received?

are you sure that is a good idea?
No, I am not sure about anything. The only thing I am sure about is that I am sure about being unsure.

do AC and DC share reference point?
Yes. The source of both the AC and DC comes from the same 24 VAC transformer.
 
...
-Thread #3 I have a hard time understanding. I am a novice and am trying my best to work through this circuit. In order to better understand Thread #3, I thought it would be wise to understand more about "Cmos input". I researched it and thought I understood it and posted Thread #4.

The "cmos input" shown in my post is the input circuitry inside the PICs input pin; not something you have to build or buy.

You only need three components between the 24Vac source and the PIC inut pin; the resistor, and the two Shottky clamp diodes.
 
Why bother with the schottky diodes when the internal clamp diodes will keep the pin within specification with just a 20k resistor.

A better way would be a diode and 20k resistor (series) from AC to pin and a 0.1uF cap and a 200k resistor (paralleled) from pin to ground. This will give you DC on the pin and 0V within 40mS of the AC going off. I did it in LtSpice but can't post the image at the moment.

Mike.
 
Thanks for the info on the "Cmos Input".

24VAC3comp.png

Is this the correct schematic for the 1 resistor and 2 diodes?
 
A better way would be a diode and 20k resistor (series) from AC to pin and a 0.1uF cap and a 200k resistor (paralleled) from pin to ground. This will give you DC on the pin and 0V within 40mS of the AC going off.

24VAC4comp.png

Is this the correct schematic?

Is the purpose of the capacitor to keep the signal high during the low part of the sine wave?
 
Yes and Yes. Try it and let us know the outcome. The values are for 50Hz as you didn't state which. If it's 60 then reduce the cap by 20% (?) . Please note that I've had a long night out and my advice may be complete garbage. Someone confirm or deny please.

Mike.:eek::D
 
...
Is this the correct schematic for the 1 resistor and 2 diodes?

No, the diode whose anode is tied to ground should have its cathode connected to RB7, as should the right end of the resistor. The other diode should be tied cathode to Vdd (pin 1 of the PIC) and anode to RB7.

Since with switch S1 open, RB7 will be "floating", you have several choices. If pin RB7 has a configurable internal "weak pull-up", you can turn it on to cause RB7 to be pulled high when S1 is open. You could add a 47K resistor between RB7 and either Vdd (if you want the pin high when S1 is open), or to Gnd (if you want the pin low when S1 is open).
 
No, the diode whose anode is tied to ground should have its cathode connected to RB7, as should the right end of the resistor. The other diode should be tied cathode to Vdd (pin 1 of the PIC) and anode to RB7.

This should be better.

24VAC3comp.png

The above picture is what I thought you meant from Thread #3 but I don't know enough about electronics to know what the purpose of the Schottky Diodes are. I erroneously thought to effect the pic pin the diode would need to be in series with the pin.

Thanks to both of you for the kind help. I will assemble both circuits and let you know what happens.
 
... I don't know enough about electronics to know what the purpose of the Schottky Diodes are. I erroneously thought to effect the pic pin the diode would need to be in series with the pin.....

No, the purpose of the diodes is to clamp the voltage at the CMOS pin to just slightly higher than Vdd on positive parts of the AC input, and just slightly lower than ground on negative swings. If it were not for the diodes, the CMOS input pin would be driven substantially higher than Vdd and below ground and you would be injecting current into or drawing current out of the CMOS pin. This is a big no-no for most CMOS input pins, and usually induces latch-up.

Microchip seems to have have made more robust CMOS input pins as per this application note.
 
I finally found a little time to assemble circuits in Threads #14 and #17. Circuit in Thread #14 worked beautifully. I did not use the capacitor since I accounted for the negative part of the sine wave through programming.

I did not have any Schottky Diodes on hand to accurately setup the circuit in Thread #17. I used 1N4001 and the pin would remain high after the switch was opened (the 47 K pull down resistor was connected). I will try the circuit again with the correct diodes after I place my next DigiKey order.

Thanks again for the wonderful help.
 
...I did not have any Schottky Diodes on hand to accurately setup the circuit in Thread #17. I used 1N4001 and the pin would remain high after the switch was opened (the 47 K pull down resistor was connected)....

If RB7 remains high with a 47K wired between RB7 and GND, then the diode from RB7 to Vdd is either shorted or installed backwards.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top