Shop OBEX P1 Docs P2 Docs Learn Events
Looking for a pulse counter — Parallax Forums

Looking for a pulse counter

HansHans Posts: 12
edited 2005-04-27 22:03 in BASIC Stamp
I've been on google for a couple of days now, and I can't find what I'm looking for.
What I would need is an IC that could count TTL pulses coming in at a rate of
about 5 PPS, and that could be read and cleared from the stamp via a CS, CLK and data
line much like many ADC IC's. I'm almost certain such an IC exists, but I can't find it.

Help.

Hans

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-26 21:14
    Is there any reason you can't use the COUNT instruction?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • HansHans Posts: 12
    edited 2005-04-26 21:33
    Yes there is. With COUNT i can measure the duration of a pulse. I need to know
    how many pulses have occurred during a given time period.

    Let me explain some more. I'm going to monitor fuel flow and water flow using flow meters
    that generate TTL pulses when fluid is flowing through them. With COUNT I could measure the
    rate at which the fluid is flowing. And I will surely do this. But what I also want to know is
    how much fluid has gone through the meter. These meters generate 1800 pulses for every liter
    of fluid that has passed thru them.

    Now I could ofcourse scan all the input pins all of the time, and make the stamp the counter. But
    this would use much of the stamp's time, and will interfere with the other functions it is doing.
    It would be better if I could interface to an IC that does the 'stupid work' for it, and then
    interrogate this IC at a time when the stamp is good and ready for it.

    The project is a 'resource monitor' for my boat. It will monitor the battery banks, fuel tanks, water
    tanks etc etc.

    Greets,

    Hans
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-04-26 21:41
    I think you may be confusing COUNT with PULSIN, quoting from the stamp manual "The COUNT instruction makes the Pin an input, then for the specified
    period of time, counts cycles on that pin and stores the total in a variable. A cycle is a change in state from 1 to 0 to 1, or from 0 to 1 to 0."

    With that said you could use a counter like 74LS590 to do this for you, say if you need to perform other functions while doing the counting, problem with this is that the output is parallel and thus requires many pins to interface with, but you could couple the 590 with a parallel in serial out chip to read the value in serially.

    Post Edited (Paul Baker) : 4/26/2005 9:50:59 PM GMT
  • HansHans Posts: 12
    edited 2005-04-26 21:58
    You are right. I did confuse PULSIN with COUNT.
    That said, COUNT would not work for me, because I need to count more than one
    input, and while COUNT is counting one pin, the pulses on the other pins are lost.
    And since I want to calculate the amount of fuel left in each tank, I don't want to miss any.

    I will have a look at the 74LS590. Do you know a parallel in serial out chip that would work here ?

    (man, this is going to be the biggest project yet. I can't wait to see my PCB with all them neato
    chips on it sitting next to my shining 2SX doing all them calculations and making me look really clever)

    Hans
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-26 22:20
    You can use a 74x165 to convert parallel outputs to a synchronous serial input (use SHIFTIN to retrieve).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • PLJackPLJack Posts: 398
    edited 2005-04-27 05:29
    I'm in the same satiation.
    I have two magnetic sensors. I need to measure the number of
    times the pulse "changes" (0 to 1 or 1 to 0, not 0-1-0)
    The Issue I have is that the travel is over a foot per pulse.
    It's true that if the metal plate passes the sensor it would produce
    a 0-1-0 for COUNT, but if it goes from 1-0 the it IS moving.
    My understanding of COUNT is that it would not detect this movement.
    Plus the max pulses per second would be around 12 or so.

    For now I am just looping 250 times pausing 1ms. And reading the state
    of both pins inside the loop. Something like this:

    Main:
    LeftTicks = 0
    RightTicks = 0

    FOR ReportTime = 0 TO 100
    PAUSE 1
    IF NOT (PinLeft = LeftLast) THEN LeftTicks = LeftTicks + 1
    IF NOT (PinRight= RightLast) THEN RightTicks = RightTicks + 1
    LeftLast = PinLeft
    RightLast = PinRight
    NEXT
    Recode and clear ticks here.

    Surly someone has a better solution.
  • HansHans Posts: 12
    edited 2005-04-27 07:26
    Hehehe. Dang ! Look what I found [noparse]:)[/noparse]

    abrobotics.tripod.com/Ebot/hardware.htm

    I love the internet. No really.
  • voodoofishvoodoofish Posts: 67
    edited 2005-04-27 17:53
    ahh yes, it's always good to read every post even if it doesn't pertain to you....so you can learn something that might be useful....or fun to experiment with!!

    Thanks Hans!!!

    -Mark
  • HansHans Posts: 12
    edited 2005-04-27 22:03
    Well, I connected the 590 and 165 as per the above diagram. It works, with one small quirk. The bits
    come in inverted. I XOR'ed the value with 255 in the stamp's code to fix this. I haven't really looked at why it's doing this yet.
    I'm gonna have a look at the specs of those IC's tomorrow. But so far it looks like my goal has come a
    little bit closer now. Thanks guys.

    Hans
Sign In or Register to comment.