Firmware Motion Control Case Study
For this project, the client needed help with the development of an embedded controller for a wearable electronic device. The device is controlled by a small form factor permanent magnet brushed DC motor and operates from a single battery cell. The controller needed to fit within a small size appropriate for a wearable device and needed to include a motor to drive a gear mechanism connected to a variable load. The product also required the load to be moved at varied speeds while being able to stop at a desired position. These requirements as well as many others dictated the use of a small and power efficient microcontroller for the system and motion control firmware. This project presented itself with many challenges in order to meet the system requirements. Some of these challenges and solutions are presented below.
Challenges and SOLUTIONS
The project’s small form factor challenged us with controlling the motor speed as well as providing good transient response to rapid changes in loading. This was challenging because the small space available limited the size and resolution of the motor shaft position encoder. The limited encoder resolution combined with the limited processing capability of the microcontroller required deviating from the typical feedback control scheme.
The motor control firmware operated as a task in a real time operating system. To prevent the motor control task from consuming too much of the microcontrollers processing time and preventing other tasks in the system from operating correctly, we decided not to add additional high frequency interrupts for the motor control task. This meant the motor control task could run according to the timing determined by the operating system scheduler. While the timing of the task scheduler was fairly accurate, it suffered from approximately 10% jitter. Using the typical method of (Δ distance/ Δ time) to calculate velocity would result in a 10% velocity error which was greater than the allowable velocity error. The solution to this problem was to use a different method for determining motor velocity. By utilizing timer hardware within the microcontroller, the period of the encoder pulses could be measured with a higher accuracy time base. Motor velocity was then determined from the period of the encoder pulses.
Another challenge was the small battery in conjunction with the system torque requirements. In order to meet the system torque requirements with the small form factor motor, strong magnets were used in the motor construction. This meant that starting the motor required roughly 40% of available battery voltage just to overcome the detent torque. Additionally, there existed a competing constraint to limit velocity overshoot and to keep motor starting current below the specifications of the small battery cell.
The startup and control of the motor was accomplished by tuning of a Proportional-Integral-Derivative (PID) control algorithm using the encoder pulse period as the feedback variable. By balancing the trade-offs of startup current, velocity overshoot, transient response and stability, the gains for the PID terms were chosen to meet the application requirements. To facilitate testing and tuning, the gain terms were adjustable by testers and developers without the need to recompile the software.
To address this challenge, two tools were developed: a Velocity Profile Creation tool and a Profile Measurement tool. These tools enabled the client to create and edit the profiles as well as measure the system’s ability to track the profile. Both tools were created using the Python programming language which allowed rapid development of the tools as well as multi-platform compatibility. The Velocity Profile Creation tool allowed testers and developers to visually create a velocity profile and download the profile to the system for use. The Profile Measurement tool connected to the system to download motion data which could then be displayed visually for the tester to evaluate.
The last challenge was the client's need to customize the motion profiles to optimize the product. This required developing a method and tools for creating, editing and downloading motion velocity profiles for motor moves. The motion control firmware needed to fulfill following the custom profile and be able to scale the profile to match any move distance.
Velocity Profile Creation tool
Profile Measurement Tool
Firmware Engineering Services:
- Embedded real time operating system
- Motion control
- Firmware PID control algorithm
- Python programming
- Embedded microcontroller application development
Mechanical Engineering Services:
- Motor characterization and specification
- Mechanical Testing