Re: Is encoder count signed or unsigned?
Posted: Wed Jun 13, 2018 10:05 am
Both ReadEncM# commands return a uint32_t(based on the roboclaw.h and roboclaw.cpp files I just looked at sothis is a typo in the user manual.
Because of some idiosyncracies with Arduino(and GCC) the ReadEncM# and SpeedAccelDeccelPosition commands use unsigned variables. However you can store those values in signed 32bit variables just fine and get the correct +- ranges.
A signed 32bit variable is used with the SetEnc commands for a similar reason but I dont remember the exact reason it couldnt use an unsigned value.
In general if you use signed variables for all your commands you will be fine.
Because of some idiosyncracies with Arduino(and GCC) the ReadEncM# and SpeedAccelDeccelPosition commands use unsigned variables. However you can store those values in signed 32bit variables just fine and get the correct +- ranges.
A signed 32bit variable is used with the SetEnc commands for a similar reason but I dont remember the exact reason it couldnt use an unsigned value.
In general if you use signed variables for all your commands you will be fine.