Shop OBEX P1 Docs P2 Docs Learn Events
The best way to read encoders with the BS2 — Parallax Forums

The best way to read encoders with the BS2

MagnusMagnus Posts: 18
edited 2005-11-15 23:19 in Robotics
Hi,
I have decided to add optical encoders to the wheels on my robot. I have been googeling for quite some time and it doesn't look that there is a standard way of doing this.

The frequences are not that extreme with 4 RPMs and 36 stripes on the encoder wheel we are talking about 300 ticks per second. But i need to poll four encoders to get the speed and direction of two wheels.

I have eveluated three different approaches:

1. connect two optical encoders directly to the Javelin. While that might be possible i think it will make it extremely hard to write the rest of the code and still beeing able to keep track of all pulses and time them.

2. Use my spare Basic Stamp (BS2E) as a separate counter/timer. This could be a possible way, but how do i interface the Javeling with the BS2 in a way that i don't loose any counts from the encoders. I just bought a PWMPAL to do some testing with, maybe this is the solution.

3. Buy/build dedicated hardware to do the counting and timing. I'm no expert in designing circuits from scratch, but can anyone direct me to a solution or a chip that could help me do the job?

Any help or directions would p

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-11-14 10:28
    Magnus of dark and rainy Stockholm -

    Why do you feel the need to poll four encoders to get the speed and direction of two wheels, when, at most, with quadrature encoding you only need 2 encoders to attain that goal? Each single quadrature encoder will give you both speed and direction. Just ask for coding hints, when the time is appropriate.

    Moreover, why do you need to poll more than ONE encoder to get this information - why check both wheels (more below)?

    Better yet, wouldn't one unpowered, trailing wheel with a quadrature encoder give you the speed, and direction (as noted above) of the vehicle or mobile platform, without regard to wheel slippage, if that was your original concern?

    Regards,

    Bruce Bates
  • MagnusMagnus Posts: 18
    edited 2005-11-14 10:58
    Bruce,
    Obviously my problem description was a bit unclear... Offcource i only need to read two encoders, what i meant was that i neet to count four square waves, two for each encoder.

    Since the robot is a four wheel drive rover with skid steering a trailing wheel would be hard to implement. Especially since i try to make the robot work outdoors in my garden...

    One solution is of cource to buy a motorcontroller with encoder inputs, PID-regulation etc. But i allready have a motor controller and since my motors consumes a total of 10A a new motor controller would be to expensive or at least the last solution.

    I want to check two encoders to be able to measure differences in travel between the wheels to perform positioning calculations. I know this will give me only limited info since my wheels will slip during turns. Using left and right encoders can however give me feedback to drive left and right motors at the same speed.

    Another solution would be to have a simple one channel encoder on one wheel only and use a gyro to measure turns. I would then always let the robot come to a complete stop before reading the wheelcount since i can't measure direction of the wheel.

    /Magnus

    Post Edited (Magnus) : 11/14/2005 12:07:59 PM GMT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-11-14 12:28
    Magnus -

    I can tell that the weather is clearing in Stockholm. Far less static in this post smile.gif

    I don't think you have nearly the problem you think you may have. All you need is a bit of coding assistance with state machines, I suspect, so here you go: http://www.emesystems.com/BS2fsm.htm#twobit

    Thanks go to Dr. Tracy Allen.

    What is not apparent at the face of this problem is that you don't need to read the entire pulse, only whether it is present or not (high or low). This is why a state machine works so well as a solution.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 11/14/2005 12:46:17 PM GMT
  • hutdonhutdon Posts: 32
    edited 2005-11-14 19:49
    I had a project that required reading several encoders a few years back. I found a company called US Digital that makes a line of inexpensive chips that do the 'dirty' work of reading the encoder and then passing the direction and amount of movement onto the stamp. You can check them out at www.usdigital.com. - Don
  • Steve JoblinSteve Joblin Posts: 784
    edited 2005-11-15 23:19
    What about a product like Nubotics Wheel Watcher Encoder --> http://www.nubotics.com/products/ww02/index.html
Sign In or Register to comment.