DISASTER: Controls - Upgrade Encoder


>>>Pi Wars 2020<<< 



1DISASTER: Control System

As part of the MVP development strategy, a closed loop PID control system was glued together to evaluate OrangeBot closed loop motor control capabilities.
All features that enable a control system were validated:
  • Quad Motor Driver
  • Quad PWM Controls
  • Quad Quadrature Encoder Acquisition
  • Bidirectional Status and Control messages
Quad current sensing capability is yet to be tested.
And yet, while it was possible to tune a quad speed PID to workable if not great performance, it was not possible to tune a stable position PID at all.




Video 1: Quad Position PID Unstable
Needless to say, raw PWM controls are not Pi-Wars worthy. This problem needs to be sorted out in order to achieve a Pi-Wars worthy robot.

1.1Architecture

The desired control system specifications are as follow:
  • Optimize aggressively for precision
  • PID Period: 1ms
  • Quad PWM Slew Rate Limiter (validated code)
  • Generic 16b PID class (code)
  • Quad Current PID
  • Quad Speed PID with two modes of operation
    • Position Ramp at low speed
    • Speed at high speed
  • Quad Position PID when near stop speed

1.2Problem

A through debugging, revealed that the source of the problem is quite simple. The control system is running too fast for the resolution of the encoder counters. This means the control system mostly sees zeros with some +1/-1 sprinkled in between.
Using lower gains, making the control softer, eliminates the instability at the cost of precision loss. The control systems allows large errors in this configuration.




Video 2: Low gain position PID
There is an array of possible solutions given the time to the competition:
  • Increase hardware encoder resolution
  • Interpolate encoder to increase software resolution
  • Reduce wheel diameter/Increase reducer ratio
  • Reduce the PID execution frequency
Given the development time available, the first solution is to improve the hardware. Software fixes will be deployed if hardware is still lacking. PID execution frequency will be relaxed as last resort as it increases latency.

2Replace Encoder

The current encoder achieves 3.6 counts per mm. We had an optical encoder laying around which has 250 pulses per turn of native resolution, we decided to replace the hall encoder with an optical one.

2.1Optical Encoder

The new encoder has a ~2.0mm hole, the motor has a ~2.2mm shaft. A 2.5mm drill was modified to enlarge the hole of the encoder disk.

Illustration 1: New Optical Encoder
A full upgrade and testing on the spare motor was done before upgrading two of OrangeBot main motors.

2.2Replace Encoders

Two main motors of OrangeBot were disassembled in preparation for the upgrade.
Illustration 2: Disassembly Two Motors

Remove Encoders and Reducer. The upgrade requires the naked DC motor.

Illustration 3: Disassembly Two Motors

Hole of the encoder disk was enlarged, and the disk was implanted on the encoder axis, taking care of installing the electronics before the disk.
Illustration 4: Install Encoder
Mount the reducer stage back on the motor and solder the wires. Electronics of the encoder is fixed via M2 screws and hot glue.

Illustration 5: Solder Wires

2.3Electronic Test

With the motors upgraded, an electrical test with an oscilloscope was conducted to test the encoder. Both direction, manual and 12V. Check that bot quadrature channels work along the full disk.

Illustration 6: Waveforms
One motors measured 33KHz frequency, the other 39KHz at 12V. This is due to differences in free running speed. By comparison, the previous encoder performed at about 750 Hz at 12V. The vastly increased encoder resolution was exactly what we were looking for.

3Conclusions

We were unable to increase the PID gains due to the low resolution of the encoders.
Replacing the hall encoder with a much more accurate variant should allow to vastly improve the tuning or the PID controllers.
Calibration of the PID will be moved to a dedicated remote control web browser page to ease the calibration.


No comments: