![]() |
RSeries astromech firmware
|
#include <RoboteQController.h>
Communicate with a Roboteq controller.
Public Types | |
enum | { kROBOTEQ_OK = 0, kROBOTEQ_TIMEOUT = -1, kROBOTEQ_ERROR = -2, kROBOTEQ_BAD_COMMAND = -3, kROBOTEQ_BAD_RESPONSE = -4, kROBOTEQ_BUFFER_OVER = -5, kROBOTEQ_FAULT_OVERHEAT = 0x01, kROBOTEQ_FAULT_OVERVOLTAGE = 0x02, kROBOTEQ_FAULT_UNDERVOLTAGE = 0x04, kROBOTEQ_FAULT_SHORT = 0x08, kROBOTEQ_FAULT_ESTOP = 0x10, kROBOTEQ_FAULT_SCRIPT = 0x20, kROBOTEQ_FAULT_MOSFET = 0x40, kROBOTEQ_FAULT_CONFIG = 0x80, kROBOTEQ_STATUS_SERIAL = 0x01, kROBOTEQ_STATUS_PULSE = 0x02, kROBOTEQ_STATUS_ANALOG = 0x04, kROBOTEQ_STATUS_POWER_OFF = 0x08, kROBOTEQ_STATUS_STALL = 0x10, kROBOTEQ_STATUS_LIMIT = 0x20, kROBOTEQ_SCRIPT_RUN = 0x80 } |
Public Member Functions | |
RoboteQController (Stream *serial) | |
Constructor. More... | |
int | isConnected (void) |
Check if controller is connected. More... | |
int | commandMotorPower (uint8_t ch, int16_t p) |
Send motor power command (!G) More... | |
int | commandEmergencyStop (void) |
Send emergency stop command (!EX) note: you have to reset the controller after this sending command. More... | |
int | queryFirmware (char *buf, size_t bufSize) |
Query controller firmware. More... | |
int | queryBatteryAmps (void) |
Query battery amps. More... | |
int | queryBatteryAmps (uint8_t ch) |
Query battery amps. More... | |
sprintf (command, "?BA %i\r", ch) | |
if ((res=this->sendQuery(command,(uint8_t *) buffer, kROBOTEQ_BUFFER_SIZE))< 0) return res | |
if (res< 4) return kROBOTEQ_BAD_RESPONSE | |
if (sscanf((char *) buffer, "BA=%i", &s)< 1) | |
int | queryBatteryVoltage (void) |
Query battery voltage. More... | |
int | queryMotorVoltage (void) |
Query motor voltage. More... | |
int | queryMotorPower (uint8_t ch) |
Query the motor power command. More... | |
int | queryFaultFlag (void) |
Query fault flags. More... | |
int | queryStatusFlag (void) |
Query status flags. More... | |
int | queryEncoderSpeed (uint8_t ch) |
Query encoder speed in RPM. More... | |
int | setEncoderPulsePerRotation (uint8_t ch, uint16_t ppr) |
Set encoder pulse per rotation. More... | |
int | setMotorAmpLimit (uint8_t ch, uint16_t a) |
Set motor amp limit. More... | |
int | loadConfiguration (void) |
Load controller configuration. More... | |
int | saveConfiguration (void) |
Save controller configuration. More... | |
void | setTimeout (uint16_t timeout) |
Set timeout. More... | |
Public Attributes | |
char | command [kROBOTEQ_COMMAND_BUFFER_SIZE] |
char | buffer [kROBOTEQ_BUFFER_SIZE] |
int | res |
return | amps |
anonymous enum |
|
inline |
Constructor.
|
inline |
Send emergency stop command (!EX) note: you have to reset the controller after this sending command.
|
inline |
Send motor power command (!G)
ch | channel |
p | power level (-1000, 1000) |
RoboteQController::if | ( | ) |
RoboteQController::if | ( | ) |
|
inline |
|
inline |
Check if controller is connected.
|
inline |
Load controller configuration.
int RoboteQController::queryBatteryAmps | ( | uint8_t | ch | ) |
Query battery amps.
ch | channel |
|
inline |
Query battery amps.
|
inline |
Query battery voltage.
|
inline |
Query encoder speed in RPM.
ch | channel |
|
inline |
Query fault flags.
|
inline |
Query controller firmware.
|
inline |
Query the motor power command.
ch | channel |
|
inline |
Query motor voltage.
|
inline |
Query status flags.
|
inline |
Save controller configuration.
|
inline |
Set encoder pulse per rotation.
ch | channel |
ppr | pulese per rotation |
|
inline |
Set motor amp limit.
ch | channel |
a | amps level (x10) |
|
inline |
Set timeout.
RoboteQController::sprintf | ( | command | , |
"?BA %i\r" | , | ||
ch | |||
) |
return RoboteQController::amps |
char RoboteQController::buffer[kROBOTEQ_BUFFER_SIZE] |
char RoboteQController::command[kROBOTEQ_COMMAND_BUFFER_SIZE] |
int RoboteQController::res |