PDA

View Full Version : counting encoder pluses.



Deano1936
03-02-2010, 12:56 AM
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

Phil Pilgrim (PhiPi)
03-02-2010, 04:32 AM
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

erco
03-02-2010, 05:08 AM
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."

allie
03-07-2010, 12:46 PM
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!
03-07-2010, 10:49 PM
allie,



what is the link to the pak. thanks, jim

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The smarter I get, the more I understand I don't know!

allie
03-08-2010, 12:07 AM
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 Allen
03-08-2010, 01:38 AM
Also take a look at this thread (http://forums.parallax.com/showthread.php?p=630036), 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 (http://www.emesystems.com)