Skip to content

Commit

Permalink
Merge pull request #63 from lsst-ts/tickets/DM-44604
Browse files Browse the repository at this point in the history
DM-44604: new cRIo commands (broadcast for steps, freeze)
  • Loading branch information
pkubanek authored Jun 10, 2024
2 parents 4b385b6 + d0a2757 commit a050e84
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
4 changes: 4 additions & 0 deletions doc/version-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Version History
###############

v1.11.1
-------
* broadcast commands to step and freeze

v1.11.0
-------
* Modbus::, ILC::ILCBusList classes. Communication code moved from ModbusBuffer
Expand Down
20 changes: 18 additions & 2 deletions include/ILC/ILCBusList.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ class ILCBusList : public Modbus::BusList {
};

protected:
/**
* Call broadcast function.
*
* @param address broadcast address. Shall be 0, 148, 149, 250 or 255. Not checked if it is correct
* @param func function to call
* @param delay delay in us (microseconds) for broadcast processing. Bus will remain silence for this
* number of us to allow ModBus process the broadcast function
* @param counter broadcast counter. ModBus provides method to retrieve this
* in unicast function to verify the broadcast was received and processed
*/
void broadcastFunction(uint8_t address, uint8_t func, uint32_t delay, uint8_t counter) {
callFunction(address, func, delay, counter);
}

/**
* Call broadcast function.
*
Expand All @@ -136,10 +150,12 @@ class ILCBusList : public Modbus::BusList {
* @param counter broadcast counter. ModBus provides method to retrieve this
* in unicast function to verify the broadcast was received and processed
* @param data function parameters. Usually device's bus ID indexed array
_
*/
template <typename data_type>
void broadcastFunction(uint8_t address, uint8_t func, uint32_t delay, uint8_t counter,
std::vector<uint8_t> data);
std::vector<data_type> data = {}) {
callFunction(address, func, delay, counter, data);
}

/**
* Return next bus broadcast counter.
Expand Down
5 changes: 5 additions & 0 deletions include/Modbus/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ inline void Buffer::write(std::vector<uint8_t> data) {
writeVector<uint8_t>(data);
}

template <>
inline void Buffer::write(std::vector<int8_t> data) {
writeVector<int8_t>(data);
}

template <>
inline void Buffer::write(std::vector<uint16_t> data) {
writeVector<uint16_t>(data);
Expand Down
31 changes: 31 additions & 0 deletions include/cRIO/ElectromechanicalPneumaticILC.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ElectromechanicalPneumaticILC : public virtual ILC::ILCBusList {
enum ILC_EM_CMD {
SET_STEPPER_STEPS = 66,
STEPPER_FORCE_STATUS = 67,
FREEZE_SENSOR = 68,
SET_DCA_GAIN = 73,
REPORT_DCA_GAIN = 74,
SET_FORCE_OFFSET = 75,
Expand All @@ -71,6 +72,8 @@ class ElectromechanicalPneumaticILC : public virtual ILC::ILCBusList {
REPORT_HARDPOINT_LVDT = 122
};

static constexpr uint8_t EA_BROADCAST = 248;

/**
* Unicast command to command stepper motor moves.
*
Expand All @@ -86,6 +89,19 @@ class ElectromechanicalPneumaticILC : public virtual ILC::ILCBusList {
callFunction(address, ILC_EM_CMD::SET_STEPPER_STEPS, 1800, steps);
}

/**
* Broadcast steps to all force actuators.
*
* @param counter broadcast counter (0-15)
* @param steps commanded steps
*
* @ingroup M1M3_hp
* @ingroup M2
*/
void broadcastStepperSteps(uint8_t counter, std::vector<int8_t> steps) {
broadcastFunction(EA_BROADCAST, ILC_EM_CMD::SET_STEPPER_STEPS, 1800, counter, steps);
}

/**
* Unicast Stepper motor @glos{ILC} Force [N] and Status Request. @glos{ILC} command
* code 67 (0x43). Applies for M2 tangent and axials controllers, as well
Expand Down Expand Up @@ -169,6 +185,21 @@ class ElectromechanicalPneumaticILC : public virtual ILC::ILCBusList {
callFunction(address, ILC_EM_CMD::REPORT_FA_FORCE_STATUS, 1800);
}

/**
* Freeze sensor values. After issuing freeze, sensor values can be read
* out with reportForceActuatorForceStatus (function
* REPORT_FA_FORCE_STATUS).
*
* @param counter broadcast counter (0-15)
*
* @ingroup M1M3_fa
* @ingroup M1M3_hp
* @ingroup M2
*/
void freezeSensor(uint8_t counter) {
broadcastFunction(EA_BROADCAST, ILC_EM_CMD::FREEZE_SENSOR, 180, counter);
}

/**
* Unicast ADC Channel Offset and Sensitivity. @glos{ILC} command code 81 (0x51).
*
Expand Down
5 changes: 0 additions & 5 deletions src/ILC/ILCBusList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ ILCBusList::ILCBusList(uint8_t bus) : _bus(bus) {

ILCBusList::~ILCBusList() {}

void ILCBusList::broadcastFunction(uint8_t address, uint8_t func, uint32_t delay, uint8_t counter,
std::vector<uint8_t> data) {
callFunction(address, func, delay, counter, data);
}

uint8_t ILCBusList::nextBroadcastCounter() {
_broadcastCounter++;
if (_broadcastCounter > 15) {
Expand Down

0 comments on commit a050e84

Please sign in to comment.