Again ... Encoder Counts Problem

Encoder_ino.zip (1182Bytes)
output.zip (8133Bytes)

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 in the attachment , while I am testing the encoders counts , I noticed that there is a difference between counts of encoders even when they spin in the same constant speed (PMW) , the difference increases as the two motors continue . so I thought that is the main cause of inaccurate odometery results .

In the output of the code (in the attachment also) the first two columns are right and left motors speed , the third & forth columns are right and left encoder counts , the fifth column is the difference between two encoders count , as you could see ,that even when the speed of two motors are approximately the same (each motor feed up with 100 PWM) there is a difference in the encoder counts and as you could see that the difference become big and big as the motors continuing spin .

 

One thing I thought that sending the same PWM value to two different motors will almost never produce the exact same speed , so I think that I should detect the absolute motion of the motors and adjust the power to get the speed/distance , but when I test the speed of motors 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 .

Actually , I don't know where is the problem , Is it in the code ? Is it in the hardware ? or what ? I am completely lost , I need for patient someone to help .

Encoders

I was unable to unzip your attachments. If I send the same PWM signal to two different motors I would expect different RPMs. I use the feedback from the encoders to adjust the PWM to get the desired speeds. With hardware decoders I expect to lose a countwhen reading/resetting the counters.

What hardware/software are you using?

thanks ggallant for replythe

thanks ggallant for reply

the links below show my early post here in this forum

https://www.robotshop.com/letsmakerobots/need-help-rover-5-robot

https://www.robotshop.com/letsmakerobots/programming-odometry-rover-5

https://www.robotshop.com/letsmakerobots/translation-shaft-encoder-data

https://www.robotshop.com/letsmakerobots/i-need-help-and-guide-case

 

Actually , I hope to use your experiment to adjust the PWM to get the desired speeds by encoders .