Shop OBEX P1 Docs P2 Docs Learn Events
Best practice measuring pulse train — Parallax Forums

Best practice measuring pulse train

noobydoobnoobydoob Posts: 14
edited 2014-05-22 08:38 in General Discussion
I have a coin counter that outputs pulse trains. The pulses are high for 30ms and 120ms peak-to-peak. If I insert a quarter, I get 25 pulses.

How would you implement this on a BS2 that has other things to do than waiting for pulses all the time? Is there a buffer circuit (for example with a binary counter) that would work?

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-05-20 17:30
    I'm pretty sure there are chips that would help you with this project. I know the Propeller board called the C3 uses some sort of counting chip. It sets three pins high or low based on how many counts it has received. It only counts up to seven (IIRC) but there are probably other chips that would allow higher counts.

    It sounds like the pulses are coming in slow enough that you could monitor the states directly with the BS2.

    BTW, the counters on the Propeller can be used for this sort of application. You just set up the counter and it will store the number of pulses received in one of the counter registers. The code attached to this post uses three different techniques to count incoming pulses.
  • kwinnkwinn Posts: 8,697
    edited 2014-05-20 21:35
    A 74hc4040 12 bit binary or 74hc393 dual 4 bit binary counter could do that. You would need one output pin to reset the counters and 5 input pins for inputting counts up to 31. Could do it with fewer pins if necessary but it is a bit more work.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-05-22 08:38
    noobydoob wrote: »
    I have a coin counter that outputs pulse trains. The pulses are high for 30ms and 120ms peak-to-peak. If I insert a quarter, I get 25 pulses.

    How would you implement this on a BS2 that has other things to do than waiting for pulses all the time? Is there a buffer circuit (for example with a binary counter) that would work?

    I know what you mean about the BS2, waiting for pulses. I faced this issue with rain gages and other kinds of sensors used in meteorology. My solution for that was an external counter chip based on a PIC chip, which you can find here. It is not exactly what you are looking for, but it might work if you have some other indication that a coin has dropped.

    Before that I was using an RC time circuit to hold the events as charge on a capacitor until PBASIC could get around to looking at the pin. I see you have another thread about that. My article about the rain gage is here.
Sign In or Register to comment.