RSeries astromech firmware
RoboteQController Class Reference

#include <RoboteQController.h>

Detailed Description

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", &amps)< 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
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kROBOTEQ_OK 
kROBOTEQ_TIMEOUT 
kROBOTEQ_ERROR 
kROBOTEQ_BAD_COMMAND 
kROBOTEQ_BAD_RESPONSE 
kROBOTEQ_BUFFER_OVER 
kROBOTEQ_FAULT_OVERHEAT 
kROBOTEQ_FAULT_OVERVOLTAGE 
kROBOTEQ_FAULT_UNDERVOLTAGE 
kROBOTEQ_FAULT_SHORT 
kROBOTEQ_FAULT_ESTOP 
kROBOTEQ_FAULT_SCRIPT 
kROBOTEQ_FAULT_MOSFET 
kROBOTEQ_FAULT_CONFIG 
kROBOTEQ_STATUS_SERIAL 
kROBOTEQ_STATUS_PULSE 
kROBOTEQ_STATUS_ANALOG 
kROBOTEQ_STATUS_POWER_OFF 
kROBOTEQ_STATUS_STALL 
kROBOTEQ_STATUS_LIMIT 
kROBOTEQ_SCRIPT_RUN 

Constructor & Destructor Documentation

◆ RoboteQController()

RoboteQController::RoboteQController ( Stream *  serial)
inline

Constructor.

Member Function Documentation

◆ commandEmergencyStop()

int RoboteQController::commandEmergencyStop ( void  )
inline

Send emergency stop command (!EX) note: you have to reset the controller after this sending command.

Returns
kROBOTEQ_OK if successful

◆ commandMotorPower()

int RoboteQController::commandMotorPower ( uint8_t  ch,
int16_t  p 
)
inline

Send motor power command (!G)

Parameters
chchannel
ppower level (-1000, 1000)
Returns
kROBOTEQ_OK if successful

◆ if() [1/3]

RoboteQController::if ( )

◆ if() [2/3]

RoboteQController::if ( )

◆ if() [3/3]

RoboteQController::if ( )
inline

◆ isConnected()

int RoboteQController::isConnected ( void  )
inline

Check if controller is connected.

Returns
kROBOTEQ_OK if connected

◆ loadConfiguration()

int RoboteQController::loadConfiguration ( void  )
inline

Load controller configuration.

Returns
kROBOTEQ_OK if successful

◆ queryBatteryAmps() [1/2]

int RoboteQController::queryBatteryAmps ( uint8_t  ch)

Query battery amps.

Parameters
chchannel
Returns
battery amps * 10

◆ queryBatteryAmps() [2/2]

int RoboteQController::queryBatteryAmps ( void  )
inline

Query battery amps.

Returns
battery amps * 10

◆ queryBatteryVoltage()

int RoboteQController::queryBatteryVoltage ( void  )
inline

Query battery voltage.

Returns
battery voltage * 10

◆ queryEncoderSpeed()

int RoboteQController::queryEncoderSpeed ( uint8_t  ch)
inline

Query encoder speed in RPM.

Parameters
chchannel
Returns
rpm

◆ queryFaultFlag()

int RoboteQController::queryFaultFlag ( void  )
inline

Query fault flags.

◆ queryFirmware()

int RoboteQController::queryFirmware ( char *  buf,
size_t  bufSize 
)
inline

Query controller firmware.

Returns
kROBOTEQ_OK if successful

◆ queryMotorPower()

int RoboteQController::queryMotorPower ( uint8_t  ch)
inline

Query the motor power command.

Parameters
chchannel
Returns
motor power

◆ queryMotorVoltage()

int RoboteQController::queryMotorVoltage ( void  )
inline

Query motor voltage.

Returns
motor voltage * 10

◆ queryStatusFlag()

int RoboteQController::queryStatusFlag ( void  )
inline

Query status flags.

◆ saveConfiguration()

int RoboteQController::saveConfiguration ( void  )
inline

Save controller configuration.

Returns
kROBOTEQ_OK if successful

◆ setEncoderPulsePerRotation()

int RoboteQController::setEncoderPulsePerRotation ( uint8_t  ch,
uint16_t  ppr 
)
inline

Set encoder pulse per rotation.

Parameters
chchannel
pprpulese per rotation
Returns
kROBOTEQ_OK if successful

◆ setMotorAmpLimit()

int RoboteQController::setMotorAmpLimit ( uint8_t  ch,
uint16_t  a 
)
inline

Set motor amp limit.

Parameters
chchannel
aamps level (x10)
Returns
kROBOTEQ_OK if successful

◆ setTimeout()

void RoboteQController::setTimeout ( uint16_t  timeout)
inline

Set timeout.

◆ sprintf()

RoboteQController::sprintf ( command  ,
"?BA %i\r"  ,
ch   
)

Member Data Documentation

◆ amps

return RoboteQController::amps

◆ buffer

char RoboteQController::buffer[kROBOTEQ_BUFFER_SIZE]

◆ command

char RoboteQController::command[kROBOTEQ_COMMAND_BUFFER_SIZE]
Initial value:
{
int amps

◆ res

int RoboteQController::res

The documentation for this class was generated from the following file:
RoboteQController::amps
return amps
Definition: RoboteQController.h:200