Packet Motor Encoder Read Invalid

Questions about using encoders with the Roboclaw product line
Post Reply
Posts: 1
Joined: Fri Oct 26, 2018 8:56 pm

Packet Motor Encoder Read Invalid

Post by chas » Fri Oct 26, 2018 9:07 pm


I copied and pasted your example code from the packet serial motor encoder read sample within your arduino library into my library sketch. I have had no problem moving the motors, turning, etc .. but moving on I wanted to start reading encoder data.

The output of the sample code you provide dumps: Encoder1:invalid Encoder2:invalid Speed1:invalid Speed2:invalid

I used your sample code because I noticed when using my code, derived from your samples, I was getting "0" ticks from the encoder when the wheels were moved.

I have a 2x7A w/ Pololu 37D 50:1 motors w/ the encoders. When using your studio software I can command the motors within the PWM screen and they'll move forward/back... and the encoders count the correct direction and appear to read properly. I did make some tweaks where I could have just flipped some motor wires but figured since the software allows for inverting... see my screen shot attached.

Additionally, and likely related. Tuning in the "velocity" settings rocks the motors back and forth a few times then they just go high speed in reverse forever. In the PWM settings attempting a tune there also runs the motor at full speed for ever. I'm guessing this is related.

Please see my screen shot attached.

ultimately I don't care to tune if I can't, I would really like the grab encoder ticks though.

Thank you,
rc_issue1.png (219.46 KiB) Viewed 2343 times

User avatar
Basicmicro Support
Posts: 1338
Joined: Thu Feb 26, 2015 9:45 pm

Re: Packet Motor Encoder Read Invalid

Post by Basicmicro Support » Mon Oct 29, 2018 10:25 am

FIrst you need to get the encoders workign correctly in Motion Studio.

1. Check that the encoders are counting in the correct direction. Open PWM Settings and move the slider UP. The encoder count should increase(positive). Move the slider down from center and the encoder should count down(negative).

2. Move the motor at full power(slider all the way up) and note the speed. Do the same in reverse(all the way down). Are the values for the maximum speeds close to the same.

If your motor direction relative to the encoders is wrong the autotuner will do eactly what you described. Assume you fix the direction and tune the motors and test that they are running correctly in Motion studio then we can start looking at your packet serial programs. I assume you are eithe rusing an arduino or using Python on the PC? Please confirm.

Posts: 2
Joined: Tue Dec 11, 2018 10:23 pm

Re: Packet Motor Encoder Read Invalid

Post by iHaa » Sun Dec 16, 2018 7:09 pm

Just piggybacking on this thread since I've got a similar issue.

I am unable to get valid readings on my Arduino Mega.

As per my research, I've got everything set up properly - correct readings in Basic Micro Motion Studio, updated firmware and Arduino libraries.

I could only get it to work once (after updating Roboclaw's firmware to 4.1.27 and updating my Arduino libraries, and after a day, it stopped working). It also works when the USB from the Roboclaw 2x30A is connected to my PC.

Is there a fix to this yet?

User avatar
Basicmicro Support
Posts: 1338
Joined: Thu Feb 26, 2015 9:45 pm

Re: Packet Motor Encoder Read Invalid

Post by Basicmicro Support » Mon Dec 17, 2018 10:50 am

iHaa, It sounds like your problem is not the same. The previous poster had a problem reading encoders at all(in Motion Studio as well).

Based on your post you do not have that problem(you say it works in Motion studio). If you can see the encoder readings in Motion studio then the problem is in your communciation between the Arduino and the Roboclaw. Since it was working before and now is not you need to check your wiring. Make sure other commands work(as a start make sure the readversion command returns the versions string).

Make sure you are using the latest Roboclaw arduino library from our website(not a resellers website).

Provide the arduino code you are using to read the encoder values(a simplified version please, just the code you need to read and display the encoder values).

Post Reply