Arduino library for controlling MD drives across multiple platforms: AVR(MCP2515), Renesas, and Teensy >4.0.
- Cross-platform support: AVR(MCP2515), Renesas, Teensy >4.0
- Creating MDs assigned to instance with unique IDs
- Managing internal registers of MDs
- Provides helper functions for managing MDs, for example: blink(), zero(), setTargetPosition()
- Open Arduino IDE
- Go to Sketch → Include Library → Manage Libraries…
- Search for
Candleduinoand click Install
- Download the library from GitHub
- Extract the folder into your Arduino
librariesfolder - Restart the Arduino IDE
mab::canId_t ID = 100; //ID of the MD drive
MD md(ID);
// MD md(ID, CS_PIN); for custom CS_PIN (Arduino AVR and MCP2515), default is 9
// FlexCAN_T4FD<CAN3, RX_SIZE_256, TX_SIZE_16> CANbus; //CANFD
//or
// FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> CANbus; //CAN2.0
// MD md(ID, &CANbus); for Teensy
md.init(); //initialize MD objectFor basic communication there are predefined commands like:
md.blink();
md.getMosfetTemperature(float &temperature);
md.setPositionPIDparam(float kp, float ki, float kd, float integralMax);
...For other registers it is recommended to use:
MD::Error_t MD::readRegister<T>(MD::Message<T> ®isterData)
MD::Error_t MD::writeRegister<T>(MD::Message<T> registerData)
MD::Error_t MD::readRegister<T>(uint16_t registerId, T ®isterData)
MD::Error_t MD::writeRegister<T>(uint16_t registerId, T registerData)Or CANFD only use readRegisters or writeRegisters for multiple data frame
MD::Error_t MD::readRegisters<T>(MD::Message<T> registerData, ...)
MD::Error_t MD::writeRegisters<T>(MD::Message<T> registerData, ...)For multiple MD drives user can create multiple MD object with unique ID's.
Example:
MD md1(100);
MD md2(120);Other registers can be found in CANdleduino documentation or in MD/Communication documentation section.