top of page

Motor Control

In order to create a functional 3D printer we knew that designing a motor control system, building the hardware, and writing the software was going to be a critical piece. The system had to be well designed and repeatable because we had 4 motors within the IFFF that would all rely on this motor control system. We decided to spend the early stages of development focusing on writing code and selecting hardware that would enable us to have control of the motors as early in the development process as possible, so that later on we could have faith in our motor control system and focus on other unit and integration aspects of the printer, such as expanding to the end goal of 4 independent motor control systems.

Hardware Overview

The main component in our Motor Driver PCB was a TI DRV888 Motor Driver. It uses a combination of GPIO inputs to determine what step size it should be increment at, how much power to give the motors, and when to increment. After making 1 version of our motor control PBC, we learned many lessons about how to interface with the device and ensure we were supplying the device with the correct voltages at each pin. By the time our second board was fabricated, we were confident that we had a motor control PCB that was fully configurable and controllable through software.

Software Overview

The other consideration our team had to make when designing our motor control system was how to interface with the motor driver through code. Fortunatley, we had thought about this from the hardware selection stage, so the MCU we decided to use made it relatively easy to interface with our hardware. Most notably, our MCU had a designated PWM peripheral that was advertised as 'very high precision'. We became familiar with this peripheral early on, and began implementing the driver functionality with this PWM output signal and a collection of other GPIO signals that the DRV888 needed.

How it Works

The general flow of the motor control algorithm run as follows:

  1. Each motor’s required motion is decoded from the current GCODE instruction

  2. Each motor thread calculates the number of microsteps needed to reach their final destination

  3. Each motor thread enables the motor driver and begins a PWM module, generating one pulse for each required microstep 

 

We determined the precision we can expect/achieve through the following derivation:

 

Rotate the motor one full rotation and measure the translation of the extruder nozzle.  The theoretical precision of the motor per microstep is then defined:

40.6 (mm)rotation*1 rotation200 steps*1 step16 microsteps=0.01 (mm)1 microstep

 

Using this ratio, we can determine the amount of steps needed in order to move the motor a specified distance by counting the rising edges of the PWM generator.  Our motor control systems are edge triggered, so each rising edge of the PWM corresponds to a translation of exactly one microstep in the motor.  We chose PWM as our method of initiating a step on our stepper motors since we can set a frequency and duty cycle and not worry about scheduling in rising edges and the timing difficulties that would entail using GPIO pin toggling. PWM also makes sense for this application since it will allow for consistent movement of the extruder head which means a consistent application of the PLA material. We are able to trigger interrupts when each motor has reached its target distance travelled. Once all motors have reached their target distances and have been disabled, we can read and begin the next GCODE instruction. Using the RTOS scheduler, we can schedule in or enable a periodic task to fetch a new instruction and add it to the instruction queue. 

drv8886_breakout_screenshot_10_29.PNG
bottom of page