BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Sun Nov 19, 2017 11:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Roboclaw 2x60A User Manual - Command 18-19 are wrong
PostPosted: Mon Aug 25, 2014 11:34 pm 
Offline
Citizen

Joined: Fri Oct 05, 2012 1:44 pm
Posts: 5
Location: Germany
Hello Support and others,

I created a library for the Roboclaw 2x30A a year ago.
Now I wanted to use this library for the new Roboclaw 2x60 version.
In the first view everything looks good, but then I realized, that my library only returned positive speed values.

In the RoboClaw 2x30A version you get 6 bytes back if you use command 18 or 19. 4 bytes are for the actual PPS (pulse per second) and the 5th byte is for the direction it can be 0 or 1, the 6th is the checksum.
I build the ppsValue which includes the actual pulsePerSeconds like this:
Code:
ppsValue = (int)pBuffer[3]; // pBuffer contains the received data from the roboclaw
ppsValue += (int)pBuffer[2] << 8;
ppsValue += (int)pBuffer[1] << 16;
ppsValue += (int)pBuffer[0] << 24;
direction = pBuffer[4];

To use the direction information i can calculate something like this:
Code:
if(direction == 1)
 actualSpeedValue1 = ppsValue1 * -1;
else
 actualSpeedValue1 = ppsValue1 ;

This worked in the 2x30 version without any problems! but I realized, that in the 2x60 version you already get a inverted speed value directly from the Roboclaw.

But in the User Manual it is not described that you get negative values you say you will get only positive values :
Quote:
The command will return 6 bytes. Byte 1,2,3 and 4 make up a long variable which is received
MSB first and is the current ticks per second which can be any value from 0 - 4,294,967,295.
Byte 5 is the direction (0 – forward, 1 - backward). Byte 6 is the checksum.

what I can confirm for the Roboclaw 2x30 version. But not for the 2x60 version!

So please actualize the User Manual and make a notification that these commands have been changed and that they will work different in different Roboclaw versions.

Best regards,
Thomas


Top
 Profile  
 
 Post subject: Re: Roboclaw 2x60A User Manual - Command 18-19 are wrong
PostPosted: Mon Sep 08, 2014 1:49 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
The direction bit in the status byte is only there to be used if you want a quick way of determining the direction.

The speed value returned is in signed 2s complement form so you don't need to check the status bit value at all if you just want the current speed value.

The encoder count value is a 32bit value. You can read it as if its signed or not signed. It entirely depends on how you determine the value is read. A -1 is the same as 2^32-1(eg 4billion and change).

But the speed value is always signed.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO