CANDrive is a brushed DC Motor Controller controlled via a CAN interface.
- Velocity control
- Torque control
- CAN interface
- Firmware updates over CAN
- Emergency stop
- 5 A output current
- 12-24 V supply voltage
This project is hosted on GitHub. You can clone this project directly using this command:
git clone --recurse-submodules https://github.com/Andreasdahlberg/CANDrive.git
scons build-opencm
scons build
Run all tests with valgrind:
scons test
Run a single test suite:
scons app/motor/test && build/motor/test/TestRunner
Run a single unit test:
scons app/motor/test && build/motor/test/TestRunner test_Motor_SetSpeed
The monitor tool is a serial terminal which parses serial output from the device and formats the output to make it easier to read. It also incorporates a simple command line used for debug commands and device configuration. The debug commands are not intended for controlling the motors during normal operation since they bypass several of the safety features.
- Host timestamps
- Color coded debug levels
- Translation from addresses to file and line
- Command line
- Filtering[Not implemented]
The monitor is started by typing scons monitor. Serial port and baudrate can be configured here or on the command line, e.g. scons monitor SERIAL_PORT=/dev/ttyACM0 BAUD_RATE=921600
The serial port used by the monitor is available at JP1 and is disabled by default. It can be enabled by moving jumper J1.
rpm [MOTOR_INDEX] [RPM]
Ex.
CANDrive> rpm 0 50
current [MOTOR_INDEX] [CURRENT]
Ex.
CANDrive> current 1 1500
run [MOTOR_INDEX]
Ex.
CANDrive> run 0
coast [MOTOR_INDEX]
Ex.
CANDrive> coast 0
brake [MOTOR_INDEX]
Ex.
CANDrive> brake 0
reset
Ex.
CANDrive> reset
level [MODULE] [LEVEL]
Ex.
CANDrive> level App 10
store [PARAMETER] [VALUE]
Ex.
CANDrive> store number_of_motors 1