🞴 Engineering Index About Search

Linear Motor Control and Tuning


Linear motor post #2. Other linear motor posts

Electronic Components

I used an ODrive Robotics controller to drive the coils, and an RLC2HD encoder (a magnetic linear incremental encoder) from RLS. The encoder has a really high resolution (1 um), which may seem like overkill for most applications, but a simple stepper motor and leadscrew can reach close to the same precision (although accuracy depends on the leadscrew in that case). The encoder arrived in really nice packaging, as expected from a high quality industrial product:

The encoder read heads came in sealed bags to protect the component from moister and static.

The magnetic scales likewise came carefully wrapped around a piece of carboard tubing to prevent it from bending too much.

The encoder read head had really small soldering pads and mounting holes, so I designed a really simple PCB breakout board to connect the wires; the soldering pads were the castellated kind, so the encoder is essentially a surface mount component.

The encoder read head is less than 12mm in its longest dimension. It was shipped in a cute little padded box inside the dry bag.

The very simple breakout board I designed for the encoder so that I can more easily mount it to mechanical components. It just connects the pads on the encoder read head to the pins I can connect a wire to.

When I was assembling the breakout board, it was difficult to tell when the pads were soldered well enough, so it took a few iterations of soldering and testing before I got them working. It didn't help that I used really bad ribbon cable at first, which seemed to break at the slightest disturbance.

The magnetic scales that came with the encoders have a adhesive backing, so I made an aluminum mounting plate with a bunch of holes so I could flexibly mount it wherever I decided to put it. I added an adjustable mount for the encoder to the linear motor carriage and then mounted the magnetic scale within range of the adjustable encoder mount. The encoder needs fairly precisely aligned with the scale, so I placed a piece of paper between the encoder read head and the scale before fixing it in place onto the carriage.

The simple rigid backplate for the encoder scale to be mounted on. I drilled holes every 20mm for mounting purposes.

Control and Tuning

ODrive has pretty good documentation about configuring and tuning the controller on their website: ODrive Documentation. I first configured the ODrive to consider my motor to be a gimbal motor because it has a low inductance compared to an iron core motor. I also set other basic parameters, such as reasonable current and velocity limits, motor pole pairs, as the encoder CPR. For a linear motor, I considered one rotation to be the motor moving from one position to another over the same configuration of magnets (1 pole pair), which is 60mm and 60000 encoder increments in my motor. I also had to change the distance the motor moves during calibration (axis.encoder.config.calib_scan_distance) so that it didn't hit the endstops.

During the first few tests of the linear motor, I was having issues during the autocalibration process. Specifically, the encoder failed to calibrate because it didn't read the number of steps during the calibration phase. It took me a bit, but I eventually figured out that the calibration current (axis.motor.config.calibration_current) wasn't high enough to fully counteract the force of the cables on the motor. The issue went away after I increased the calibration current a bit.

The autocalibration would fail when the current was too low to follow the open loop control, causing the jerk at the beginning and causing the motor to disarm after scanning.

To tune the motor, I followed the guide in the ODrive documentation, but I didn't tune the motor to the limits of what was possible. During the tuning process, I increased the controller's vel_gain parameter too much, which resulted in fairly violent vibrations and I had to quickly pull the plug to the power supply. I eventually got it to be able to handle decently snappy moves, but there is still some overshoot, and I'm not confident that a fault won't be triggered during particularly dynamic moves. I got a few faults/errors during tuning that I couldn't exactly figure out why they were occurring, so a lot more testing would be required to figure those out and make the calibration more robust against them.

Once I fixed the autocalibration issues and did a little tuning, I got satisfying, snappy movements out of the motor.