46 IntentionallyDeenergized = 0,
50 RequiredInputInvalid = 4,
53 SafeStartViolation = 7,
67 SetTargetPosition = 0xE0,
68 SetTargetVelocity = 0xE3,
69 HaltAndSetPosition = 0xEC,
72 ResetCommandTimeout = 0x8C,
76 EnterSafeStart = 0x8F,
78 ClearDriverError = 0x8A,
80 SetStartingSpeed = 0xE5,
84 SetCurrentLimit = 0x91,
88 GetVariableAndClearErrorsOccurred = 0xA2,
100 WaitingForErrLine = 6,
277 PositionUncertain = 1,
278 ForwardLimitActive = 2,
279 ReverseLimitActive = 3,
329 this->product = product;
347 commandW32(TicCommand::SetTargetPosition, position);
367 commandW32(TicCommand::SetTargetVelocity, velocity);
388 commandW32(TicCommand::HaltAndSetPosition, position);
409 commandQuick(TicCommand::HaltAndHold);
419 commandW7(TicCommand::GoHome, 0);
429 commandW7(TicCommand::GoHome, 1);
442 commandQuick(TicCommand::ResetCommandTimeout);
466 commandQuick(TicCommand::Deenergize);
481 commandQuick(TicCommand::Energize);
496 commandQuick(TicCommand::ExitSafeStart);
516 commandQuick(TicCommand::EnterSafeStart);
530 commandQuick(TicCommand::Reset);
548 commandQuick(TicCommand::ClearDriverError);
564 commandW32(TicCommand::SetSpeedMax, speed);
580 commandW32(TicCommand::SetStartingSpeed, speed);
597 commandW32(TicCommand::SetAccelMax, accel);
614 commandW32(TicCommand::SetDecelMax, decel);
631 commandW7(TicCommand::SetStepMode, (uint8_t)mode);
654 void setCurrentLimit(uint16_t limit);
668 commandW7(TicCommand::SetDecayMode, (uint8_t)mode);
678 commandW7(TicCommand::SetAgcOption, (uint8_t)mode & 0xF);
688 commandW7(TicCommand::SetAgcOption, 0x10 | (uint8_t)limit & 0xF);
698 commandW7(TicCommand::SetAgcOption, 0x20 | (uint8_t)steps & 0xF);
708 commandW7(TicCommand::SetAgcOption, 0x30 | (uint8_t)limit & 0xF);
733 return getVar8(VarOffset::MiscFlags1) >>
734 (uint8_t)TicMiscFlags1::Energized & 1;
744 return getVar8(VarOffset::MiscFlags1) >>
745 (uint8_t)TicMiscFlags1::PositionUncertain & 1;
751 return getVar8(VarOffset::MiscFlags1) >>
752 (uint8_t)TicMiscFlags1::ForwardLimitActive & 1;
758 return getVar8(VarOffset::MiscFlags1) >>
759 (uint8_t)TicMiscFlags1::ReverseLimitActive & 1;
765 return getVar8(VarOffset::MiscFlags1) >>
766 (uint8_t)TicMiscFlags1::HomingActive & 1;
784 return getVar16(VarOffset::ErrorStatus);
807 getSegment(TicCommand::GetVariableAndClearErrorsOccurred,
808 VarOffset::ErrorsOccurred, 4, &result);
838 return getVar32(VarOffset::TargetPosition);
849 return getVar32(VarOffset::TargetVelocity);
860 return getVar32(VarOffset::SpeedMax);
876 return getVar32(VarOffset::StartingSpeed);
892 return getVar32(VarOffset::AccelMax);
908 return getVar32(VarOffset::DecelMax);
923 return getVar32(VarOffset::CurrentPosition);
939 return getVar32(VarOffset::CurrentVelocity);
951 return getVar32(VarOffset::ActingTargetPosition);
964 return getVar32(VarOffset::TimeSinceLastStep);
980 return (
TicReset)getVar8(VarOffset::DeviceReset);
991 return getVar16(VarOffset::VinVoltage);
1005 return getVar32(VarOffset::UpTime);
1016 return getVar32(VarOffset::EncoderPosition);
1034 return getVar16(VarOffset::RCPulseWidth);
1054 uint8_t offset = VarOffset::AnalogReadingSCL + 2 * (uint8_t)pin;
1055 return getVar16(offset);
1071 uint8_t readings = getVar8(VarOffset::DigitalReadings);
1072 return (readings >> (uint8_t)pin) & 1;
1090 uint8_t states = getVar8(VarOffset::PinStates);
1091 return (
TicPinState)(states >> (2 * (uint8_t)pin) & 0b11);
1123 uint16_t getCurrentLimit();
1164 return getVar16(VarOffset::InputAfterAveraging);
1174 return getVar16(VarOffset::InputAfterHysteresis);
1190 return getVar32(VarOffset::InputAfterScaling);
1208 return (
TicAgcMode)getVar8(VarOffset::AgcMode);
1249 return getVar8(VarOffset::LastHpDriverErrors);
1266 void getSetting(uint8_t offset, uint8_t length, uint8_t * buffer)
1268 getSegment(TicCommand::GetSetting, offset, length, buffer);
1281 uint8_t _lastError = 0;
1286 OperationState = 0x00,
1289 ErrorsOccurred = 0x04,
1290 PlanningMode = 0x09,
1291 TargetPosition = 0x0A,
1292 TargetVelocity = 0x0E,
1293 StartingSpeed = 0x12,
1297 CurrentPosition = 0x22,
1298 CurrentVelocity = 0x26,
1299 ActingTargetPosition = 0x2A,
1300 TimeSinceLastStep = 0x2E,
1304 EncoderPosition = 0x39,
1305 RCPulseWidth = 0x3D,
1306 AnalogReadingSCL = 0x3F,
1307 AnalogReadingSDA = 0x41,
1308 AnalogReadingTX = 0x43,
1309 AnalogReadingRX = 0x45,
1310 DigitalReadings = 0x47,
1313 CurrentLimit = 0x4A,
1316 InputAfterAveraging = 0x4D,
1317 InputAfterHysteresis = 0x4F,
1318 InputAfterScaling = 0x51,
1319 LastMotorDriverError = 0x55,
1321 AgcBottomCurrentLimit = 0x57,
1322 AgcCurrentBoostSteps = 0x58,
1323 AgcFrequencyLimit = 0x59,
1324 LastHpDriverErrors = 0xFF,
1327 uint8_t getVar8(uint8_t offset)
1330 getSegment(TicCommand::GetVariable, offset, 1, &result);
1334 uint16_t getVar16(uint8_t offset)
1337 getSegment(TicCommand::GetVariable, offset, 2, &buffer);
1338 return ((uint16_t)buffer[0] << 0) | ((uint16_t)buffer[1] << 8);
1341 uint32_t getVar32(uint8_t offset)
1344 getSegment(TicCommand::GetVariable, offset, 4, buffer);
1345 return ((uint32_t)buffer[0] << 0) |
1346 ((uint32_t)buffer[1] << 8) |
1347 ((uint32_t)buffer[2] << 16) |
1348 ((uint32_t)buffer[3] << 24);
1351 virtual void commandQuick(
TicCommand cmd) = 0;
1352 virtual void commandW32(
TicCommand cmd, uint32_t val) = 0;
1353 virtual void commandW7(
TicCommand cmd, uint8_t val) = 0;
1354 virtual void getSegment(
TicCommand cmd, uint8_t offset,
1355 uint8_t length,
void * buffer);
1357 TicProduct product = TicProduct::Unknown;
1395 _deviceNumber(deviceNumber)
1403 Stream *
const _stream;
1404 const uint8_t _deviceNumber;
1406 void commandQuick(
TicCommand cmd) { sendCommandHeader(cmd); }
1407 void commandW32(
TicCommand cmd, uint32_t val);
1410 void getSegment(
TicCommand cmd, uint8_t offset,
1411 uint8_t length,
void * buffer);
1414 void serialW7(uint8_t val) { _stream->write(val & 0x7F); }
1428 TicI2C(uint8_t address = 14) : _address(address)
1438 const uint8_t _address;
1441 void commandW32(
TicCommand cmd, uint32_t val);
1443 void getSegment(
TicCommand cmd, uint8_t offset,
1444 uint8_t length,
void * buffer);
1445 void delayAfterRead();
TicInputState
This enum defines the possible states of the Tic's main input.
uint16_t getAnalogReading(TicPin pin)
uint32_t getErrorsOccurred()
void setDecayMode(TicDecayMode mode)
void setProduct(TicProduct product)
void setAgcFrequencyLimit(TicAgcFrequencyLimit limit)
The input is valid and is telling the Tic to halt the motor.
TicPin
This enum defines the Tic's control pins.
TicMotorDriverError getLastMotorDriverError()
uint8_t getLastHpDriverErrors()
TicAgcCurrentBoostSteps getAgcCurrentBoostSteps()
bool getDigitalReading(TicPin pin)
const uint8_t TicT249CurrentUnits
void setStartingSpeed(uint32_t speed)
const uint8_t TicCurrentUnits
uint8_t getDeviceNumber()
Gets the serial device number specified in the constructor.
TicStepMode getStepMode()
void setTargetVelocity(int32_t velocity)
TicDecayMode getDecayMode()
TicReset getDeviceReset()
void setStepMode(TicStepMode mode)
void getSetting(uint8_t offset, uint8_t length, uint8_t *buffer)
void setMaxDecel(uint32_t decel)
bool getPositionUncertain()
TicI2C(uint8_t address=14)
uint32_t getStartingSpeed()
void setAgcMode(TicAgcMode mode)
int32_t getEncoderPosition()
uint32_t getActingTargetPosition()
TicInputState getInputState()
int32_t getTargetPosition()
uint16_t getInputAfterHysteresis()
bool getForwardLimitActive()
Returns true if one of the forward limit switches is active.
bool getReverseLimitActive()
Returns true if one of the reverse limit switches is active.
uint32_t getTimeSinceLastStep()
TicPlanningMode getPlanningMode()
uint16_t getErrorStatus()
int32_t getCurrentVelocity()
void setMaxAccel(uint32_t accel)
bool getHomingActive()
Returns true if the Tic's homing procedure is running.
TicAgcBottomCurrentLimit getAgcBottomCurrentLimit()
void setAgcBottomCurrentLimit(TicAgcBottomCurrentLimit limit)
uint16_t getRCPulseWidth()
uint8_t getAddress()
Gets the I2C address specified in the constructor.
void haltAndSetPosition(int32_t position)
TicAgcFrequencyLimit getAgcFrequencyLimit()
int32_t getInputAfterScaling()
uint16_t getInputAfterAveraging()
This specifies "Fast" decay mode.
TicPinState getPinState(TicPin pin)
int32_t getCurrentPosition()
int32_t getTargetVelocity()
This specifies "Slow" decay mode.
TicSerial(Stream &stream, uint8_t deviceNumber=255)
const uint16_t TicInputNull
void setAgcCurrentBoostSteps(TicAgcCurrentBoostSteps steps)
void resetCommandTimeout()
void setMaxSpeed(uint32_t speed)
TicOperationState getOperationState()
void setTargetPosition(int32_t position)