How to read pulse from reed switch


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2007
    Posts
    66

    Default How to read pulse from reed switch

    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?

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by passion1 View Post
    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?

  3. #3
    Join Date
    May 2007
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    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?
    Last edited by passion1; - 8th June 2007 at 16:08.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by passion1 View Post
    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?

  5. #5
    Join Date
    May 2007
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    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?

  6. #6
    Join Date
    May 2007
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    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?
    Last edited by passion1; - 8th June 2007 at 21:56.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by passion1 View Post
    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...

  8. #8
    Join Date
    May 2007
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Skimask

    Thank you for the help!

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  2. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  3. Replies: 3
    Last Post: - 13th September 2008, 17:40
  4. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34
  5. read the pulse of a bobbin
    By savnik in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th July 2006, 22:09

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts