Need help with Rover 5 robot

Encoder.zip (651Bytes)

 

I had Rover 5 robot with dimensions below

 

Gearbox ratio: 86.8:1

Encoder type: Quadrature

Encoder resolution: 1000 state changes per 3 wheel rotations

 

Actually from above information , I inferred  these values below and I don't know how far I am accurate in that , so please need help

 

Wheel Diameter = 6  in CM

153 + 30 = 183 , so 

Track Width = 18.3  in CM

333.3 / 2 = 166.65 / 2 = 83.325 , so

CountsPerRevolution = 83.325


Are these values accurately right ?

--

----

------

---------

--------------

------------------

-----------------------

-----------------------------

----------------------------------

---------------------------------------

thanks a lot OddBot for your post , actually I re-arrange the code in your post , and it seems working good and when I tested it on my encoders I got about 333 change per revolution but the problem is that it just adds incrementally and doesn't descemet when the wheel rotate backward .  so please what change in the code should I do to make it decrement .

 

 

 

I will play with some math in my comment.

The wheel diameter is as you said 60mm. The track width is shown to be 30mm.
Track length can be calcualted by:

245 - 60 = 185 * 2 = 370 + (2 * 3.14 * 30) = 370 + (188.5) = 558.5 (approximately)

245 is overal length end to end for the tracks

60 is the wheel diameter

370 is the lenght of track top + bottom from center to center

Adding the circumference for length of track around the front + length around the back wheel gives a total of 558.5mm.

Thanks alot

Thanks  alot birdmum

Actually I meant by track width is the wheelbase of the vehicle, ideally measured as the distance between the two contact points between the wheels and the floor.

so from figure above 

15 + 153 + 15 = 183 , so 

Track Width = 18.3  in CM

Tracked robots tend to have
Tracked robots tend to have the tracks slide a lot during turning. This can mess with odometry. I would trade the tracks for wheels if you want a bit more accuracy.

As for what 66 was talking about: you are only using one transition of the four transitions open to you. You can interrupt on A going from low to high as well as A going from high to low. Likewise you can interrupt on both B transitions. This would give you 4 interrupts a opposed to the one you have now, which would give you four times the precision.

I also think that it would take you less time to read and understand (through experimentation) one of the many tutorials available on quadrature encoding than continuing to ask here. I’m saying this for your sake, because if we continue to write your code for you, it will take you longer to understand the subject.