Motion Control
The Goal: Making robotics accessible to a wider audience
Two Teensies and a Raspberry Pi walk into a bar
No, no, wait, what do you get when you mix two Teensies and a Raspberry Pi? Well, in this case, a robot Motion Controller. Once you work out the mechanical engineering of a 6-axis long travel hexapod, you quickly realize it’s so efficient, the motion controller is going to cost more than the rest of the robot. To make a truly affordable truly useful robot, Apollo has to run on a $35 Raspberry Pi with Arduino compatible micro-controllers.
This week at oshRobot we’re tweaking the communication protocols between the Pi and Teensies
First, a little background. There’s really 3 pillars to a useful-affordable robot: 1 it’s got to use stepper motors, they’re affordable, and hi-torque, so no expensive low-backlash gear reduction required. 2 you’ve got to get the motors working together, not one carrying another, carrying another, etc. Put all your motors in one spot, and have them work together on the end effector in parallel. 3 an affordable yet capable motion control system to tell the motors what to do. Stepper motors exist, but numbers 2 and 3 needed some work. We’ll get into the mechanical engineering (2) later, for now lets focus on #3, motion control.
Building a robot is very much like building a team
you have to determine what each component is good at, and give each one what it needs to do what it does best. Raspberry Pi’s are great for the big picture, the large scale complex math, and user interfaces; however, when you need real-time data for your stepper motors, the Pi’s operating system can get in the way. Enter the Teensies. No need for an OS here, just load it with your favorite executable and bang, data when you need it. For brevity lets call this motion controller oshMotion. In oshMotion, the Pi handles the trajectory planning, path blending, and kinematics, the really complicated stuff.
*12us steps generated by the Teensy 3.2 (red line) and buffered to 5v by an op-amp
*Step and direction as seen by the stepper driver during motion testing
Once every millisecond the Pi calculates new position information
which of 32,000 possible positions each of the six primary arms should be in, passing that information along to the Teensy 4.0. The 4.0 keeps track of current position, calculates number of steps, in which direction, are needed to get to the new position, passes that info, how many steps, 0 to 60 (there is physical limitation of 60 steps in a millisecond for our stepper drivers), each motor should take, to the Teensy 3.2.
The 3.2 then distributes the steps using a pre-calculated digital differential analyzer algorithm over 250,000 possible options, so they happen evenly throughout the millisecond making a smooth movement instead of jerky stop start action, thereby avoiding mechanical vibration. The algorithm that distributes the steps runs presciently with the results for all possibilities stored in a multidimensional array on the Teensy 3.2 to reduce processing time. The Teensy 4.0 then reads the encoder info checking that the correct position has been reached. Making a correction if necessary. Next week we’ll get into the ins and outs of the encoders.