View previous topic :: View next topic |
Author |
Message |
jet_pack234
Joined: 11 Feb 2005 Posts: 11
|
Square Wave Voltage reduction |
Posted: Thu Sep 29, 2005 11:16 am |
|
|
How can I input a 24V square wave signal onto an i/o pin of a 16F84A? Could I use an external resistor on the input pin to pull up a voltage or would I have to use an op-amp. Thanks for any suggestions |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Thu Sep 29, 2005 11:29 am |
|
|
It depends on your source impedence. If it is low (output from a transformer / opamp/ amplifier etc) then the simplest way is to use two resistors and a zener diode. Ideally you would connect it to a Schmidt trigger input.
39K resistor from the +24v input to the PIC input pin
10K resistor from PIC input pin to ground (signal comon)
4.7volt 400mW zener diode. Cathode (bar) to the PIC input pin. Anode to ground.
Have a look at http://www.kpsec.freeuk.com/components/diode.htm#zener but add the second resistor across the zener. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Last edited by asmallri on Thu Sep 29, 2005 11:48 am; edited 1 time in total |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Sep 29, 2005 11:36 am |
|
|
Quote: |
How can I input a 24V square wave signal onto an i/o pin of a 16F84A?
|
If the square signal can source > 10 mA use an optocoupler.
Humberto |
|
|
Guest
|
|
Posted: Thu Sep 29, 2005 3:49 pm |
|
|
Thankyou guys, will have a look at both options. |
|
|
jet_pack234
Joined: 11 Feb 2005 Posts: 11
|
|
Posted: Thu Sep 29, 2005 4:20 pm |
|
|
Why do I need to bother with the two resistors - which are acting as a potential divider (hence the chosen values?). I thought the whole point of a zener diode was so that if it is reversed biased it will maintain the breakdown voltage. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Thu Sep 29, 2005 5:00 pm |
|
|
Just playing it safe. The cheapest way of doing this is just to have the series resistor (not even the pull down resistor). In this case the protection diode clamp the input voltage on the PIC pin to 0.7 volts above the PICs VCC. However this is not really good practice.
The pull down resistor forms the voltage divider and is a cleaner solution than just the series resistor. If however you have a poor solder joint then the effective circuit is as the first scenario.
The zener is a clamp to ensure the input does not exceed the PICs VCC. In which case the zener conducts passing current to ground. You do not need the zener because, as in the first case, the input diode protection in the PIC will clamp the input to 0.7v above the power rail.
In other words the simplest solution is just the series resistor, a better solution is the voltage divider, the purist approach is the addition of the zener. You get to choose what level meets your needs. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
jet_pack234
Joined: 11 Feb 2005 Posts: 11
|
|
Posted: Fri Sep 30, 2005 5:46 am |
|
|
the only thing i dont understand now is if I put a multimeter across the input pin and ground, what would my input voltage be, assuming I am using the best approach of a reversed biased zener and a 10k resistor in parallel, Would the voltage drop be 5V from the potential divider or 4.7V from the zener?
Or is it (4.7 (from zener) + 0.19(drop across resistor) = 4.89V)
which would then stack up to give:
4.89V +19.1V (across 39K res) = 23.99V (original voltage)
I know it will work its just I like to understand whats happening before I put these things into practice!
Thanks so much for your help Andrew. |
|
|
jet_pack234
Joined: 11 Feb 2005 Posts: 11
|
|
Posted: Fri Sep 30, 2005 7:18 am |
|
|
Finally, may I ask you for one last piece of advice?
I am trying to program the following protocol.
http://www.sensorpulse.com/support/Documentation/MSP_Protocol_Theory.htm#Output_Delta
I am looking at the last section of the document (section 3.3)
What would be the best technique to capture this data. Using timers to measure the can rate or while loops etc etc. Just not sure how to approach the problem.
thanks |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Sep 30, 2005 11:55 am |
|
|
jet_pack234 wrote: | the only thing i dont understand now is if I put a multimeter across the input pin and ground, what would my input voltage be, assuming I am using the best approach of a reversed biased zener and a 10k resistor in parallel, Would the voltage drop be 5V from the potential divider or 4.7V from the zener?
|
Don't forget to take the tolerance of the Zener into account. Assuming a 10% tolerance zener, the voltage across the zener will be between 4.2 and 5.1 volts. If we ignore the zener for a moment, the voltage across the 10K resistor will be 24*(10/(10+39)) = 4.9V. If we now bring the zener back into account it means the voltage across the 10K resistor will be between 4.2V and 4.9V.
Note I have ignored the tolerance of the resistors. A 1% resistor costs virtually the same as a 5% resistor so I use 1% in all my projects. As the zerer tolerance is much higher than the tolerance of the resistors you can ignore the tolerance of the resistors in the above. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Sep 30, 2005 12:05 pm |
|
|
jet_pack234 wrote: | Finally, may I ask you for one last piece of advice?
I am trying to program the following protocol.
http://www.sensorpulse.com/support/Documentation/MSP_Protocol_Theory.htm#Output_Delta
I am looking at the last section of the document (section 3.3)
What would be the best technique to capture this data. Using timers to measure the can rate or while loops etc etc. Just not sure how to approach the problem.
thanks |
I saw this post on a different thread. I looked at the protocol and, IHMO, considered it was a [censored] protocol, poorly defined (for example in figure 10 is the pulse width of the entire 16 data bits 3 scans or is it 3 scans per bit), and didn't justify me spending and more cycles on it.
My opinion has not changed. The key to decoding the protocol is the detection of the initial sync sequence. Once that has happened then I would enter a loop. Inside the loop I would sync on each rising edge of the data bit and, using a timer, time to 1.5 times the width of a one bit, and reading the resultant bit shifting into a long value. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|