Adding Step and Direction (CNC) Control to the Cheetah Motor

Robot Dog Motors

The proliferation of dog like robots has spawned a new generation of servo motors. These motors combine Brushless DC motors from the RC/Drone world with encoders, motor controllers and gearboxes in one small package. They are very compact, super strong and are in an easy to use package. Some of these are open source and are now being made cheaply in China.

I am interested in exploring the possible CNC uses of these motors. The appeal is the simplicity. You only need to run power and motion signals to them and one set of power wires can be daisy chained to the motors. With stepper motors, you need to run 4 heavy power wires to each motor. There are also potential EMI benefits because the stepper motors use long runs of fast switching high current.

To make them compatible with basic CNC machines you need to have step and direction signals, similar to what stepper drivers use. My initial goal was to add these inputs without changing anything to the physical motor. I will only touch the firmware.

Open Source FTW

Fortunately the motors I have are open source and the firmware is shared. While I only know the basics of Field Oriented Control (FOC), which is how these 3 phase brushless DC motors are controlled, the rest of the software is pretty easy to follow. The MCU is an STM32F446.

Existing I/O

There are 5 connectors on the controller board that are exposed through the side.

  • 24VDC In This is the primary motor power.
  • 5VDC in/out This can be used to power the board during programming. The 24VDC will create 5V on this if present.
  • CAN Interface
  • UART. This presents a menu that can be used to setup and calibrate the motor.
  • SWD. This is the programming interface.

I decided to use the UART connector. I would allow it to be optionally used as a UART for setup or for step and direction. I made an interface connection with some 1k resistors in line. This would save me if I screwed up. This would limit any current to a couple of milliamps. Any delays due to capacitance seem to be negligible. The UART still works fine at 921600 baud.

I can connect a UART to the input (left side) or a source of step and direction signals.

The RX and TX lines are changed to inputs. The step signal input will generate an interrupt. In the interrupt, the direction pin is check and the desired position is either incremented or decremented.

There is a defined constant called STEPS_PER_REV. This can be any reasonable value. The firmware works in radians, so that is converted to RADS_PER_STEP. Each step input alters the desired location by that amount.

Currently the CAN is also used to control the modes of the motor and it can also return the current motor position. That is a nice feature to allow a manual mode of a CNC machine and the motors will act as a DRO (Digital Read out) source. I plan to add a few extra can commands that allow the motor to default the proper modes at turn on.

My Test Rig

Here is a photo of my test rig. The motor needs a lot of weight to keep it from jumping around. Even with the weight of this 400 watt power supply it can do some serious jumps. I have the motor limited to 10A (40A is the max) to settle it down a little.

  • The ESP32 near the power plug is acting as a USB to CAN adapter. It goes through the skinny blue CAN PCB near the motor.
  • The red PCB is a 3.3V FTDI USB UART
  • The purple breadboard has the current limiting resistors.
  • The blue dongle in the middle is the programmer.
  • Not shown is another ESP32 running Grbl_ESP32 that generates step and direction signals. It plugs into the breadboard instead of the FTDI when in step/direction mode.

Next Steps

  • Right now there are two versions (by #define) of the firmware. One with the UART and one with the step and direction.
  • Do some accuracy testing
  • Release my firmware changes. It is a little messy right now and I am about to go on vacation, so I will probably wait about 2 weeks.
  • Build some sort of a machine with the motors. I might make a SCARA, so I only need 2 motors.

Documentation

I am been keeps a few docs up to date on all my findings.

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  1. No Comments

*