Absolute position control

Questions about using encoders with the Roboclaw product line
Post Reply
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Absolute position control

Post by Basicmicro Support »

Im going to assume you want to use an RC signal to control a motors position like a giant servo? If you want to use a different control method(Analog signal,Packet Serial) please let me know. Your post is somewhat limited on info.

First thing you need to do is get your motor and encoders wired up. Do you plan on using a Absolute Encoder(eg: Potentiometer) or a Quadrature encoder?
jonasb
Posts: 3
Joined: Sat Nov 21, 2015 9:33 pm
Re: Absolute position control

Post by jonasb »

Same issue for me. I have a linear actuator with pot feedback. I want to use packet (not RC) mode to send roboclaw 2x5A a command to go to a position based on the feedback pot. The documentation and examples are almost non existent for packet with analog position feedbacl. Can this be done? Just to clarify, I am trying to get roboclaw to take care of feedback loop and do not want to read the pot in the arduino and handle the feedback that way.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Absolute position control

Post by Basicmicro Support »

Except for changing the encoder type(go to General Settings in IonMotion and change the type(s) to Absolute for the specific motor channel(s)) the Absolute enocder wiring(eg analog POT) information starts on page 56 of the manual and leads into manual tuning and then auto tuning.

For packet serial mode that pretty much explains all of it. Please make sure you read the entire section on tuning and especially the "Auto tuning" section that explains how to check if your motor is moving in the correct direction. You have to make sure your motor is moving in the correct direction relative to the power coming from the Roboclaw or the PID control will run away and probably destroy your POT.

If you need more help setting it up please call in and we'll walk through the setup with you.
jonasb
Posts: 3
Joined: Sat Nov 21, 2015 9:33 pm
Re: Absolute position control

Post by jonasb »

My motor controller is pre USB so I have to do everything via packet commands from the Arduino. I think I have it sorted out but not tested yet. I am using the Arduino libraries you provide. Am I correct that after the initial "lib includes and definitions", in setup I have to: Begin roboclaw comms, Set Encoder Mode to B10000001, Set velocity PID, and then Set position PID with min and max position values based on the 0-2047 range before I can send any position commands when I am using a pot as an absolute encoder.

I do have some additional questions. Are the position PID different from the velocity PID?

Also I am a little confused about the speed variable. The manual keeps talking about pulses. In abs mode, no pulses so what are the speed values based on (a derived QPPS or the 0-127 range used in the simple commands)? Command 35 Set M1 speed would be an example. My linear actuator has limit switches so not too worried about runaway damage.

It looks like only commands 65 and 66 use the position info for controlling the motor. Is there a way to compute distance based on current and desired position so you can use commands like 41 or is this affected by velocity and/or acceleration. If not how do I set the accel and decel values in 65 to just turn on and off the motor to go the desired position with no ramping in absolute encoder mode?

BTW in digging into the V5 user manual I noticed an inconsistency with the Arduino libraries. The libraries set the data by sending it out in PID order, the user manual says the hardware is expecting DIP order. Same issue with reading. Which is correct?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Absolute position control

Post by Basicmicro Support »

You can do everything but autotune through the TTL serial packet serial commands. Manual tuning isnt too difficult and if you have any questions please call in or post a new thread specific to tuning.

Are you using a 2x5A or is your board a really old 2x15/2x30 that didnt have USB? If the latter you can send it in and we will add a USB connector and update the firmware on the board to the USB version. Let me know if that is the case.

Yes, Position PID is different from Velocity PID. With an absolute encoder with limited range you will probably only want to set the Position PID values. Zero the Velocity PID constants. Set the correct QPPS and set the Position PID values and save them to the board so you wont have to do it everytime you start your program.

When the manual says pulses it is talking about change in count. The manual is still more focused on quadrature encoders(which use pulses) but you can just read "pulses" as "encoder counts".

QPPS is the maximum change in the encoder position your motor could produce in 1 second at 100% power. If you have a limited range of movement you cant just run the motor at 100% duty and read the encoder speed. You will need to calculate the maximum speed(QPPS) either using the motor/gear ratio/encoder specs or by running the motor at some lower duty(10% for example) and multipling the resolting speed by the factor(eg 10 if running at 10%) to get a ballpark figure for the 100% speed of the system.

Yes, their are only three position commands(65,66 and 67). Each command has all the options available for a position movement in it so we didnt feel it would be usefull to have multiple subcommands.

If you look at the actual function in the arduino library it takes the argumetns you send as P, D, and I and sends them to the Roboclaw in the correct order(D,P,I). The manual is describing the actual packetserial command formats(which in the case of the SetPID commands is D,P,I) while the arduino library was written to not confuse people(everything is P,I,D order).
jonasb
Posts: 3
Joined: Sat Nov 21, 2015 9:33 pm
Re: Absolute position control

Post by jonasb »

Thanks much for that. Will help when I get into the code. Right now I can not even compile. I am getting a compiler error when I combine the keypad example for 4x4 keypad (it worked without roboclaw) and the roboclaw example for reading version. It won't allow the keypadeventhandler. I assume there is a conflict somewhere in roboclaw.h and the keypad libs because I did not add any of my own code yet. Any ideas on how to fix this?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Absolute position control

Post by Basicmicro Support »

The keypad lib probably uses the PCINT interrupt which the roboclaw library also uses which then causes a compiler error when both try to use it at the same time. But I would need to see your code to be sure. An error message would also help. Please provide the code and a link to the version of the keypad library if it isn't a standard lib.

Post Reply