Hey, Im currently building a 6 axis robot arm, and i use some heavily geared Steppermotors wich offer a lot of torque(more than enough) still, i need to control them in a PID manner and I was thinking if there is maybe a suitable approach.
My differential Kinematics algorithm outputs motor speeds and positions with 4kHz and i need my stepper motors to follow these commands as good as possible. those commands aren't linear or anything, so i can't use Accelstep library or teensyStep (just if u thought).
i don't think my steppers would lose steps, but as i use Euler integration to derive the joint positions, there might be some error in the velocity/position relation, that may accumulate over time.
what may be the best approach to get my steppers to run in a performing way?
Im just curious what u guys might come up with.
and just talking about actual algorithms. coding those won't be a huge problem(i hope)
also: what's the upper boundary for uart communication? i need to send 6 joint velocities, and 6 positions in realtime, as fast as possible.
thanks for ur help, and Greetings from Aachen Germany!
The upper boundary for the UART is in the megabaud range. Maybe 2 or 5 megas. Remember it takes 10 bit transitions(baud) to send one byte. Calculate how many bytes you need to send in one second to send the data required. It is unlikely that you will need more than 115200 baud.
I am unclear on the commands being sent for the motors to execute. Do you get a destination in degrees or steps and a time required to get to that destination? If you don't, could you transform the data into that kind of concept?
Ok nice.
I thought I’d send them the desired speed they should have, and also the desired position. First of all the speed is set. There’s an ISR that gets called at dT (every 100 microsec or smth) and if the motors dt to make a step is smaller than the elapsed time they’ll do a step.
With only the speed set, the motors may drift from the desired position, that’s where I need the PID correction I guess, to alter the speed if needed.
That’s what I came up with so far, but I don’t know if it’s the most robust algorithm
Could you make your PC program produce both the number of steps and the speed (or interval between steps) for a single movement and then send that data to the Arduino? When the Arduino has finished implementing the move it can ask for the next data. Actually, it could ask for the data for move 23 before it starts move 22 and then when move 22 is finished the data for move 23 will have arrived and it just needs to request data for move 24.
That sort of system should avoid any position errors - assuming the motors do not miss steps.
The problem is the moves are never linear so a single move would be like 3 steps maybe.
I’ve thought about that as well but that would mean I’d have to discretize the movement into linear segments and I don’t wanna do that because that would mean I’d lose tooltip trajectory precision.
Also as the initial movement is timescaled, what results in nice acceleration and jerk behavior of the motors, I’d lose that with discretization as well
A CNC robot? Then you should be using g code. You are using the inverse kinematics to turn g code moves into stepper positions?
While there are advanced g codes for curves, most g code producers only use simpler linear segments. Some 3D printers will turn that back into smooth curves.
RWTH_MASCHI:
Ok nice.
I thought I’d send them the desired speed they should have, and also the desired position. First of all the speed is set. There’s an ISR that gets called at dT (every 100 microsec or smth) and if the motors dt to make a step is smaller than the elapsed time they’ll do a step.
With only the speed set, the motors may drift from the desired position, that’s where I need the PID correction I guess, to alter the speed if needed.
You simply need to keep a count of the position in steps and have your ISR work in position. So long as it
runs frequently enough the velocity takes care of itself.