Used to communicate with the Maxon EPOS 24/2 motor controller using the ST Nucleo micro controller. Can be easily modified to work with other micro controllers as well. Only limited functionality (velocity mode and current reading).
maxonEPOS2 Class Reference
Class for communicating with Maxon EPOS 24/2 over the serial interface (and communicating with the PC via USB) More...
#include <maxonEPOS2.h>
Public Member Functions | |
| maxonEPOS2 (int serialID, int debugHigh, int debugLow) | |
| Create a maxonEPOS2 object, connected to the PC and the specified transmit and received pair. | |
| void | init () |
| Initialize the debugging serial port (PC) and motor controller serial port (EPOS) | |
| void | debug (const char *s) |
| Display a debug statement on the serial interface on PC. | |
| BufferedSerial | getSerialPC () |
| maxonEPOS2.cpp | |
| long | parseData () |
| Parse the received array to get the data. | |
Detailed Description
Class for communicating with Maxon EPOS 24/2 over the serial interface (and communicating with the PC via USB)
Can be used for transmitting and receiving for the following functions: Running on velocity mode Reading current
Example:
#include "mbed.h" #include "maxonEPOS2.h" #include "BufferedSerial.h" int main() { // Declare variables and serial interface BufferedSerial pc (USBTX, USBRX, 256, 4); int serialID = 2; unsigned char nodeID = 0x01; long motorSpeed = 8000; long receivedErrorCode = 0; long current = 0; maxonEPOS2 motor (serialID, 1, 0); motor.init(); motor.debug("Initialization done.\n"); // Start up the motor and set the velocity receivedErrorCode = motor.faultReset(nodeID); if (!receivedErrorCode) receivedErrorCode = motor.motorShutdown(nodeID); if (!receivedErrorCode) receivedErrorCode = motor.motorVelocityModeOn(nodeID); wait(1); if (!receivedErrorCode) receivedErrorCode = motor.motorSwitchOn(nodeID); wait(1); if (!receivedErrorCode) receivedErrorCode = motor.motorSetVelocity(nodeID, motorSpeed); wait(1); if (!receivedErrorCode) { // Measure the current 10 times for (int i = 0; i < 10; i++) { receivedErrorCode = motor.motorGetCurrent(nodeID); current = motor.parseData(); pc.printf("Current: %l\n", current); wait_ms(1000); } } // Shut down the motor and EPOS if (!receivedErrorCode) receivedErrorCode = motor.motorSetVelocity(nodeID, 0); if (!receivedErrorCode) receivedErrorCode = motor.motorShutdown(nodeID); if (receivedErrorCode) pc.printf ("Error code %d received.\n", receivedErrorCode); exit(0); }
Controllers for the Maxon EPOS 24/2 for the ST Nucleo
Definition at line 84 of file maxonEPOS2.h.
Constructor & Destructor Documentation
| maxonEPOS2 | ( | int | serialID, |
| int | debugHigh, | ||
| int | debugLow | ||
| ) |
Create a maxonEPOS2 object, connected to the PC and the specified transmit and received pair.
- Parameters:
-
serialID The TX/RX pin pair .Only works for the pairs Serial2, Serial3, Serial5 and Serial 7 (default). debugHigh 1 to enable high level debugging on PC via the USB port (0 to disable) debugLow 1 to enable low level debugging on PC via the USB port (0 to disable)
- Note:
- A serial interface to connect to the PC via the USB interface is automatically created.
Definition at line 106 of file maxonEPOS2.h.
Member Function Documentation
| void debug | ( | const char * | s ) |
Display a debug statement on the serial interface on PC.
- Parameters:
-
s The string to be sent through the PC serial port
Definition at line 204 of file maxonEPOS2.cpp.
| BufferedSerial getSerialPC | ( | ) |
Created on: Oct 5, 2016 Author: Nadun Wijesinghe
Definition at line 12 of file maxonEPOS2.cpp.
| void init | ( | ) |
Initialize the debugging serial port (PC) and motor controller serial port (EPOS)
- Note:
- The PC serial port is set for 9600 baud rate, EPOS2 serial port is set to 115200 baud rate.
- Both serial ports are set to use 8 bits, no parity bit and 1 stop bit
Definition at line 209 of file maxonEPOS2.cpp.
| long parseData | ( | ) |
Parse the received array to get the data.
- Returns:
- The number included in the 4 data bytes of the received message
- See also:
- Can be used with the motorGetCurrent() function
Definition at line 561 of file maxonEPOS2.cpp.
Generated on Tue Jul 26 2022 01:55:06 by
1.7.2