Hi
What is the suitable code to test the speed of two DC motors of Rover 5 (had two encoders ) ?
Hi
What is the suitable code to test the speed of two DC motors of Rover 5 (had two encoders ) ?
any answer ???
But you've got code for this haven't you? You gave results a few days ago.
What does this mean though:
had two encoders
..... Do they no longer have encoders? Have you changed the hardware?
JimboZA:
But you've got code for this haven't you? You gave results a few days ago.What does this mean though:
had two encoders
..... Do they no longer have encoders? Have you changed the hardware?
thanks JimboZA
But you've got code for this haven't you? You gave results a few days ago.
that's right , I have been here since two weeks looking for convinced and final solution for my problem , actually I am completely lost , the problem is that the motors when feeding up them with same constant speed (PMW)and monitor the encoder counts , the counts of two encoders are not the same , there is a big difference . Actually I tried to use many codes for testing . I don't know where is the problem , Is it code , Is it in the hardware , I am completely lost . need for patient someone to help .
..... Do they no longer have encoders? Have you changed the hardware?
No , it is same Rover 5 with two encoders , I want to function the encoders to determine the Odomtery (X, Y , Heading ).
the problem is that the motors when feeding up them with same constant speed (PMW)and monitor the encoder counts , the counts of two encoders are not the same , there is a big difference .
Post a complete program that shows this problem. Just a fixed PWM output to the 2 motors and the code to read and display the encoders values from them. An explanation of how the encoders and Arduino are wired, or better still a circuit diagram would also help.
How are the motors and Arduino powered ?
We've discussed this before: the two motors will almost certainly not run at the same speed, so why should the encoders be the same. You should accept that fact. The whole point of encoders, as already pointed out to you at the weekend, is to see the difference in motor speeds so you can speed one up or slow one down to get the vehicle moving straight. When moving straight, the pwm values will very likely differ from one side to the other, because the motors and gearboxes are different.
You posted results the other day that showed the speeds were in fact pretty close, identical in some cases.
Someone gave you an answer about those huge 20-million or whatever it was, encoder readings.
The only way to see if the encoders agree is to put both encoders on the same wheel at the same time, or at least at different times but with the same pwm value and see if the encoder readings are the same. Then when you know the encoders agree, when they are on their actual wheels you can accept their values and if one wheel goes faster than the other at same pwm, well that's the way of it. Adjust one wheel's pwm until their encoders agree, even if the pwms are then different.
UKHeliBob:
the problem is that the motors when feeding up them with same constant speed (PMW)and monitor the encoder counts , the counts of two encoders are not the same , there is a big difference .
Post a complete program that shows this problem. Just a fixed PWM output to the 2 motors and the code to read and display the encoders values from them. An explanation of how the encoders and Arduino are wired, or better still a circuit diagram would also help.
How are the motors and Arduino powered ?
thanks UKHeliBob and JimboZA
Wires connections as follow :
L298 driver is feed up with 8 V and then I take 5 V & Ground pins of L298 driver and feed it up to Arduino mega .
ENA of L298 driver connected to Arduino's port 8
ENB of L298 driver connected to Arduino's port 9
IN1 of L298 driver connected to Arduino's port 48
IN2 of L298 driver connected to Arduino's port 49
IN3 of L298 driver connected to Arduino's port 50
IN4 of L298 driver connected to Arduino's port 51
Out1 of L298 driver connected to RightMotorWire1
Out2 of L298 driver connected to RightMotorWire2
Out3 of L298 driver connected to LeftMotorWire1
Out4 of L298 driver connected to LeftMotorWire2
LeftEncoderPinA 2 // connected to signal A of left encoder (White wire )
LeftEncoderPinB 4 // connected to signal B of left encoder (yellow wire )
RightEncoderPinA 3 // connected to signal A of right encoder (White wire )
RightEncoderPinB 5 //connected to signal B of right encoder (yellow wire )
when I test the speed of motors with code below , after feed them with 100 PWM at same time , the two speeds were almost identical , but I noticed that there is a difference between counts of two encoders even when the motors spin in the same constant speed , the difference is between 10 - 50 and increase as the two motors continue spinning as seen in the output
newposition1 = encoder1Pos;
newtime1 = millis();
vel1 = (newposition1-oldposition1) * 1000 /(long)(newtime1-oldtime1);
oldposition1 = newposition1;
oldtime1 = newtime1;
The only way to see if the encoders agree is to put both encoders on the same wheel at the same time,
I couldn't because I used Rover 5 with encoders equipped by manufacture , it is hard to open and install them again.
the code below for that test and you could see the the speed of two motors is 100 .
#define encoder0PinA 3
#define encoder0PinB 5
#define encoder1PinA 2
#define encoder1PinB 4
int ENA=8; // SpeedPinA connected to Arduino's port 8
int ENB=9; // SpeedPinB connected to Arduino's port 9
int IN1=48; // RightMotorWire1 connected to Arduino's port 48
int IN2=49; // RightMotorWire2 connected to Arduino's port 49
int IN3=50; // RightMotorWire1 connected to Arduino's port 48
int IN4=51; // RightMotorWire2 connected to Arduino's port 49
volatile long encoder0Pos=0;
long newposition;
long oldposition = 0;
unsigned long newtime;
unsigned long oldtime = 0;
long vel;
volatile long encoder1Pos=0;
long newposition1;
long oldposition1 = 0;
unsigned long newtime1;
unsigned long oldtime1 = 0;
long vel1;
void setup()
{
Serial.begin(9600);
pinMode(ENA,OUTPUT);
pinMode(ENB,OUTPUT);
pinMode(IN1,OUTPUT);
pinMode(IN2,OUTPUT);
pinMode(IN3,OUTPUT);
pinMode(IN4,OUTPUT);
digitalWrite(ENA,HIGH); //enable motorA
digitalWrite(ENB,HIGH); //enable motorB
pinMode(encoder0PinA, INPUT);
digitalWrite(encoder0PinA, HIGH); // turn on pullup resistor
pinMode(encoder0PinB, INPUT);
digitalWrite(encoder0PinB, HIGH); // turn on pullup resistor
attachInterrupt(1 ,doEncoder, RISING); // encoDER ON PIN 2
pinMode(encoder1PinA, INPUT);
digitalWrite(encoder1PinA, HIGH); // turn on pullup resistor
pinMode(encoder1PinB, INPUT);
digitalWrite(encoder1PinB, HIGH); // turn on pullup resistor
attachInterrupt(0, doEncoder1, RISING); // encoDER ON PIN 2
Serial.begin (9600);
}
int WR=100; // angular velocity of right wheel
int WL=100; // angular velocity of right wheel
void loop()
{
int rightPWM;
if (WR > 0) {
//forward
digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
} else if (WR < 0){
//reverse
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
}
if (WR == 0) {
rightPWM = 0;
analogWrite(ENA, rightPWM);
} else {
rightPWM=WR;
analogWrite(ENA, rightPWM);
}
int leftPWM;
if (WL > 0) {
//forward
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
} else if (WL < 0) {
//reverse
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);}
if (WL == 0) {
leftPWM = 0;
analogWrite(ENB, leftPWM);
} else {
leftPWM=WL;
analogWrite(ENB, leftPWM);
}
newposition = encoder0Pos;
newtime = millis();
vel = (newposition-oldposition) * 1000 /(long)(newtime-oldtime);
Serial.print (vel*-1);
Serial.print ("\t\t");
oldposition = newposition;
oldtime = newtime;
newposition1 = encoder1Pos;
newtime1 = millis();
vel1 = (newposition1-oldposition1) * 1000 /(long)(newtime1-oldtime1);
Serial.print (vel1);
Serial.print ("\t\t");
Serial.print(abs(vel)-abs(vel1));
Serial.print ("\t\t");
Serial.print(encoder0Pos*-1);
Serial.print ("\t\t");
Serial.print(encoder1Pos);
Serial.print ("\t\t");
Serial.println(abs(encoder0Pos) - abs(encoder1Pos));
oldposition1 = newposition1;
oldtime1 = newtime1;
delay(250);
}
void doEncoder()
{
if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB)) {
encoder0Pos++;
} else {
encoder0Pos--;
}
}
void doEncoder1()
{
if (digitalRead(encoder1PinA) == digitalRead(encoder1PinB)) {
encoder1Pos++;
} else {
encoder1Pos--;
}
}
the output
56 59 -3 14 15 -1
87 87 0 36 38 -2
96 95 1 60 61 -1
95 96 -1 84 85 -1
95 95 0 109 109 0
95 95 0 132 133 -1
95 91 4 156 156 0
99 95 4 181 180 1
99 95 4 206 204 2
95 91 4 230 227 3
99 99 0 255 252 3
100 100 0 280 277 3
99 91 8 305 300 4
91 95 -4 328 324 4
95 95 0 352 348 4
91 95 -4 375 372 3
91 95 -4 398 396 2
91 91 0 421 419 2
95 91 4 445 442 3
96 96 0 469 466 3
99 95 4 494 490 4
95 99 -4 518 515 3
99 95 4 543 539 4
95 107 -12 568 566 2
95 95 0 591 590 1
95 99 -4 615 615 0
95 107 -12 639 642 -3
95 99 -4 663 667 -4
96 96 0 687 691 -4
99 95 4 712 715 -3
91 99 -8 735 740 -5
99 99 0 760 765 -5
95 91 4 784 788 -4
95 103 -8 808 814 -6
95 91 4 832 838 -6
.
.
.
99 95 4 1330 1334 -4
95 95 0 1354 1358 -4
99 95 4 1379 1382 -3
91 95 -4 1402 1406 -4
99 103 -4 1427 1432 -5
91 95 -4 1450 1456 -6
91 95 -4 1473 1480 -7
96 95 1 1497 1504 -7
95 99 -4 1521 1529 -8
91 95 -4 1544 1553 -9
103 95 8 1570 1577 -7
95 95 0 1594 1601 -7
99 95 4 1619 1625 -6
99 95 4 1644 1649 -5
95 95 0 1668 1674 -6
.
.
.
87 95 -8 2362 2369 -7
99 95 4 2387 2392 -6
91 99 -8 2410 2417 -7
95 95 0 2434 2441 -7
95 95 0 2458 2465 -7
95 95 0 2482 2489 -7
95 95 0 2506 2513 -7
96 92 4 2530 2536 -6
87 95 -8 2552 2560 -8
95 95 0 2576 2584 -8
95 95 0 2601 2608 -7
99 103 -4 2625 2634 -9
.
.
.
100 103 -3 3563 3596 -33
95 96 -1 3587 3621 -34
91 107 -16 3610 3647 -37
95 91 4 3634 3670 -37
99 99 0 3659 3695 -36
95 99 -4 3683 3720 -37
87 95 -8 3705 3744 -39
99 103 -4 3730 3770 -40
99 99 0 3755 3795 -40
96 95 1 3779 3819 -40
95 95 0 3803 3843 -40
95 99 -4 3827 3868 -41
95 95 0 3851 3892 -41
91 99 -8 3874 3917 -43
99 95 4 3899 3941 -42
99 99 0 3924 3966 -42
99 99 0 3949 3992 -43
99 99 0 3974 4016 -42
96 100 -4 3999 4041 -42
99 95 4 4023 4065 -42
95 95 0 4047 4089 -42
99 99 0 4072 4114 -42
.
.
.
.
.
.
95 79 16 6714 6792 -78
100 112 -12 6739 6820 -81
87 83 4 6761 6841 -80
95 95 0 6785 6865 -80
95 87 8 6809 6887 -78
95 95 0 6833 6911 -78
75 75 0 6852 6930 -78
27 19 8 6859 6935 -76
I noticed that there is a difference between counts of two encoders even when the motors spin in the same constant speed
The fact that the encoder counts are different for each wheel would seem to indicate that the motors are not running at the same constant speed, but that is nothing to worry about and for cheap DC motors is to be expected.
When you feed a signal with the same PWM value to both motors does the robot run straight ? I would be amazed if it did. The solution is to count the encoder signals for a period of time and to adjust the speed of the motors to slow the fast one and speed up the slow one then start the count again and adjust again after a period of time and so on. The smart way to do this is to use a PID to sense the difference between the encoder counts and adjust the motor speeds accordingly,
UKHeliBob:
I noticed that there is a difference between counts of two encoders even when the motors spin in the same constant speed
The fact that the encoder counts are different for each wheel would seem to indicate that the motors are not running at the same constant speed, but that is nothing to worry about and for cheap DC motors is to be expected.
When you feed a signal with the same PWM value to both motors does the robot run straight ? I would be amazed if it did. The solution is to count the encoder signals for a period of time and to adjust the speed of the motors to slow the fast one and speed up the slow one then start the count again and adjust again after a period of time and so on. The smart way to do this is to use a PID to sense the difference between the encoder counts and adjust the motor speeds accordingly,
thanks a lot UKHeliBob
When you feed a signal with the same PWM value to both motors does the robot run straight ? I would be amazed if it did.
I can almost say Yes .
The fact that the encoder counts are different for each wheel would seem to indicate that the motors are not running at the same constant speed
but if monitor the output you could see that the speed of two wheel almost the same .
95 99 -4 663 667 -4
**96 96 ** 0 687 691 -4
99 95 4 712 715 -3
91 99 -8 735 740 -5
**99 99 ** 0 760 765 -5
95 91 4 784 788 -4
95 103 -8 808 814 -6
95 91 4 832 838 -6
Actually , I have questions need to some explanation .
The code below , is it the right way to determine the speed of motor by encoders ?
newposition1 = encoder1Pos;
newtime1 = millis();
vel1 = (newposition1-oldposition1) * 1000 /(long)(newtime1-oldtime1);
oldposition1 = newposition1;
oldtime1 = newtime1;
The smart way to do this is to use a PID to sense the difference between the encoder counts and adjust the motor speeds accordingly,
so is there any posts or tutorial could help me in that way ?
thanks
waiting for any answer ![]()
so is there any posts or tutorial could help me in that way ?
My advice would be to stay away from PIDs to start with and use the crude method because you will have full control over what is going on.
Some pseudo code for you
declare global variables
setup() function
{
usual stuff to set up pinModes and interrupts
}
loop() function
if it is time to adjust speeds (use the BlinkWithoutDelay principle using millis())
if the left encoder count is higher than the right encoder count
speed up the right motor a small amount
slow down the left motor a small amount
end if
else
if the right encoder count is higher than the left encoder count
speed up the left motor a small amount
slow down the right motor a small amount
end if
zero both encoder counts
reset the timing variables
end if
end of loop function
left encoder ISR
add 1 to left encoder count
end of function
right encoder ISR
add 1 to right encoder count
end of function
If you want to explore the use of a PID then this page will get you started but it can be hard going Arduino Playground - HomePage
UKHeliBob:
so is there any posts or tutorial could help me in that way ?
My advice would be to stay away from PIDs to start with and use the crude method because you will have full control over what is going on.
Some pseudo code for you
declare global variables
setup() function
{
usual stuff to set up pinModes and interrupts
}
loop() function
if it is time to adjust speeds (use the BlinkWithoutDelay principle using millis())
if the left encoder count is higher than the right encoder count
speed up the right motor a small amount
slow down the left motor a small amount
end if
else
if the right encoder count is higher than the left encoder count
speed up the left motor a small amount
slow down the right motor a small amount
end if
zero both encoder counts
reset the timing variables
end if
end of loop function
left encoder ISR
add 1 to left encoder count
end of function
right encoder ISR
add 1 to right encoder count
end of function
If you want to explore the use of a PID then this page will get you started but it can be hard going http://playground.arduino.cc/Code/PIDLibrary
thanks a lot
but could I considered that the code below , it is the right code to determine the speed of motor by encoders ?
newposition1 = encoder1Pos;
newtime1 = millis();
vel1 = (newposition1-oldposition1) * 1000 /(long)(newtime1-oldtime1);
oldposition1 = newposition1;
oldtime1 = newtime1;
I am again… !
Encoders problem again…!
Odometery problem again…!
Actually , I have been since two weeks looking for convinced and final solution for my problem , actually I am completely lost , the members here I think they know about my problem since I post here many times but no problem to remember again , I am working on mobile robot (Rover 5) with 2 motors , 2 encoders . the controller that designed to the robot needs to know the odometery of mobile robot (X ,Y, Heading Angle ) , actually I am trying to function the encoders for this purpose , getting X ,Y, Heading Angle by measuring the traveled distance by each wheel , so to get the X ,Y, Heading Angle values , I should compute a accurate readings without missing any counts or ticks as could as possible .
The problem now is : In the code below , while I am testing the encoders counts , I noticed that odometry results computed by code are wrong and not identical the value on real world where robot is located .
In the test code the speed of right and left motors are feed up 50 PWM & 100 PWM respectively and at same time , but when I solve the odometry equations manually and compare results with code results , the two results are not identical , for example , lets take the output line
Left Encoder= 27 Right Encoder= 15 X= 0.01 Y= 0.03 Heading= 56.22
deltaHeading = (double)(deltaRight - deltaLeft) / TrackWidth;
= ( 15 - 27 ) /0.189
= -63.4920
Left Encoder= 705 Right Encoder= 571 X= -0.17 Y= -0.09 Heading= 531.41
deltaHeading = (double)(deltaRight - deltaLeft) / TrackWidth;
= ( 571 - 705 ) / 0.189
= -708.99
Actually , I don't know where is the problem , Is it in the code ? Is it in the hardware ? or what ?
the code below and the output of code in the attachments
#define encoder0PinA 2
#define encoder0PinB 4
#define encoder1PinA 3
#define encoder1PinB 5
#define PI 3.14159265
#define TwoPI 6.28318531
volatile int LeftEncoderCounts = 0;
volatile int RightEncoderCounts = 0;
int WR=50; // angular velocity of right wheel
int WL=100; // angular velocity of right wheel
double _DistancePerCount;
double _radiansPerCount;
//long _leftEncoderCounts;
long _PreviousLeftEncoderCounts;
// long _RightEncoderCounts;
long _PreviousRightEncoderCounts;
double X; // x coord in global frame
double Y; // y coord in global frame
double Heading; // heading (radians) in the global frame. The value lies in (-PI, PI]
double WheelDiameter;
double TrackWidth;
double CountsPerRevolution;
double DistancePerCount;
double RadiansPerCount;
int ENA=8; // SpeedPinA connected to Arduino's port 8
int ENB=9; // SpeedPinB connected to Arduino's port 9
int IN1=48; // RightMotorWire1 connected to Arduino's port 48
int IN2=49; // RightMotorWire2 connected to Arduino's port 49
int IN3=50; // RightMotorWire1 connected to Arduino's port 48
int IN4=51; // RightMotorWire2 connected to Arduino's port 49
void setup() {
Serial.begin (9600);
pinMode(ENA,OUTPUT);
pinMode(ENB,OUTPUT);
pinMode(IN1,OUTPUT);
pinMode(IN2,OUTPUT);
pinMode(IN3,OUTPUT);
pinMode(IN4,OUTPUT);
digitalWrite(ENA,HIGH); //enable motorA
digitalWrite(ENB,HIGH); //enable motorB
pinMode(encoder0PinA, INPUT);
pinMode(encoder0PinB, INPUT);
pinMode(encoder1PinA, INPUT);
pinMode(encoder1PinB, INPUT);
// encoder pin on interrupt 0 (pin 2)
attachInterrupt(0, doEncoderA, CHANGE);
// encoder pin on interrupt 1 (pin 3)
attachInterrupt(1, doEncoderB, CHANGE);
WheelDiameter = 0.062;
TrackWidth = 0.189;
CountsPerRevolution = 83;
DistancePerCount = (PI * WheelDiameter) / (double)CountsPerRevolution;
RadiansPerCount = DistancePerCount / TrackWidth;
}
void loop(){ //Do stuff here
int rightPWM;
if (WR > 0) {
//forward
digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
} else if (WR < 0){
//reverse
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
}
if (WR == 0) {
rightPWM = 0;
analogWrite(ENA, rightPWM);
} else {
rightPWM = map(abs(WR), 1, 100, 1, 255);
// rightPWM=WR;
analogWrite(ENA, rightPWM);
}
int leftPWM;
if (WL > 0) {
//forward
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
} else if (WL < 0) {
//reverse
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);}
if (WL == 0) {
leftPWM = 0;
analogWrite(ENB, leftPWM);
} else {
leftPWM = map(abs(WL), 1, 100, 1, 255);
//leftPWM=WL;
analogWrite(ENB, leftPWM);
}
long deltaLeft = LeftEncoderCounts - _PreviousLeftEncoderCounts;
long deltaRight = RightEncoderCounts - _PreviousRightEncoderCounts;
double deltaDistance = 0.5f * (double)(deltaLeft + deltaRight) * DistancePerCount;
double deltaX = deltaDistance * (double)cos(Heading);
double deltaY = deltaDistance * (double)sin(Heading);
double deltaHeading = (double)(deltaRight - deltaLeft) / TrackWidth;
X += deltaX;
Y += deltaY;
Heading += deltaHeading;
if (Heading > PI)
{
Heading -= TwoPI;
}
else
{
if (Heading <= -PI)
{
Heading += TwoPI;
}
}
_PreviousLeftEncoderCounts = LeftEncoderCounts;
_PreviousRightEncoderCounts =RightEncoderCounts;
Serial.print("Left Encoder= ");
Serial.print(LeftEncoderCounts*-1);
Serial.print("\t\t");
Serial.print("Right Encoder= ");
Serial.print (RightEncoderCounts*-1);
Serial.print("\t\t");
Serial.print("X= ");
Serial.print(X);
Serial.print("\t\t");
Serial.print("Y= ");
Serial.print(Y);
Serial.print("\t\t");
Serial.print("Heading= ");
Serial.println(Heading);
}
void doEncoderA(){
// look for a low-to-high on channel A
if (digitalRead(encoder0PinA) == HIGH) {
// check channel B to see which way encoder is turning
if (digitalRead(encoder0PinB) == LOW) {
LeftEncoderCounts = LeftEncoderCounts + 1; // CW
}
else {
LeftEncoderCounts = LeftEncoderCounts - 1; // CCW
}
}
else // must be a high-to-low edge on channel A
{
// check channel B to see which way encoder is turning
if (digitalRead(encoder0PinB) == HIGH) {
LeftEncoderCounts = LeftEncoderCounts + 1; // CW
}
else {
LeftEncoderCounts = LeftEncoderCounts - 1; // CCW
}
}
}
void doEncoderB(){
// look for a low-to-high on channel B
if (digitalRead(encoder1PinB) == HIGH) {
// check channel A to see which way encoder is turning
if (digitalRead(encoder1PinA) == HIGH) {
RightEncoderCounts = RightEncoderCounts + 1; // CW
}
else {
RightEncoderCounts = RightEncoderCounts- 1; // CCW
}
}
// Look for a high-to-low on channel B
else {
// check channel B to see which way encoder is turning
if (digitalRead(encoder1PinA) == LOW) {
RightEncoderCounts = RightEncoderCounts + 1; // CW
}
else {
RightEncoderCounts = RightEncoderCounts - 1; // CCW
}
}
}
Output_of_the_code.ino (4.43 KB)
Maria88:
since I post here many times
Post link(s) to the earlier Thread(s) so we have all the background info.
...R
Robin2:
Maria88:
since I post here many timesPost link(s) to the earlier Thread(s) so we have all the background info.
...R
thanks Robin2
I thinks the current post where we are is enough to show the problem and if there any questions I will be here to answer .
thanks
Maria88:
I thinks the current post where we are is enough to show the problem and if there any questions I will be here to answer .
It looks like someone has merged the Threads so I don't have to disagree with you ![]()
I don't understand what you mean by this
Left Encoder= 27 Right Encoder= 15 X= 0.01 Y= 0.03 Heading= 56.22
deltaHeading = (double)(deltaRight - deltaLeft) * TrackWidth;
= ( 15 - 27 ) * 0.189
= -63.4920
The answer should be -2.268 but when I look in your code the formula divides by Trackwidth hence -63.492. Which is correct?
Can you provide an overview of where you are with your project at this stage?
Earlier you seemed to be having trouble with relating the encoder counts and the PWM settings. Has that now been resolved?
The reason I ask is that there seems little point in discussing how the encoder counts should be processed unless you are satisfied that the counting is correct.
Are all these complicated formula really necessary? If you want the robot to go straight you just need to adjust the speeds to get the encoder counts to stay the same, or nearly the same. I imagine that turns could also be worked out with simple integer maths. Unless you are relating the movement of the robot to an external reference (GPS or compass) the apparent accuracy of cosines to three decimal places is unlikely to have any connection with reality. The same goes for wheel diameter unless the two wheels have different diameters - even then a simple correction should be sufficient.
...R