Closed-Loop Motor Controller for Gearmotors

Jake Wachlin designed a SAM D21-powered dual micro gearmotor controller with a CAN bus interface.

Cabe Atwell
4 years agoRobotics / Home Automation

Jake Wachlin is currently developing a custom solution for a dual closed-loop motor controller, specifically meant to work with micro gearmotors to avoid the jerkiness of servos and the open-loop position control of steppers. Additionally, a CAN interface is being added for robustness and scalability.

Two custom PCBs were created for the project. One is a main robot motor controller, and the other being the dual CAN motor controller. Both PCBs were fabricated at JLCPCB and designed using EasyEDA software. JLC provides solid PCBs for very low prices and also offer an assembly service for a range of components. Furthermore, EasyEDA integrates seamlessly with JLC’s services. For the circuits implemented, the main robot controller board created houses an ESP32 that can handle fairly complex algorithms with two cores running at 240MHz. In addition, the ESP has a built-in CAN controller. On the other hand, the dual CAN motor controller houses a Microchip SAM D21 along with an MCP2512 to support the CAN interface.

With the boards built and interfaces wired together, a semi-custom CAN interface was written. Generally, CAN communication will consist of frames that include an ID and data section. Wachlin chose to use 11-bit messages with the first bit being the message identifier, the next there bits being a message class identifier, the next three being messages indices, and the last four being device indices. Examples of the command classes are control, settings, and timing related commands.

More details on the project are outlined in Wachlin's logs. These include working with the PID controller, handling the continuous-time equations in discrete time, and much of the code written is posted as well. Furthermore, the efforts to implement inverse kinematics for positional tracking are also mentioned.

Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles