Command library for the Roboteq SDC21XX serie of DC Motor drivers, using CANopen Interface. This library replicates the CANopen commands detailled in the User's Manual for the SDC21XX Serie, Section 14 CANopen Interface. Please refer to this document for more details about the use of any of the commands.

Dependents:   SDC21XX_Motor

Fork of Roboteq_SDC_serie by Pierre David

Committer:
kkoichy
Date:
Mon Jul 11 10:33:59 2016 +0000
Revision:
7:9a17b688dd59
Parent:
6:bd10b47f59d2
Added comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kkoichy 7:9a17b688dd59 1
kkoichy 7:9a17b688dd59 2 /**************************************************/
kkoichy 7:9a17b688dd59 3 /* Roboteq class : inherits from CANopen_node
kkoichy 7:9a17b688dd59 4 - Contains : node-id, identifier of the node to communicate with, range from 1 to 127
kkoichy 7:9a17b688dd59 5 can, pointer to the CAN instance used to communicate with the node
kkoichy 7:9a17b688dd59 6
kkoichy 7:9a17b688dd59 7 - Methods : 2 constructors, 1 of them setting the frequency of the CAN bus
kkoichy 7:9a17b688dd59 8 Getters and setters for every variable
kkoichy 7:9a17b688dd59 9 Send SDO up- and download, to send and receive basic messages over CANopen protocol
kkoichy 7:9a17b688dd59 10 Every commands detailled in the SDC21XX serie documentation under the title Object Dictionnary
kkoichy 7:9a17b688dd59 11 A SetParameters method, allowing to set acceleration, deceleration and velocity for one of the two channels of the motor controller
kkoichy 7:9a17b688dd59 12 */
kkoichy 7:9a17b688dd59 13 /**************************************************/
kkoichy 7:9a17b688dd59 14
kkoichy 7:9a17b688dd59 15 /**************************************************/
kkoichy 7:9a17b688dd59 16 /* Example programm
kkoichy 6:bd10b47f59d2 17 Two motors are connected to 2 SDC21XX controllers, both on channel 1.
kkoichy 6:bd10b47f59d2 18 When pressing the user button, 2 CANopen frames are sent, setting the motors to go to the position referred to as +/- 1000
kkoichy 6:bd10b47f59d2 19 #include "mbed.h"
kkoichy 6:bd10b47f59d2 20 #include "Roboteq.h"
kkoichy 6:bd10b47f59d2 21
kkoichy 7:9a17b688dd59 22 InterruptIn Button(p28);
kkoichy 6:bd10b47f59d2 23 Serial pc(USBTX,USBRX);
kkoichy 7:9a17b688dd59 24 CAN can(p30, p29);
kkoichy 6:bd10b47f59d2 25 Roboteq Robot_Moteur1(4, &Can);
kkoichy 6:bd10b47f59d2 26 Roboteq Robot_Moteur2(5, &Can);
kkoichy 6:bd10b47f59d2 27 int i = 0, j = 1;
kkoichy 6:bd10b47f59d2 28
kkoichy 6:bd10b47f59d2 29 void send(void)
kkoichy 6:bd10b47f59d2 30 {
kkoichy 6:bd10b47f59d2 31 pc.printf("1");
kkoichy 6:bd10b47f59d2 32 Robot_Moteur1.SetPosition(j * 1000, 1);
kkoichy 6:bd10b47f59d2 33 Robot_Moteur2.SetPosition(-j * 1000, 1);
kkoichy 6:bd10b47f59d2 34 j = -j;
kkoichy 6:bd10b47f59d2 35
kkoichy 6:bd10b47f59d2 36 }
kkoichy 6:bd10b47f59d2 37
kkoichy 6:bd10b47f59d2 38 int main() {
kkoichy 6:bd10b47f59d2 39 Can.frequency(250000);
kkoichy 6:bd10b47f59d2 40 pc.baud(115200);
kkoichy 6:bd10b47f59d2 41 pc.printf("\n\rdebut prog");
kkoichy 6:bd10b47f59d2 42
kkoichy 6:bd10b47f59d2 43 Button.fall(&send);
kkoichy 6:bd10b47f59d2 44
kkoichy 6:bd10b47f59d2 45 while(1) {
kkoichy 6:bd10b47f59d2 46
kkoichy 6:bd10b47f59d2 47
kkoichy 6:bd10b47f59d2 48 }
kkoichy 6:bd10b47f59d2 49 }
kkoichy 6:bd10b47f59d2 50 */
kkoichy 6:bd10b47f59d2 51
kkoichy 6:bd10b47f59d2 52
kkoichy 6:bd10b47f59d2 53
kkoichy 6:bd10b47f59d2 54
kkoichy 6:bd10b47f59d2 55
kkoichy 6:bd10b47f59d2 56
kkoichy 6:bd10b47f59d2 57
kkoichy 6:bd10b47f59d2 58
kkoichy 0:783afa2e2461 59 #ifndef ROBOTEQ_H
kkoichy 0:783afa2e2461 60 #define ROBOTEQ_H
kkoichy 0:783afa2e2461 61
kkoichy 4:2e3f45b81f23 62 #include "CANopen_Node.h"
kkoichy 0:783afa2e2461 63
kkoichy 0:783afa2e2461 64
kkoichy 0:783afa2e2461 65 namespace mbed {
kkoichy 0:783afa2e2461 66
kkoichy 3:53d26a675eb3 67 class Roboteq : public CANopen_Node{
kkoichy 0:783afa2e2461 68
kkoichy 0:783afa2e2461 69 public :
kkoichy 3:53d26a675eb3 70 Roboteq(uint8_t _node_id, CAN * _can);
kkoichy 3:53d26a675eb3 71 void SetParameters(int16_t _velocity, long _accel, long _decel, uint8_t _channel);
kkoichy 0:783afa2e2461 72 void SetPosition(long _position, uint8_t _channel);
kkoichy 0:783afa2e2461 73 void SetVelocity(uint16_t _speed, uint8_t _channel);
kkoichy 0:783afa2e2461 74 void SetEncoderCounter(long _counter, uint8_t _channel);
kkoichy 0:783afa2e2461 75 void SetBrushlessCounter(long _counter, uint8_t _channel);
kkoichy 0:783afa2e2461 76 void SetUserIntVariable(long _var, uint8_t _nb_var);
kkoichy 0:783afa2e2461 77 void SetAcceleration(long _accel, uint8_t _channel);
kkoichy 0:783afa2e2461 78 void SetDeceleration(long _decel, uint8_t _channel);
kkoichy 0:783afa2e2461 79 void SetAllDigitalOutBits(uint8_t _out_bits);
kkoichy 0:783afa2e2461 80 void SetIndividualDigitalOutBits(uint8_t _out_bits);
kkoichy 0:783afa2e2461 81 void ResetIndividualOutBits(uint8_t _out_bits);
kkoichy 0:783afa2e2461 82 void LoadHomeCounter(uint8_t _channel);
kkoichy 0:783afa2e2461 83 void EmergencyShutdown(uint8_t _param);
kkoichy 0:783afa2e2461 84 void ReleaseShutdown(uint8_t _param);
kkoichy 0:783afa2e2461 85 void StopInAllModes(uint8_t _channel);
kkoichy 0:783afa2e2461 86 void SetPosRelative(long _position, uint8_t _channel);
kkoichy 0:783afa2e2461 87 void SetNextPosAbsolute(long _position, uint8_t _channel);
kkoichy 0:783afa2e2461 88 void SetNextPosRelative(long _position, uint8_t _channel);
kkoichy 0:783afa2e2461 89 void SetNextAcceleration(long _accel, uint8_t _channel);
kkoichy 0:783afa2e2461 90 void SetNextDeceleration(long _decel, uint8_t _channel);
kkoichy 0:783afa2e2461 91 void SetNextVelocity(uint16_t _speed, uint8_t _channel);
kkoichy 0:783afa2e2461 92 void SetUserBoolVariable(long _var, uint8_t _nb_var);
kkoichy 0:783afa2e2461 93 void SaveConfigToFlash(void);
kkoichy 0:783afa2e2461 94
kkoichy 0:783afa2e2461 95 int16_t ReadMotorAmps(uint8_t _channel);
kkoichy 0:783afa2e2461 96 int16_t ReadActualMotorCommand(uint8_t _channel);
kkoichy 0:783afa2e2461 97 int16_t ReadAppliedPowerLevel(uint8_t _channel);
kkoichy 0:783afa2e2461 98 int16_t ReadEncoderMotorSpeed(uint8_t _channel);
kkoichy 0:783afa2e2461 99 int16_t ReadAbsoluteEncoderCount(uint8_t _channel);
kkoichy 0:783afa2e2461 100 int16_t ReadAbsoluteBrushlessCounter(uint8_t _channel);
kkoichy 0:783afa2e2461 101 int16_t ReadUserIntegerVariable(uint8_t _nb_var);
kkoichy 0:783afa2e2461 102 int16_t ReadEncoderMotorSpeedRelativeToMaxSpeed(uint8_t _channel);
kkoichy 0:783afa2e2461 103 int16_t ReadEncoderCountRelative(uint8_t _channel);
kkoichy 0:783afa2e2461 104 int16_t ReadBrushlessCountRelative(uint8_t _channel);
kkoichy 0:783afa2e2461 105 int16_t ReadBrushlessMotorSpeed(uint8_t _channel);
kkoichy 0:783afa2e2461 106 int16_t ReadBrushlessMotorSpeedRelativeToMaxSpeed(uint8_t _channel);
kkoichy 0:783afa2e2461 107 int16_t ReadBatteryAmps(uint8_t _channel);
kkoichy 0:783afa2e2461 108 uint16_t ReadInternalVoltages(uint8_t _param);
kkoichy 0:783afa2e2461 109 uint32_t ReadAllDigitalInputs(void);
kkoichy 0:783afa2e2461 110 int8_t ReadCaseAndInternalTemperatures(uint8_t _param);
kkoichy 0:783afa2e2461 111 int16_t ReadFeedback(uint8_t _channel);
kkoichy 0:783afa2e2461 112 uint8_t ReadStatusFlags(void);
kkoichy 0:783afa2e2461 113 uint8_t ReadFaultFlags(void);
kkoichy 0:783afa2e2461 114 uint8_t ReadCurrentDigitalOutputs(void);
kkoichy 0:783afa2e2461 115 int32_t ReadClosedLoopError(uint8_t _channel);
kkoichy 0:783afa2e2461 116 int32_t ReadUserBooleanVariable(uint8_t _nb_var);
kkoichy 0:783afa2e2461 117 int32_t ReadInternalSerialCommand(uint8_t _channel);
kkoichy 0:783afa2e2461 118 int32_t ReadInternalAnalogCommand(uint8_t _channel);
kkoichy 0:783afa2e2461 119 int32_t ReadInternalPulseCommand(uint8_t _channel);
kkoichy 0:783afa2e2461 120 uint32_t ReadTime(void);
kkoichy 0:783afa2e2461 121 uint16_t ReadSpektrumRadioCapture(uint8_t _nb_capture);
kkoichy 0:783afa2e2461 122 uint8_t ReadDestinationPositionReachedFlag(uint8_t _channel);
kkoichy 0:783afa2e2461 123 int32_t ReadMEMSAccelerometerAxis(uint8_t _axis);
kkoichy 0:783afa2e2461 124 uint16_t ReadMagsensorTrackDetect(void);
kkoichy 0:783afa2e2461 125 uint8_t ReadMagsensorTrackPosition(void);
kkoichy 0:783afa2e2461 126 uint8_t ReadMagsensorMarkers(void);
kkoichy 0:783afa2e2461 127 uint8_t ReadMagsensorStatus(void);
kkoichy 0:783afa2e2461 128 uint8_t ReadMotorStatusFlags(void);
kkoichy 0:783afa2e2461 129 int32_t ReadIndividualDigitalInputs(uint8_t _input);
kkoichy 0:783afa2e2461 130 int16_t ReadAnalogInputs(uint8_t _input);
kkoichy 0:783afa2e2461 131 int16_t ReadAnalogInputsConverted(uint8_t _input);
kkoichy 0:783afa2e2461 132 int16_t ReadPulseInputs(uint8_t _input);
kkoichy 0:783afa2e2461 133 int16_t ReadPulseInputsConverted(uint8_t _input);
kkoichy 0:783afa2e2461 134
kkoichy 0:783afa2e2461 135
kkoichy 0:783afa2e2461 136
kkoichy 0:783afa2e2461 137
kkoichy 0:783afa2e2461 138
kkoichy 0:783afa2e2461 139
kkoichy 0:783afa2e2461 140
kkoichy 0:783afa2e2461 141 private :
kkoichy 0:783afa2e2461 142
kkoichy 0:783afa2e2461 143
kkoichy 0:783afa2e2461 144 protected :
kkoichy 0:783afa2e2461 145
kkoichy 0:783afa2e2461 146
kkoichy 0:783afa2e2461 147
kkoichy 0:783afa2e2461 148 };
kkoichy 0:783afa2e2461 149
kkoichy 0:783afa2e2461 150
kkoichy 0:783afa2e2461 151 }//end namespace
kkoichy 0:783afa2e2461 152
kkoichy 0:783afa2e2461 153
kkoichy 0:783afa2e2461 154 #endif