Pierre David / Roboteq_SDC_serie

Dependents:   SDC21XX_Motor SDC21XX_Motor

Committer:
kkoichy
Date:
Thu Jun 16 12:30:29 2016 +0000
Revision:
6:bd10b47f59d2
Parent:
4:53d26a675eb3
Added an example program in the .h file

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kkoichy 0:783afa2e2461 1 #include "Roboteq.h"
kkoichy 0:783afa2e2461 2
kkoichy 0:783afa2e2461 3
kkoichy 0:783afa2e2461 4 namespace mbed {
kkoichy 0:783afa2e2461 5
kkoichy 4:53d26a675eb3 6 Roboteq::Roboteq(uint8_t _node_id, CAN * _can) : CANopen_Node(_node_id, _can)
kkoichy 0:783afa2e2461 7 {
kkoichy 0:783afa2e2461 8
kkoichy 0:783afa2e2461 9
kkoichy 0:783afa2e2461 10 }
kkoichy 4:53d26a675eb3 11
kkoichy 4:53d26a675eb3 12 void Roboteq::SetParameters(int16_t _velocity, long _accel, long _decel, uint8_t _channel)
kkoichy 4:53d26a675eb3 13 {
kkoichy 4:53d26a675eb3 14 SetVelocity(_velocity, _channel);
kkoichy 4:53d26a675eb3 15 SetAcceleration(_accel, _channel);
kkoichy 4:53d26a675eb3 16 SetDeceleration(_decel, _channel);
kkoichy 4:53d26a675eb3 17 SaveConfigToFlash();
kkoichy 4:53d26a675eb3 18 }
kkoichy 4:53d26a675eb3 19
kkoichy 0:783afa2e2461 20 void Roboteq::SetPosition(long _position, uint8_t _channel)
kkoichy 0:783afa2e2461 21 {
kkoichy 0:783afa2e2461 22 Send_Initiate_SDO_Download(0x2001, _channel, _position);
kkoichy 0:783afa2e2461 23 }
kkoichy 0:783afa2e2461 24 void Roboteq::SetVelocity(uint16_t _speed, uint8_t _channel)
kkoichy 0:783afa2e2461 25 {
kkoichy 0:783afa2e2461 26 Send_Initiate_SDO_Download(0x2002, _channel, _speed);
kkoichy 0:783afa2e2461 27 }
kkoichy 0:783afa2e2461 28 void Roboteq::SetEncoderCounter(long _counter, uint8_t _channel)
kkoichy 0:783afa2e2461 29 {
kkoichy 0:783afa2e2461 30 Send_Initiate_SDO_Download(0x2003, _channel, _counter);
kkoichy 0:783afa2e2461 31 }
kkoichy 0:783afa2e2461 32 void Roboteq::SetBrushlessCounter(long _counter, uint8_t _channel)
kkoichy 0:783afa2e2461 33 {
kkoichy 0:783afa2e2461 34 Send_Initiate_SDO_Download(0x2004, _channel, _counter);
kkoichy 0:783afa2e2461 35 }
kkoichy 0:783afa2e2461 36 void Roboteq::SetUserIntVariable(long _var, uint8_t _nb_var)
kkoichy 0:783afa2e2461 37 {
kkoichy 0:783afa2e2461 38 Send_Initiate_SDO_Download(0x2005, _nb_var, _var);
kkoichy 0:783afa2e2461 39 }
kkoichy 0:783afa2e2461 40 void Roboteq::SetAcceleration(long _accel, uint8_t _channel)
kkoichy 0:783afa2e2461 41 {
kkoichy 0:783afa2e2461 42 Send_Initiate_SDO_Download(0x2006, _channel, _accel);
kkoichy 0:783afa2e2461 43 }
kkoichy 0:783afa2e2461 44 void Roboteq::SetDeceleration(long _decel, uint8_t _channel)
kkoichy 0:783afa2e2461 45 {
kkoichy 0:783afa2e2461 46 Send_Initiate_SDO_Download(0x2007, _channel, _decel);
kkoichy 0:783afa2e2461 47 }
kkoichy 0:783afa2e2461 48 void Roboteq::SetAllDigitalOutBits(uint8_t _out_bits)
kkoichy 0:783afa2e2461 49 {
kkoichy 0:783afa2e2461 50 Send_Initiate_SDO_Download(0x2008, 0, _out_bits);
kkoichy 0:783afa2e2461 51 }
kkoichy 0:783afa2e2461 52 void Roboteq::SetIndividualDigitalOutBits(uint8_t _out_bits)
kkoichy 0:783afa2e2461 53 {
kkoichy 0:783afa2e2461 54 Send_Initiate_SDO_Download(0x2009, 0, _out_bits);
kkoichy 0:783afa2e2461 55 }
kkoichy 0:783afa2e2461 56 void Roboteq::ResetIndividualOutBits(uint8_t _out_bits)
kkoichy 0:783afa2e2461 57 {
kkoichy 0:783afa2e2461 58 Send_Initiate_SDO_Download(0x200a, 0, _out_bits);
kkoichy 0:783afa2e2461 59 }
kkoichy 0:783afa2e2461 60 void Roboteq::LoadHomeCounter(uint8_t _channel)
kkoichy 0:783afa2e2461 61 {
kkoichy 0:783afa2e2461 62 Send_Initiate_SDO_Download(0x200b, 0, 0);
kkoichy 0:783afa2e2461 63 }
kkoichy 0:783afa2e2461 64 void Roboteq::EmergencyShutdown(uint8_t _param)
kkoichy 0:783afa2e2461 65 {
kkoichy 0:783afa2e2461 66 Send_Initiate_SDO_Download(0x200c, 0, 0);
kkoichy 0:783afa2e2461 67 }
kkoichy 0:783afa2e2461 68 void Roboteq::ReleaseShutdown(uint8_t _param)
kkoichy 0:783afa2e2461 69 {
kkoichy 0:783afa2e2461 70 Send_Initiate_SDO_Download(0x200d, 0, 0);
kkoichy 0:783afa2e2461 71 }
kkoichy 0:783afa2e2461 72 void Roboteq::StopInAllModes(uint8_t _channel)
kkoichy 0:783afa2e2461 73 {
kkoichy 0:783afa2e2461 74 Send_Initiate_SDO_Download(0x200e, _channel, 0);
kkoichy 0:783afa2e2461 75 }
kkoichy 0:783afa2e2461 76 void Roboteq::SetPosRelative(long _position, uint8_t _channel)
kkoichy 0:783afa2e2461 77 {
kkoichy 0:783afa2e2461 78 Send_Initiate_SDO_Download(0x200f, _channel, _position);
kkoichy 0:783afa2e2461 79 }
kkoichy 0:783afa2e2461 80 void Roboteq::SetNextPosAbsolute(long _position, uint8_t _channel)
kkoichy 0:783afa2e2461 81 {
kkoichy 0:783afa2e2461 82 Send_Initiate_SDO_Download(0x2010, _channel, _position);
kkoichy 0:783afa2e2461 83 }
kkoichy 0:783afa2e2461 84 void Roboteq::SetNextPosRelative(long _position, uint8_t _channel)
kkoichy 0:783afa2e2461 85 {
kkoichy 0:783afa2e2461 86 Send_Initiate_SDO_Download(0x2011, _channel, _position);
kkoichy 0:783afa2e2461 87 }
kkoichy 0:783afa2e2461 88 void Roboteq::SetNextAcceleration(long _accel, uint8_t _channel)
kkoichy 0:783afa2e2461 89 {
kkoichy 0:783afa2e2461 90 Send_Initiate_SDO_Download(0x2012, _channel, _accel);
kkoichy 0:783afa2e2461 91 }
kkoichy 0:783afa2e2461 92 void Roboteq::SetNextDeceleration(long _decel, uint8_t _channel)
kkoichy 0:783afa2e2461 93 {
kkoichy 0:783afa2e2461 94 Send_Initiate_SDO_Download(0x2013, _channel, _decel);
kkoichy 0:783afa2e2461 95 }
kkoichy 0:783afa2e2461 96 void Roboteq::SetNextVelocity(uint16_t _speed, uint8_t _channel)
kkoichy 0:783afa2e2461 97 {
kkoichy 0:783afa2e2461 98 Send_Initiate_SDO_Download(0x2014, _channel, _speed);
kkoichy 0:783afa2e2461 99 }
kkoichy 0:783afa2e2461 100 void Roboteq::SetUserBoolVariable(long _var, uint8_t _nb_var)
kkoichy 0:783afa2e2461 101 {
kkoichy 0:783afa2e2461 102 Send_Initiate_SDO_Download(0x2015, _nb_var, _var);
kkoichy 0:783afa2e2461 103 }
kkoichy 0:783afa2e2461 104 void Roboteq::SaveConfigToFlash(void)
kkoichy 0:783afa2e2461 105 {
kkoichy 0:783afa2e2461 106 Send_Initiate_SDO_Download(0x2017, 0, 0);
kkoichy 0:783afa2e2461 107 }
kkoichy 0:783afa2e2461 108
kkoichy 0:783afa2e2461 109
kkoichy 0:783afa2e2461 110 int16_t Roboteq::ReadMotorAmps(uint8_t _channel)
kkoichy 0:783afa2e2461 111 {
kkoichy 0:783afa2e2461 112 return Send_Initiate_SDO_Upload(0x2100, _channel);
kkoichy 0:783afa2e2461 113 }
kkoichy 0:783afa2e2461 114 int16_t Roboteq::ReadActualMotorCommand(uint8_t _channel)
kkoichy 0:783afa2e2461 115 {
kkoichy 0:783afa2e2461 116 return Send_Initiate_SDO_Upload(0x2101, _channel);
kkoichy 0:783afa2e2461 117 }
kkoichy 0:783afa2e2461 118 int16_t Roboteq::ReadAppliedPowerLevel(uint8_t _channel)
kkoichy 0:783afa2e2461 119 {
kkoichy 0:783afa2e2461 120 return Send_Initiate_SDO_Upload(0x2102, _channel);
kkoichy 0:783afa2e2461 121 }
kkoichy 0:783afa2e2461 122 int16_t Roboteq::ReadEncoderMotorSpeed(uint8_t _channel)
kkoichy 0:783afa2e2461 123 {
kkoichy 0:783afa2e2461 124 return Send_Initiate_SDO_Upload(0x2103, _channel);
kkoichy 0:783afa2e2461 125 }
kkoichy 0:783afa2e2461 126 int16_t Roboteq::ReadAbsoluteEncoderCount(uint8_t _channel)
kkoichy 0:783afa2e2461 127 {
kkoichy 0:783afa2e2461 128 return Send_Initiate_SDO_Upload(0x2104, _channel);
kkoichy 0:783afa2e2461 129 }
kkoichy 0:783afa2e2461 130 int16_t Roboteq::ReadAbsoluteBrushlessCounter(uint8_t _channel)
kkoichy 0:783afa2e2461 131 {
kkoichy 0:783afa2e2461 132 return Send_Initiate_SDO_Upload(0x2105, _channel);
kkoichy 0:783afa2e2461 133 }
kkoichy 0:783afa2e2461 134 int16_t Roboteq::ReadUserIntegerVariable(uint8_t _nb_var)
kkoichy 0:783afa2e2461 135 {
kkoichy 0:783afa2e2461 136 return Send_Initiate_SDO_Upload(0x2106, _nb_var);
kkoichy 0:783afa2e2461 137 }
kkoichy 0:783afa2e2461 138 int16_t Roboteq::ReadEncoderMotorSpeedRelativeToMaxSpeed(uint8_t _channel)
kkoichy 0:783afa2e2461 139 {
kkoichy 0:783afa2e2461 140 return Send_Initiate_SDO_Upload(0x2107, _channel);
kkoichy 0:783afa2e2461 141 }
kkoichy 0:783afa2e2461 142 int16_t Roboteq::ReadEncoderCountRelative(uint8_t _channel)
kkoichy 0:783afa2e2461 143 {
kkoichy 0:783afa2e2461 144 return Send_Initiate_SDO_Upload(0x2108, _channel);
kkoichy 0:783afa2e2461 145 }
kkoichy 0:783afa2e2461 146 int16_t Roboteq::ReadBrushlessCountRelative(uint8_t _channel)
kkoichy 0:783afa2e2461 147 {
kkoichy 0:783afa2e2461 148 return Send_Initiate_SDO_Upload(0x2109, _channel);
kkoichy 0:783afa2e2461 149 }
kkoichy 0:783afa2e2461 150 int16_t Roboteq::ReadBrushlessMotorSpeed(uint8_t _channel)
kkoichy 0:783afa2e2461 151 {
kkoichy 0:783afa2e2461 152 return Send_Initiate_SDO_Upload(0x210a, _channel);
kkoichy 0:783afa2e2461 153 }
kkoichy 0:783afa2e2461 154 int16_t Roboteq::ReadBrushlessMotorSpeedRelativeToMaxSpeed(uint8_t _channel)
kkoichy 0:783afa2e2461 155 {
kkoichy 0:783afa2e2461 156 return Send_Initiate_SDO_Upload(0x210b, _channel);
kkoichy 0:783afa2e2461 157 }
kkoichy 0:783afa2e2461 158 int16_t Roboteq::ReadBatteryAmps(uint8_t _channel)
kkoichy 0:783afa2e2461 159 {
kkoichy 0:783afa2e2461 160 return Send_Initiate_SDO_Upload(0x210c, _channel);
kkoichy 0:783afa2e2461 161 }
kkoichy 0:783afa2e2461 162 uint16_t Roboteq::ReadInternalVoltages(uint8_t _param)
kkoichy 0:783afa2e2461 163 {
kkoichy 0:783afa2e2461 164 return Send_Initiate_SDO_Upload(0x210d, _param);
kkoichy 0:783afa2e2461 165 }
kkoichy 0:783afa2e2461 166 uint32_t Roboteq::ReadAllDigitalInputs(void)
kkoichy 0:783afa2e2461 167 {
kkoichy 0:783afa2e2461 168 return Send_Initiate_SDO_Upload(0x210e, 0);
kkoichy 0:783afa2e2461 169 }
kkoichy 0:783afa2e2461 170 int8_t Roboteq::ReadCaseAndInternalTemperatures(uint8_t _param)
kkoichy 0:783afa2e2461 171 {
kkoichy 0:783afa2e2461 172 return Send_Initiate_SDO_Upload(0x210f, _param);
kkoichy 0:783afa2e2461 173 }
kkoichy 0:783afa2e2461 174 int16_t Roboteq::ReadFeedback(uint8_t _channel)
kkoichy 0:783afa2e2461 175 {
kkoichy 0:783afa2e2461 176 return Send_Initiate_SDO_Upload(0x2110, _channel);
kkoichy 0:783afa2e2461 177 }
kkoichy 0:783afa2e2461 178 uint8_t Roboteq::ReadStatusFlags(void)
kkoichy 0:783afa2e2461 179 {
kkoichy 0:783afa2e2461 180 return Send_Initiate_SDO_Upload(0x2111, 0);
kkoichy 0:783afa2e2461 181 }
kkoichy 0:783afa2e2461 182 uint8_t Roboteq::ReadFaultFlags(void)
kkoichy 0:783afa2e2461 183 {
kkoichy 0:783afa2e2461 184 return Send_Initiate_SDO_Upload(0x2112, 0);
kkoichy 0:783afa2e2461 185 }
kkoichy 0:783afa2e2461 186 uint8_t Roboteq::ReadCurrentDigitalOutputs(void)
kkoichy 0:783afa2e2461 187 {
kkoichy 0:783afa2e2461 188 return Send_Initiate_SDO_Upload(0x2113, 0);
kkoichy 0:783afa2e2461 189
kkoichy 0:783afa2e2461 190 }
kkoichy 0:783afa2e2461 191 int32_t Roboteq::ReadClosedLoopError(uint8_t _channel)
kkoichy 0:783afa2e2461 192 {
kkoichy 0:783afa2e2461 193 return Send_Initiate_SDO_Upload(0x2114, _channel);
kkoichy 0:783afa2e2461 194 }
kkoichy 0:783afa2e2461 195 int32_t Roboteq::ReadUserBooleanVariable(uint8_t _nb_var)
kkoichy 0:783afa2e2461 196 {
kkoichy 0:783afa2e2461 197 return Send_Initiate_SDO_Upload(0x2115, _nb_var);
kkoichy 0:783afa2e2461 198 }
kkoichy 0:783afa2e2461 199 int32_t Roboteq::ReadInternalSerialCommand(uint8_t _channel)
kkoichy 0:783afa2e2461 200 {
kkoichy 0:783afa2e2461 201 return Send_Initiate_SDO_Upload(0x2116, _channel);
kkoichy 0:783afa2e2461 202 }
kkoichy 0:783afa2e2461 203 int32_t Roboteq::ReadInternalAnalogCommand(uint8_t _channel)
kkoichy 0:783afa2e2461 204 {
kkoichy 0:783afa2e2461 205 return Send_Initiate_SDO_Upload(0x2117, _channel);
kkoichy 0:783afa2e2461 206 }
kkoichy 0:783afa2e2461 207 int32_t Roboteq::ReadInternalPulseCommand(uint8_t _channel)
kkoichy 0:783afa2e2461 208 {
kkoichy 0:783afa2e2461 209 return Send_Initiate_SDO_Upload(0x2118, _channel);
kkoichy 0:783afa2e2461 210 }
kkoichy 0:783afa2e2461 211 uint32_t Roboteq::ReadTime(void)
kkoichy 0:783afa2e2461 212 {
kkoichy 0:783afa2e2461 213 return Send_Initiate_SDO_Upload(0x2119, 0);
kkoichy 0:783afa2e2461 214 }
kkoichy 0:783afa2e2461 215 uint16_t Roboteq::ReadSpektrumRadioCapture(uint8_t _nb_capture)
kkoichy 0:783afa2e2461 216 {
kkoichy 0:783afa2e2461 217 return Send_Initiate_SDO_Upload(0x211a, _nb_capture);
kkoichy 0:783afa2e2461 218 }
kkoichy 0:783afa2e2461 219 uint8_t Roboteq::ReadDestinationPositionReachedFlag(uint8_t _channel)
kkoichy 0:783afa2e2461 220 {
kkoichy 0:783afa2e2461 221 return Send_Initiate_SDO_Upload(0x211b, _channel);
kkoichy 0:783afa2e2461 222 }
kkoichy 0:783afa2e2461 223 int32_t Roboteq::ReadMEMSAccelerometerAxis(uint8_t _axis)
kkoichy 0:783afa2e2461 224 {
kkoichy 0:783afa2e2461 225 return Send_Initiate_SDO_Upload(0x211c, _axis);
kkoichy 0:783afa2e2461 226 }
kkoichy 0:783afa2e2461 227 uint16_t Roboteq::ReadMagsensorTrackDetect(void)
kkoichy 0:783afa2e2461 228 {
kkoichy 0:783afa2e2461 229 return Send_Initiate_SDO_Upload(0x211d, 0);
kkoichy 0:783afa2e2461 230 }
kkoichy 0:783afa2e2461 231 uint8_t Roboteq::ReadMagsensorTrackPosition(void)
kkoichy 0:783afa2e2461 232 {
kkoichy 0:783afa2e2461 233 return Send_Initiate_SDO_Upload(0x211e, 0);
kkoichy 0:783afa2e2461 234 }
kkoichy 0:783afa2e2461 235 uint8_t Roboteq::ReadMagsensorMarkers(void)
kkoichy 0:783afa2e2461 236 {
kkoichy 0:783afa2e2461 237 return Send_Initiate_SDO_Upload(0x211f, 0);
kkoichy 0:783afa2e2461 238 }
kkoichy 0:783afa2e2461 239 uint8_t Roboteq::ReadMagsensorStatus(void)
kkoichy 0:783afa2e2461 240 {
kkoichy 0:783afa2e2461 241 return Send_Initiate_SDO_Upload(0x2120, 0);
kkoichy 0:783afa2e2461 242 }
kkoichy 0:783afa2e2461 243 uint8_t Roboteq::ReadMotorStatusFlags(void)
kkoichy 0:783afa2e2461 244 {
kkoichy 0:783afa2e2461 245 return Send_Initiate_SDO_Upload(0x2121, 0);
kkoichy 0:783afa2e2461 246 }
kkoichy 0:783afa2e2461 247 int32_t Roboteq::ReadIndividualDigitalInputs(uint8_t _input)
kkoichy 0:783afa2e2461 248 {
kkoichy 0:783afa2e2461 249 return Send_Initiate_SDO_Upload(0x6400, _input);
kkoichy 0:783afa2e2461 250 }
kkoichy 0:783afa2e2461 251 int16_t Roboteq::ReadAnalogInputs(uint8_t _input)
kkoichy 0:783afa2e2461 252 {
kkoichy 0:783afa2e2461 253 return Send_Initiate_SDO_Upload(0x6401, _input);
kkoichy 0:783afa2e2461 254 }
kkoichy 0:783afa2e2461 255 int16_t Roboteq::ReadAnalogInputsConverted(uint8_t _input)
kkoichy 0:783afa2e2461 256 {
kkoichy 0:783afa2e2461 257 return Send_Initiate_SDO_Upload(0x6402, _input);
kkoichy 0:783afa2e2461 258 }
kkoichy 0:783afa2e2461 259 int16_t Roboteq::ReadPulseInputs(uint8_t _input)
kkoichy 0:783afa2e2461 260 {
kkoichy 0:783afa2e2461 261 return Send_Initiate_SDO_Upload(0x6403, _input);
kkoichy 0:783afa2e2461 262 }
kkoichy 0:783afa2e2461 263 int16_t Roboteq::ReadPulseInputsConverted(uint8_t _input)
kkoichy 0:783afa2e2461 264 {
kkoichy 0:783afa2e2461 265 return Send_Initiate_SDO_Upload(0x6404, _input);
kkoichy 0:783afa2e2461 266 }
kkoichy 0:783afa2e2461 267
kkoichy 0:783afa2e2461 268
kkoichy 0:783afa2e2461 269 }