Shop OBEX P1 Docs P2 Docs Learn Events
Is there a way to count pulses (a steady 120hz) for a changing length of a butt - Page 3 — Parallax Forums

Is there a way to count pulses (a steady 120hz) for a changing length of a butt

13»

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-30 13:21
    BPM,

    I recommend the 74HC595 because it is latched; so the outputs do not ripple when new data is being clocked in and through.· As I've tried to explain a couple times, you can use three pins to connect to the 595s: Data, Clock, Latch.· The clock and latch lines are common to all, the data line gets pushed "through" like this:

    DataOut
    >[noparse][[/noparse]14·· 595-1··· 9]
    >[noparse][[/noparse]14·· 595-2··· 9]
    >[noparse][[/noparse]14·· 595-3··· 9]

    When you do that you can read the segments pattern from a table (use READ with the index created with DIG) and then push them out.· If the 1s value is the third digit in the chain, you could do something like this:

    Update_Displays:
    · FOR theDigit = 0 TO 2
    ··· idx = bpm DIG·theDigit
    ··· READ (SegTable·+ idx), segments
    ··· SHIFTOUT DataOut, Clock, MSBFIRST, [noparse][[/noparse]segments]
    · NEXT
    · PULSOUT Latch, 5
    · RETURN

    Notice that the latch comes AFTER all the shifting -- this allows data to be "pushed through" the 595s to the right position before you move that data to the outputs.

    Of course, you can do things the hard way (manual multiplexing)·if you like, but if you're target is to get three digits displayed without hassle, spend a couple bucks on some 595s -- you'll be glad you did; they are one of my favorite expansion components.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-06-30 22:53
    thanks! I didn't understand all the things involved in displaying digits, when you mentioned the 595 before. So I just figured I would try to use the 7447's, knowing after doing it all that I would probably understand better, what exactly is going on and why you CAN'T do it with a few 7447's.
    And I definetly learned that. Sometimes I do things the hard way to understand better why it should be done a different way. I am cursed with wanting to know how to do something, and then if I think I can do it one way, I must try it and understand why it cannot be done that way.

    But thanks to you, I am not going to spend the next month on trying many different ways, I'll just go buy some 595's!
    This will be my first time working with shift out.. mmmmmm....

    Post Edited (BPM) : 6/30/2005 10:56:43 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-30 23:31
    See the help file for SHIFTOUT -- it has a 595 example to get you going.· Nothing like a breadboard and some LEDs for a little fun (for a LOT of fun, get one of our PDBs).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.