PDA

View Full Version : How to read pulse from reed switch



passion1
- 8th June 2007, 15:24
I am not sure if I need a frequency to voltage converter.
I have got a device that transmits a pulse via a reed switch and I would
like to interpret this output with my PIC16F877.
Can I do this with PBP without needing a frequency to voltage converter?

skimask
- 8th June 2007, 15:33
I am not sure if I need a frequency to voltage converter.
I have got a device that transmits a pulse via a reed switch and I would
like to interpret this output with my PIC16F877.
Can I do this with PBP without needing a frequency to voltage converter?

So the output is a pulse that you need to COUNT?

passion1
- 8th June 2007, 16:00
Yes! If I can count the pulse, then I can calculate the frequency using PBP
(and would not need a frequency-to-voltage converter to convert to analog).
In other words, how do I recognize a pulse from a reed switch directly and may I link the reed switch directly to a pin of my PIC, thus skipping the step of converting the output of the reed switch to a 0-5VDC signal?

skimask
- 8th June 2007, 16:53
Yes! If I can count the pulse, then I can calculate the frequency using PBP
(and would not need a frequency-to-voltage converter to convert to analog).
In other words, how do I recognize a pulse from a reed switch directly and may I link the reed switch directly to a pin of my PIC, thus skipping the step of converting the output of the reed switch to a 0-5VDC signal?

You answered your own question about COUNTing if you'd just take a quick look at the PBP manual.
What's your voltages coming out of the reed switch?

passion1
- 8th June 2007, 21:46
Thanks! Wow, PBP is really powerful!
I assume that as long as the voltage coming out of the reed switch is < 5V, it should be OK to connect the reed switch directly with any pin on the PIC.

If I use the command
COUNT PORTB.1,1000,w1
I will be counting the number of pulses on pin1 in 1000 milliseconds.
During the period of 1000 milliseconds, does the program 'pause' or does it continue to execute in the background, in other words, will any ON INTERRUPT commands execute during the 1000 milliseconds?

passion1
- 8th June 2007, 21:53
The manual says "With a 20MHz oscillator it checks the pin state every 4us, thus I assume the program continues to execute during the 1000 milliseconds period of the COUNT command, or am I wrong?

skimask
- 9th June 2007, 00:33
The manual says "With a 20MHz oscillator it checks the pin state every 4us, thus I assume the program continues to execute during the 1000 milliseconds period of the COUNT command, or am I wrong?

Nope, the program stops during the counting.
If you want the program to keep running, you have to start looking at interrupts and timers, etc...

passion1
- 9th June 2007, 14:29
Skimask

Thank you for the help!