Note that the BASIC Stamp is relatively slow in executing instructions, so it only works for encoders that are moved slowly. The processor has to be fast enough to detect every single state transition.
gregg A said...
Can anyone tell me how to read a quadrature encoder using a BS2?
I cant find a program that works.
Those are good links, but I have to agree with the last poster, even with a bs2px you end up skipping (missing spots) if it goes more than 1 revolution per second, and that was just dedicated for looking at the encoder.
I ended up using an absolute encoder from usdigital.com.· It works good, but you need an ADC chip to read the voltage (it varies from 0-5volts).· If you get an absolute encoder, I can share my code for tracking it and measuring rollovers (counts).
Okay, here's the code.· Its not very well documented at this point because its a project in progress.· Also, it is for use with the PLC development board.
"DrumCnt" is the number of rotations, and "DrumPos" is the relative position.· I degraded the value to get a range of 0-60.
If you pickup this months SERVO magazine there is an article in there about encoders. It uses a Parallax SX28 chip as an encoder processor. It can scale down the encoder values so you won't miss pulses. At any rate you may find the article helpful.
RobotWorkshop said...
If you pickup this months SERVO magazine there is an article in there about encoders. It uses a Parallax SX28 chip as an encoder processor. It can scale down the encoder values so you won't miss pulses. At any rate you may find the article helpful.
Robert
Nice.· Too bad I can't find that mag at a Krogers, lol.· Don't they make dedicated chips for this purpose too?
I see a lot of people putting encoders on the motors instead of the wheels, and it seems to me that's looking for a bloody nose. Obviously the wheels (several gears downstream from the motor) are turning more slowly than the motor, and a BS2-class chip stands a better chance of keeping up with encoder ticks. Those using motor encoders hoping for better resolution via more ticks per wheel revolution will quickly find that transmission backlash (gear slop) introduces erroneous errors. IMHO, it's better to have the encoder look at wheel revolutions for real-world output, and give our beloved Stamps an honest chance to keep up with them. My own robot has 5" diameter wheels, travels relatively quickly at 1.5 feet per second, has 32 holes in it, and the BS2 never misses a tick. I use a plain old Radio Shack IR LED & phototransistor sensor, directly input into a BS2 pin. The input signal swings back & forth across the Stamp's logic level transition ~1.4 volts, and I simply test for high/low to look for passing holes. I deleted my original Schmitt trigger because I had better results by sampling the input signal twice (make sure I get two lows in a row, then two highs in a row). That has totally eliminated false triggering from the noisy transition from high to low.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ·"If you build it, they will come."
Comments
http://www.seattlerobotics.org/encoder/200311/johnson/Mousebot.html· mousebot
http://www.sxlist.com/techref/io/sensor/pos/enc/quadrature.htm
http://en.wikipedia.org/wiki/Rotary_encoder
http://www.mcmanis.com/chuck/robotics/projects/lab-x3/quadratrak.html
http://zone.ni.com/devzone/cda/tut/p/id/7109· good info
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
www.emesys.com/BS2fsm.htm#twobit
Note that the BASIC Stamp is relatively slow in executing instructions, so it only works for encoders that are moved slowly. The processor has to be fast enough to detect every single state transition.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I ended up using an absolute encoder from usdigital.com.· It works good, but you need an ADC chip to read the voltage (it varies from 0-5volts).· If you get an absolute encoder, I can share my code for tracking it and measuring rollovers (counts).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Keep buying replacement parts and sooner or later you will get it RIGHT!
"DrumCnt" is the number of rotations, and "DrumPos" is the relative position.· I degraded the value to get a range of 0-60.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Keep buying replacement parts and sooner or later you will get it RIGHT!
Robert
lots of good info responses to my question.
"Don't they make dedicated chips for this purpose too?"
Years ago it was not uncommon to see an arrangement·using a 74HC73 (Dual J-K Flip-Flop) and a couple of 4040B's (12-Bit Ripple Counter)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."