always get zero for Status and Valid for encoder

General discussion of using Roboclaw motor controllers
Post Reply
TedRobotBuilder
Posts: 12
Joined: Mon Aug 31, 2015 8:00 am
always get zero for Status and Valid for encoder

Post by TedRobotBuilder »

I always get zero for Status and Valid when I call for an encoder value on channel one using two-way serial with arduino. Channel two works fine with the same encoder hooked to it. I can see channel one increment and decrement the value for encoder one channel but Status and Valid are always zero which doesn't allow me to filter out bad values.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: always get zero for Status and Valid for encoder

Post by Basicmicro Support »

Please provide your code.

Also what do you mean by valid(I assume bit 8, 0x80, of the status byte). If so that bit is always set on xmega based Roboclaws. On older(much much much older) Roboclaws we had separate quadrature decoders so we had to know if the decoder was working correctly or not. It is now always set to 1 for backwards compatibility.
TedRobotBuilder
Posts: 12
Joined: Mon Aug 31, 2015 8:00 am
Re: always get zero for Status and Valid for encoder

Post by TedRobotBuilder »

acidtech wrote:Please provide your code.

Also what do you mean by valid(I assume bit 8, 0x80, of the status byte). If so that bit is always set on xmega based Roboclaws. On older(much much much older) Roboclaws we had separate quadrature decoders so we had to know if the decoder was working correctly or not. It is now always set to 1 for backwards compatibility.
I am using a version5 board with the latest firmware.

I am running your example code: PacketSerialEncoderSpeed.ino

I am using a Mega with UART pins.

for valid and status I am talking about your valid flag and status flag in your code:

Code: Select all

uint32_t enc1= roboclaw.ReadEncM1(address, &status1, &valid1);
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: always get zero for Status and Valid for encoder

Post by Basicmicro Support »

We just updated everything(Sunday 10/11/2015), IonMotion, Roboclaw firmware and Arduino libraries so you should update your files. I recommend you grab the new arduino files, update your firmware using IonMotion and check this example again to see if you still have any trouble. We use Arduino 1.0.5 to test all the examples and newer arduino IDEs should also work.

The main change is we have changed to a CRC16 checksum. The arduino libraries have been updated to better handle communicaitons errors. The valid1 returning 0 indicates a communications error, not any kind of hardware error(eg either the return data timed out or the checksum came back incorrect).
TedRobotBuilder
Posts: 12
Joined: Mon Aug 31, 2015 8:00 am
Re: always get zero for Status and Valid for encoder

Post by TedRobotBuilder »

Working much better so far. I haven't completely regression tested but so far it is looking very good. Thanks!

Post Reply