Obviously having feedback for each of the linear actuators is a pretty big requirement (though not essential realistically for the leg lifting actuators), therefore a fair bit of through needs to go into this section. I was originally going to use flex sensors on the joints to measure the angle of each joint but after a bit more thought, it makes way more sense for me to use linear slide potentiometers instead!
As was said in the video, I bought some slide potentiometers that were advertised to have enough travel but it really wasn’t anywhere near the advertised amount (curse you cheap asian pots! …I’m joking, you’re all amazing) which was a little annoying as I had to wait the 3 weeks for those to arrive. Instead, I invested in a single 60mm travel slide pot to ensure it had ample range. Once I had tested the range, I purchased another 11 slide pots (actually 12 as they were different resistances). Fortunately, on each actuator, there is a slide pot sized flat spot which the slide pot seems to happily glue to. For the gluing, I’m only using super glue and should probably use epoxy for a better metal to metal bond but at the moment, that isn’t a large issue as super glue works just fine with the addition of me being able to remove it.
Bang bang control
Bang bang control is the simplest type of control that can be used for any device with feedback. It contains no linear control and controls the device by turn it on or off. The name apparently comes from mechanical systems that feature this controller as they make a “bang” noise as they switch between two defined states. A bang bang controller essentially has a set point with hysteresis about the set point that the system can lie in without further application of power. In this case, the set point is the desired position and the fedback signal is the actual position of the actuator. For a position of 100 and a hysteresis of 10 for example, the linear actuator could actually have a position of 95 to 105. These controllers are generally used in low performance applications where good responses aren’t required. While this controller would’ve probably sufficed with some feedback signal processing, I decided after 3 years of learning control that I should probably design a proper controller.
PID controllers are found in many applications, predominantly industrial control applications. Like a PI controller, they can be used for a multitude of systems with correct tuning and can give quite a good response. In this system, the control variable was the motor voltage (and in relation to that, the current). Application of motor current provided change in position in the output which was fedback to the controller using the linear slide potentiometer. However because of the type of system being controlled, I decided that I didn’t need any integral component. An integrator is generally used to eliminate steady state error but in this case, the linear actuator consists of a worm gear mechanism to produce linear motion. This in itself is a form of integrator as it “accumulates” motor rotations meaning if power is applied to the motor and removed, the worm gear mechanism doesn’t return to the original position. It could be seen that including any form of integrator term produced massive overshoot, slow rise times and if enough gain was added, oscillations. This is due to the controller and system poles and which controller can be used for what system dependent on the system type (I’ll be honest, I don’t 100% remember the system type/controller relation).
Because of this lack of integral control, I’m actually merely using a PD controller. I tuned the controller by increasing the proportional gain until the system oscillated to a disturbance (introduced by putting a pulldown resistor on the potentiometer analogue input “simulating” output movement), at this point, I increased the derivative gain until oscillations ceased. At this point, I decreased the proportional and derivative gains until the system showed good response with minimal overshoot. This tuning methodology is similar to this one shown on Stack Overflow. This resulted in a pretty good controller for the system with small steady state error.
There was however an issue with the motor “jitter” (I’m not sure what the real term is) where small drive duty cycles would cause the motor to hum but not actually move as the power wasn’t quite enough. While this isn’t a massive issue for large hefty motors, the motors on these actuators are designed for a duty cycle of 20%. I therefore decided that it isn’t worth the constant power draw/motor wear and added a non-linear hysteresis control element. Because the controller would get the position to within 2 counts of the demanded position, the hysteresis only had to be small (much smaller than for a bang bang controller) meaning the position wasn’t massively affected by this hysteresis. This stopped the motor jittering for small errors and hopefully will prolong the life at the slight disadvantage of minimally increased steady state error. This final controller is a bit of a mix of the two.
It is also worth noting that the PWM was implemented in software as opposed to hardware as I won’t be able to implement hardware PWM on the real thing. The PWM used was 5 bit at 125Hz (PWM loop frequency of 4kHz). The controller was synchronous to the PWM frequency and also ran at 125Hz. In the hardware side, a 100nF capacitor was placed on the potentiometer output to ground. This has the disadvantage of a position dependent pole but this didn’t cause any major issues. A 1 pole software LPF was also implemented on the feedback signal to further smooth out noise though this had a reasonably high cutoff frequency. Position was encoded using a 10bit variable allowing 1024 steps of precision. Theoretically, the ADC is taking 12bit measurements but since the full potentiometer range isn’t covered, the theoretical range is somewhere near 11.5bits. this 10bit positional precision seems fine for this application.
Keep tuned (ayyy) for more posts!