Shop OBEX P1 Docs P2 Docs Learn Events
counting encoder pluses. — Parallax Forums

counting encoder pluses.

Deano1936Deano1936 Posts: 15
edited 2010-03-07 17:38 in BASIC Stamp
I'm using a BS2pe stamp. I have a DC servo motor with an optical encoder that puts out 400 pulses per rev. I have tested the unit using the P basic "COUNT" function .
It works great. I would like to output a motor stop command when the counter reaches a predetermined count. The problem I have with the count function is that I can't use the count viable until the count duration time has been reach. Can anyone give me a source code that would accomplish this task ?

Thank you.
Dean

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-01 20:32
    BASIC Stamps are single-task controllers that do one thing at a time only. While the COUNT instruction is executing during the selected duration, the Stamp cannot do anything else but wait for it to finish. For applications requiring multi-tasking/multi-processing, the Propeller is the way to go.

    -Phil
  • ercoerco Posts: 20,256
    edited 2010-03-01 21:08
    400 PPR is a lot or resolution! At some low RPM, you can count individual pulses in a small, fast software loop. That's how I keep track of the wheel encoders on my bot. But I only have 36 PPR and maybe 80 RPM, easily tracked by a BS2E.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • allieallie Posts: 107
    edited 2010-03-07 04:46
    I also will need to count encoder pulses from my milling machine project with a BS2P40 as the main controller. I'm going to use one of AL Williams pulse counting PAKS to do the counting then send the results to the BS2P40 for processing. That way the BS2P40 can control my relay board while the pulse counting PAK takes care of it's job at the same time. Then the BS2P40 can send the results through the Propeller Backpack to the TV display.

    Regards
    Allie
  • Let's Go!Let's Go! Posts: 124
    edited 2010-03-07 14:49
    allie,



    what is the link to the pak. thanks, jim

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The smarter I get, the more I understand I don't know!
  • allieallie Posts: 107
    edited 2010-03-07 16:07
    jim,

    Go to www.awce.com for the pak. Under awc electronics logo choose pak selection guide then choose pulse I/O pak-VII.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-03-07 17:38
    Also take a look at this thread, where PhiPi contributed an encoder interface based on the tinyAVR used on the MOBO Stamp. You have a BS2pe, which does have the One-wire command that is required to use it.

    Simple counting of pulses may work for what you are doing, but I am not sure you are aware that encoders produce two out-of-phase count channels, and a true decoder will count both up and down as appropriate to track the position of the encoder. A simple counter on one of the channels can't do that.

    The Stamp will have to return often to read the encoder, or else it might seriously overshoot. Ideally for your purpose, your coprocessor would provide an simple "interrupt" on a pin so that the Stamp could easily poll for the end of the travel. The coprocessor would have to have a count/compare/interrupt function, but I don't know of one that does that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.