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?
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.
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.
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.
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)
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.
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.
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?
...
-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.
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.
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.
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.
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.
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.
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.
...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)....