8#include <nlohmann/json_fwd.hpp>
120 return "rotatingTuned";
157 return "unknown encoder";
184 return "configuration";
214 return "drive-control";
216 return "motion-control";
246 return "the encoder's asynchronous channel is busy with another transaction";
248 return "the register length must be 1 to 4 bytes";
250 return "the encoder did not return a value within 10 ms";
252 return "the encoder answered with a different number of bytes than were asked for";
254 return "the encoder is accessing its flash memory and cannot service this register";
256 return "unknown fault";
390 return "illegal-instruction";
392 return "illegal-resource";
402 return "resource-dependency";
406 return "endless-loop";
408 return "resettable-firmware-error";
446 return "start frequency";
448 return "target frequency";
450 return "target amplitude";
452 return "transition time";
454 return "signal type";
456 return "start the procedure";
458 return "unknown parameter";
473 return "logarithmic";
501 return "immediately";
503 return "after-hrd-stream-start";
540 return "invalid response";
542 return "register not allowed";
552 return "the register communication transaction failed internally, which a BiSS clock "
553 "frequency set too high can cause";
555 return "the register cannot be accessed at the moment, which happens when the firmware is "
556 "itself using it — an iC-MU I2C register while iC-PVL registers are being monitored, "
559 return "unknown fault";
593 return "encoder-raw";
595 return "system-identification";
602std::optional<HrdData>
parseHrdData(std::string_view token);
621 : std::chrono::milliseconds(6000);
641 return "initialization error";
643 return "streaming error";
645 return "duration value";
647 return "data index value";
649 return "action value";
659 return "the drive could not start the recording";
661 return "the recording failed part way through, so whatever reached the drive's files is "
664 return "the requested duration is longer than the drive allows for the chosen data, which is "
665 "10000 ms for encoder raw data and 6000 ms for system identification data";
667 return "the drive does not know the requested data index, which means its firmware records a "
668 "different set of signals than this build expects";
670 return "the drive does not know the requested action, which means its firmware drives HRD "
671 "streaming differently than this build expects";
673 return "unknown fault";
717 return "notConfigured";
730 return "manualOutputVoltage";
788 return "open terminal A";
790 return "open terminal B";
792 return "open terminal C";
794 return "open FET A high";
796 return "open FET A low";
798 return "open FET B high";
800 return "open FET B low";
802 return "open FET C high";
804 return "open FET C low";
813 return "terminal A of the drive is not connected";
815 return "terminal B of the drive is not connected";
817 return "terminal C of the drive is not connected";
819 return "the upper FET in leg A is not conducting (open circuit fault)";
821 return "the lower FET in leg A is not conducting (open circuit fault)";
823 return "the upper FET in leg B is not conducting (open circuit fault)";
825 return "the lower FET in leg B is not conducting (open circuit fault)";
827 return "the upper FET in leg C is not conducting (open circuit fault)";
829 return "the lower FET in leg C is not conducting (open circuit fault)";
831 return "unknown fault";
872 return "current amplitude error";
882 return "the drive could not raise the motor phase currents to the amplitude it needed, which "
883 "a limited DC-link voltage or a high motor phase impedance can both cause";
885 return "unknown fault";
912 return "JointTorque";
914 return "SystemIdentification";
916 return "OpenLoopField";
918 return "Diagnostics";
920 return "CoggingCompensationRecording";
929 return "Impedance mode";
931 return "Joint torque mode";
933 return "System identification mode";
935 return "Open loop field mode";
937 return "Diagnostics mode";
939 return "Cogging compensation recording mode";
941 return "Unknown mode";
1175 std::span<const uint8_t> data,
const std::vector<DeviceParameter>& definitions);
1202void to_json(nlohmann::json& j,
const BrakeState& state);
1289 std::variant<std::vector<HrdEncoderSample>, std::vector<HrdSystemIdentificationSample>>;
1354 std::optional<somanet::OpenPhaseFault>
fault;
1376void to_json(nlohmann::json& j,
const MotorPhaseOrderResult& result);
1392void to_json(nlohmann::json& j,
const CommutationOffsetResult& result);
1613 std::expected<OsCommandResponse, std::string>
runOsCommand(
1614 const std::vector<uint8_t>& command,
const OsCommandConfig& config = {},
1615 const OsCommandFsBuffer& fsBuffer = {});
1637 const OsCommandConfig& config = {});
1645 std::expected<std::string, std::string>
errorReport()
const;
1650 std::expected<BrakeState, std::string>
brakeState()
const;
1653 std::expected<somanet::BrakeStatus, std::string>
brakeStatus()
const;
1689 std::chrono::milliseconds settle = std::chrono::milliseconds(50));
1699 std::expected<BrakeState, std::string>
engageBrake(
1700 std::chrono::milliseconds settle = std::chrono::milliseconds(50));
1735 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
1736 .pollInterval = std::chrono::milliseconds(20)});
1758 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
1759 .pollInterval = std::chrono::milliseconds(20)});
1786 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
1787 .pollInterval = std::chrono::milliseconds(20)});
1814 const OsCommandConfig& config = {.timeout = std::chrono::seconds(10),
1815 .pollInterval = std::chrono::milliseconds(100)});
1837 std::expected<void, std::string>
startHrdStream(
const OsCommandConfig& config);
1873 std::expected<std::vector<DeviceFile>, std::string>
readFileList()
const;
1902 std::expected<std::optional<IntegroVariant>, std::string>
readIntegroVariant()
const;
1927 std::string_view packageFilename)
const;
1952 const OsCommandConfig& config = {.timeout = std::chrono::seconds(10),
1953 .pollInterval = std::chrono::milliseconds(100)});
1978 const OsCommandConfig& config = {.timeout = std::chrono::seconds(60),
1979 .pollInterval = std::chrono::milliseconds(100)});
2014 const OsCommandConfig& config = {.timeout = std::chrono::seconds(60),
2015 .pollInterval = std::chrono::milliseconds(100)});
2036 const OsCommandConfig& config = {.timeout = std::chrono::seconds(60),
2037 .pollInterval = std::chrono::milliseconds(100)});
2060 const OsCommandConfig& config = {.timeout = std::chrono::seconds(30),
2061 .pollInterval = std::chrono::milliseconds(100)});
2076 const OsCommandConfig& config = {.timeout = std::chrono::seconds(30),
2077 .pollInterval = std::chrono::milliseconds(100)});
2108 const OsCommandConfig& config = {.timeout = std::chrono::seconds(60),
2109 .pollInterval = std::chrono::milliseconds(100)});
2140 std::expected<TriggerErrorResult, std::string>
triggerError(
2142 const OsCommandConfig& config = {.timeout = std::chrono::seconds(3),
2143 .pollInterval = std::chrono::milliseconds(20)});
2172 uint8_t address, uint8_t length,
bool write =
false, uint32_t value = 0,
2173 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2174 .pollInterval = std::chrono::milliseconds(20)});
2197 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2198 .pollInterval = std::chrono::milliseconds(20)});
2219 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2220 .pollInterval = std::chrono::milliseconds(20)});
2237 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2238 .pollInterval = std::chrono::milliseconds(20)});
2249 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2250 .pollInterval = std::chrono::milliseconds(20)});
2281 const OsCommandConfig& config = {.timeout = std::chrono::seconds(30),
2282 .pollInterval = std::chrono::milliseconds(20)});
2314 const OsCommandConfig& config = {.timeout = std::chrono::seconds(30),
2315 .pollInterval = std::chrono::milliseconds(20)});
2341 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2342 .pollInterval = std::chrono::milliseconds(20)});
Borrowed view of a CiA402 drive — the device control state machine, operation modes,...
Definition cia402_drive.h:104
std::expected< void, std::string > setOperationMode(cia402::OperationMode mode)
Requests an operation mode (0x6060). The drive reflects it in 0x6061 once accepted.
Definition cia402_drive.cc:131
Represents a single node on the fieldbus.
Definition device.h:116
Device & device()
The underlying generic device this view operates on.
Definition profile_device.h:157
Borrowed view of a SOMANET drive — a CiA402 drive plus Synapticon-specific object-dictionary access (...
Definition somanet_drive.h:1560
std::expected< HardwareDescription, std::string > readHardwareDescription() const
Reads and parses the drive's .hardware_description file (FoE).
Definition somanet_drive.cc:1151
std::expected< void, std::string > configureHrdStream(somanet::HrdData data, std::chrono::milliseconds duration, const OsCommandConfig &config={.timeout=std::chrono::seconds(10),.pollInterval=std::chrono::milliseconds(100)})
Configures a high resolution data stream (OS command 3, configure action).
Definition somanet_drive.cc:1082
std::expected< KueblerRegisterResult, std::string > accessKueblerRegister(uint8_t address, uint8_t length, bool write=false, uint32_t value=0, const OsCommandConfig &config={.timeout=std::chrono::seconds(5),.pollInterval=std::chrono::milliseconds(20)})
Reads or writes one register of the Integro's internal (Kübler) encoder (command 19).
Definition somanet_drive.cc:1683
std::expected< MotorPhaseOrderResult, std::string > runMotorPhaseOrderDetection(const OsCommandConfig &config={.timeout=std::chrono::seconds(60),.pollInterval=std::chrono::milliseconds(100)})
Runs motor phase order detection (OS command 4) and decodes what it found.
Definition somanet_drive.cc:1361
std::expected< SkippedCyclesResult, std::string > readSkippedCycles(somanet::FirmwareService service, const OsCommandConfig &config={.timeout=std::chrono::seconds(30),.pollInterval=std::chrono::milliseconds(20)})
Reads a control loop's skipped-cycle counter (OS command 13).
Definition somanet_drive.cc:1535
std::expected< EncoderRegisterResult, std::string > writeEncoderRegister(somanet::EncoderOrdinal encoder, uint8_t registerAddress, uint8_t value, const OsCommandConfig &config={.timeout=std::chrono::seconds(5),.pollInterval=std::chrono::milliseconds(20)})
Writes one register of an encoder (OS command 0, write direction).
Definition somanet_drive.cc:1287
std::expected< void, std::string > setBrakeStatus(somanet::BrakeStatus status)
Commands the brake by writing 0x2004:07 — the raw write, with no wait and no checks.
Definition somanet_drive.cc:814
std::expected< PhaseInductanceResult, std::string > runPhaseInductanceMeasurement(const OsCommandConfig &config={.timeout=std::chrono::seconds(30),.pollInterval=std::chrono::milliseconds(100)})
Runs phase inductance measurement (OS command 9) and decodes the value it reports.
Definition somanet_drive.cc:1480
std::expected< PhaseResistanceResult, std::string > runPhaseResistanceMeasurement(const OsCommandConfig &config={.timeout=std::chrono::seconds(30),.pollInterval=std::chrono::milliseconds(100)})
Runs phase resistance measurement (OS command 8) and decodes the value it reports.
Definition somanet_drive.cc:1457
std::expected< BrakeState, std::string > brakeState() const
Reads the whole brake configuration and its current state in one call.
Definition somanet_drive.cc:819
std::expected< FullFirmwareDescriptors, std::string > readFullFirmwareDescriptors() const
Reads both files and assembles the descriptors this drive accepts firmware under.
Definition somanet_drive.cc:1188
std::expected< std::vector< DeviceFile >, std::string > readFileList() const
Reads the list of files stored on the device (FoE read of "fs-getlist").
Definition somanet_drive.cc:1133
std::expected< void, std::string > startHrdStream(const OsCommandConfig &config)
Starts the configured high resolution data stream and waits for it to finish (OS command 3,...
Definition somanet_drive.cc:1116
std::expected< TriggerErrorResult, std::string > triggerError(somanet::FirmwareService service, somanet::FirmwareErrorType type, const OsCommandConfig &config={.timeout=std::chrono::seconds(3),.pollInterval=std::chrono::milliseconds(20)})
Provokes a firmware error or exception in a control service (OS command 16).
Definition somanet_drive.cc:1941
std::expected< CommutationOffsetResult, std::string > runCommutationOffsetMeasurement(somanet::CommutationOffsetMethod method, const OsCommandConfig &config={.timeout=std::chrono::seconds(60),.pollInterval=std::chrono::milliseconds(100)})
Runs commutation offset measurement (OS command 5) and decodes the offset it reports.
Definition somanet_drive.cc:1411
std::expected< std::optional< IntegroVariant >, std::string > readIntegroVariant() const
Reads and parses the drive's .variant file (FoE).
Definition somanet_drive.cc:1165
std::expected< BrakeState, std::string > engageBrake(std::chrono::milliseconds settle=std::chrono::milliseconds(50))
Engages the brake and waits settle for it to bite.
Definition somanet_drive.cc:880
std::expected< void, std::string > setIgnoreBissStatusBits(somanet::EncoderOrdinal encoder, bool ignore, const OsCommandConfig &config={.timeout=std::chrono::seconds(30),.pollInterval=std::chrono::milliseconds(20)})
Starts or stops ignoring a BiSS encoder's status bits (OS command 14).
Definition somanet_drive.cc:1586
SomanetDrive(Device &device)
Binds an (unchecked) SOMANET view to device. Prefer createSomanetDrive.
Definition somanet_drive.h:1563
std::expected< FirmwareLatencyResult, std::string > readMaximumFirmwareLatency(somanet::FirmwareLatency latency, const OsCommandConfig &config={.timeout=std::chrono::seconds(5),.pollInterval=std::chrono::milliseconds(20)})
Reads and clears one firmware latency's recorded maximum (OS command 22, action 1).
Definition somanet_drive.cc:1895
std::expected< FirmwareCompatibility, std::string > checkFirmwarePackage(std::string_view packageFilename) const
Reads what this drive is and decides whether packageFilename belongs on it.
Definition somanet_drive.cc:1201
std::expected< OsCommandResponse, std::string > runOsCommand(const std::vector< uint8_t > &command, const OsCommandConfig &config={}, const OsCommandFsBuffer &fsBuffer={})
Issues an OS command (0x1023) and blocks until the drive reports it finished.
Definition somanet_drive.cc:479
std::expected< void, std::string > setIcMuCalibrationMode(somanet::EncoderOrdinal encoder, somanet::IcMuCalibrationMode mode, const OsCommandConfig &config={.timeout=std::chrono::seconds(5),.pollInterval=std::chrono::milliseconds(20)})
Sets an iC-MU encoder's calibration mode (OS command 1).
Definition somanet_drive.cc:898
std::expected< void, std::string > setSystemIdentificationParameter(somanet::SystemIdentificationParameter parameter, uint32_t value, const OsCommandConfig &config={.timeout=std::chrono::seconds(5),.pollInterval=std::chrono::milliseconds(20)})
Writes one system-identification setting (OS command 15).
Definition somanet_drive.cc:1978
std::expected< OpenPhaseResult, std::string > runOpenPhaseDetection(const OsCommandConfig &config={.timeout=std::chrono::seconds(10),.pollInterval=std::chrono::milliseconds(100)})
Runs open phase detection (OS command 6) and decodes its verdict.
Definition somanet_drive.cc:1316
std::expected< HrdRecording, std::string > readHrdRecording(somanet::HrdData data) const
Reads the drive's high resolution data files back and decodes them (FoE, no OS command).
Definition somanet_drive.cc:1220
std::expected< ObjectDictionaryValues, std::string > readObjectDictionaryValues(const OsCommandConfig &config={})
Reads every object dictionary value the drive holds, in one transfer (OS command 21).
Definition somanet_drive.cc:766
std::expected< EncoderRegisterResult, std::string > readEncoderRegister(somanet::EncoderOrdinal encoder, uint8_t registerAddress, const OsCommandConfig &config={.timeout=std::chrono::seconds(5),.pollInterval=std::chrono::milliseconds(20)})
Reads one register of an encoder (OS command 0, read direction).
Definition somanet_drive.cc:1282
std::expected< void, std::string > setOperationMode(somanet::OperationMode mode)
Requests one of SOMANET's manufacturer-specific operation modes (0x6060).
Definition somanet_drive.cc:2017
std::expected< void, std::string > stopFirmwareLatencyMeasurements(const OsCommandConfig &config={.timeout=std::chrono::seconds(5),.pollInterval=std::chrono::milliseconds(20)})
Stops measuring both firmware latencies (OS command 22, action 2).
Definition somanet_drive.cc:1921
std::expected< void, std::string > startFirmwareLatencyMeasurement(somanet::FirmwareLatency latency, const OsCommandConfig &config={.timeout=std::chrono::seconds(5),.pollInterval=std::chrono::milliseconds(20)})
Starts measuring one internal firmware latency (OS command 22, action 0).
Definition somanet_drive.cc:1879
std::expected< std::string, std::string > errorReport() const
Reads the drive's description of its most recent fault (0x203F:01).
Definition somanet_drive.cc:802
std::expected< PolePairResult, std::string > runPolePairDetection(const OsCommandConfig &config={.timeout=std::chrono::seconds(60),.pollInterval=std::chrono::milliseconds(100)})
Runs pole pair detection (OS command 7) and decodes the count it reports.
Definition somanet_drive.cc:1434
std::expected< TorqueConstantResult, std::string > runTorqueConstantMeasurement(const OsCommandConfig &config={.timeout=std::chrono::seconds(60),.pollInterval=std::chrono::milliseconds(100)})
Runs torque constant measurement (OS command 10) and decodes the value it reports.
Definition somanet_drive.cc:1504
std::expected< void, std::string > setVelocitySource(somanet::VelocitySource source, const OsCommandConfig &config={.timeout=std::chrono::seconds(5),.pollInterval=std::chrono::milliseconds(20)})
Chooses where the velocity control loop takes its feedback from (OS command 18).
Definition somanet_drive.cc:1752
std::expected< somanet::BrakeStatus, std::string > brakeStatus() const
Reads the brake state (0x2004:07).
Definition somanet_drive.cc:806
std::expected< somanet::CommutationOffsetMethod, std::string > commutationOffsetMethod() const
Reads which commutation offset method is configured (0x2009:03).
Definition somanet_drive.cc:1395
What a SOMANET firmware package is, offline: how its filename decodes, what its zip holds,...
std::optional< ChirpSignalType > parseChirpSignalType(std::string_view token)
Parses a signal-type token ("logarithmic" / "linear"). std::nullopt for any other.
Definition somanet_drive.cc:375
std::optional< FirmwareLatency > parseFirmwareLatency(std::string_view token)
Parses a firmware latency token ("setpoint" / "feedback"). std::nullopt otherwise.
Definition somanet_drive.cc:408
constexpr bool requiresBrakeReleased(CommutationOffsetMethod method)
Whether the method needs the brake released, as opposed to engaged.
Definition somanet_drive.h:133
constexpr uint32_t kMaxChirpTransitionTimeMs
20 s.
Definition somanet_drive.h:523
CommutationOffsetMethod
How commutation offset measurement (command 5) is performed (0x2009:03).
Definition somanet_drive.h:96
OpenPhaseFault
The faults open phase detection (command 6) reports, as its command-specific OS error code.
Definition somanet_drive.h:772
@ kOpenFetCHigh
Upper FET in leg C is not conducting (open circuit fault).
@ kOpenFetCLow
Lower FET in leg C is not conducting (open circuit fault).
@ kOpenTerminalA
Terminal A of the drive is not connected.
@ kOpenFetALow
Lower FET in leg A is not conducting (open circuit fault).
@ kOpenTerminalB
Terminal B of the drive is not connected.
@ kOpenFetBHigh
Upper FET in leg B is not conducting (open circuit fault).
@ kOpenFetAHigh
Upper FET in leg A is not conducting (open circuit fault).
@ kOpenFetBLow
Lower FET in leg B is not conducting (open circuit fault).
@ kOpenTerminalC
Terminal C of the drive is not connected.
IcMuCalibrationMode
How the BiSS service clocks and interprets an iC-MU encoder (OS command 1). The enum value is the "mo...
Definition somanet_drive.h:165
@ kStandard
Normal clocking — the mode an encoder runs in when nothing is being calibrated.
constexpr size_t hrdSampleSize(HrdData data)
How many bytes one recorded sample of data occupies in the drive's files.
Definition somanet_drive.h:608
FirmwareService
One of the drive's two independently-scheduled control loops, as the firmware's FirmwareServiceId nam...
Definition somanet_drive.h:205
@ kMotionControl
The position/velocity loop above it.
@ kDriveControl
The current/torque loop — the fast one, period per 0x60C2.
constexpr bool isDeprecated(OperationMode mode)
Whether the firmware marks mode as deprecated — true for system identification alone,...
Definition somanet_drive.h:960
OsCommandId
OS command IDs (byte 0 of 0x1023:01).
Definition somanet_drive.h:743
@ kSystemIdentification
Configures and triggers the system-identification chirp.
@ kTorqueConstantMeasurement
Measures the motor's torque constant. Rotates the rotor.
@ kMotorPhaseOrderDetection
Detects the motor phase order. Rotates the rotor.
@ kPolePairDetection
Detects the motor's pole pair count. Rotates the rotor.
@ kReadObjectDictionary
Sends every object dictionary value at once. No motion.
@ kKueblerRegisterCommunication
Reads or writes an Integro internal encoder register.
@ kOpenPhaseDetection
Checks every motor phase and FET leg for an open circuit.
@ kCommutationOffsetMeasurement
@ kIgnoreBissStatusBits
Suppresses a BiSS encoder's own error and warning bits.
@ kIcMuCalibrationMode
Sets how the BiSS service clocks an iC-MU encoder.
@ kMeasureFirmwareLatency
Measures a duration inside the drive control cycle.
@ kTriggerError
Provokes a firmware error or exception. Test tool only.
@ kPhaseResistanceMeasurement
Measures the motor's phase resistance, in milliohms.
@ kHrdStreaming
Records a signal into the drive's high resolution data files.
@ kPhaseInductanceMeasurement
Measures the motor's phase inductance, in microhenries.
@ kEncoderRegisterCommunication
Reads or writes one register of a BiSS encoder.
@ kVelocitySource
Chooses where the velocity loop's feedback comes from.
constexpr std::string_view toString(IcHausChip chip)
Name of a chip, as the console and logs should render it. Never returns nullptr.
Definition ic_haus_registers.h:53
constexpr std::string_view describe(EncoderRegisterFault fault)
What an encoder register fault means, for a message a user has to act on. Never nullptr.
Definition somanet_drive.h:549
EncoderRegisterFault
The faults encoder register communication (command 0) reports as its command-specific OS error code.
Definition somanet_drive.h:530
@ kInvalidResponse
The register transaction failed inside the encoder service.
@ kRegisterNotAllowed
The register cannot be accessed while the firmware is using it.
std::optional< VelocitySource > parseVelocitySource(std::string_view token)
Parses a velocity source token ("firmware" / "encoder"). std::nullopt otherwise.
Definition somanet_drive.cc:398
constexpr std::chrono::milliseconds maxHrdStreamDuration(HrdData data)
The longest stream the drive will record for data.
Definition somanet_drive.h:619
ErrorReportEntry
Sub-entries of 0x203F (error report). The enum value is the subindex.
Definition somanet_drive.h:40
@ kErrorReportDescription
STRING — what the drive says about its most recent fault.
Definition somanet_drive.h:41
EncoderOrdinal
Which of a drive's two encoders a command addresses. The enum value is the ordinal the firmware expec...
Definition somanet_drive.h:144
@ kEncoder1
The encoder configured in 0x2110.
@ kEncoder2
The encoder configured in 0x2112.
Object
Manufacturer-specific object indices (the 0x2000-0x5FFF vendor range).
Definition somanet_drive.h:31
@ kMotorSpecificSettings
RECORD — motor configuration; :05 is the phase order.
Definition somanet_drive.h:33
@ kCommutationAngleOffset
INTEGER16 — the offset command 5 measures and writes.
Definition somanet_drive.h:32
@ kBrakeOptions
RECORD — brake voltages, timing, release strategy, status.
Definition somanet_drive.h:34
@ kCommutationOffsetDetection
RECORD — how commutation offset (5) is measured.
Definition somanet_drive.h:35
@ kErrorReport
RECORD — :01 describes the drive's most recent fault.
Definition somanet_drive.h:36
std::optional< HrdData > parseHrdData(std::string_view token)
Parses an HRD data token ("encoder-raw" / "system-identification") — the inverse of toString....
Definition somanet_drive.cc:365
BrakeOption
Sub-entries of 0x2004 (brake options). The enum value is the subindex.
Definition somanet_drive.h:677
@ kBrakePullVoltage
UNSIGNED32, mV — voltage that disengages the brake.
Definition somanet_drive.h:678
@ kBrakeStatus
UNSIGNED8 — reports and commands the brake; see BrakeStatus.
Definition somanet_drive.h:684
@ kBrakeReleaseStrategy
UNSIGNED8 — how the brake is driven; see BrakeReleaseStrategy.
Definition somanet_drive.h:681
@ kBrakeControllerDisableDelay
UNSIGNED16, ms — engage-to-controller-off delay.
Definition somanet_drive.h:682
@ kBrakePinInitialDirection
INTEGER8 — which way a pin-brake release moves first.
Definition somanet_drive.h:693
@ kBrakeDcBusVoltage
UNSIGNED16 — deprecated; the drive still lists it.
Definition somanet_drive.h:683
@ kBrakeMinimumDisplacement
UNSIGNED32 — pin-brake release travel threshold.
Definition somanet_drive.h:685
@ kBrakePullTime
UNSIGNED16, ms — how long the pull voltage is applied.
Definition somanet_drive.h:680
@ kBrakeHoldVoltage
UNSIGNED32, mV — lower voltage that keeps it disengaged.
Definition somanet_drive.h:679
@ kBrakeSwitchingFrequency
UNSIGNED8 — phase-D PWM rate (0: 16, 1: 32, 2: 64 kHz).
Definition somanet_drive.h:692
@ kBrakeOutputVoltage
UNSIGNED16, mV — phase-D voltage in manual mode.
Definition somanet_drive.h:691
@ kBrakePinCurrentPercent
Definition somanet_drive.h:689
MotorPhaseOrder
Which way round the motor's phases are wired, as motor phase order detection (command 4) reports it a...
Definition somanet_drive.h:839
@ kNormal
Sensor and rotor angles change in the same direction.
@ kInverted
They change in opposite directions.
BrakeStatus
Brake state (0x2004:07), which both reports the brake and commands it when written.
Definition somanet_drive.h:707
@ kEngaged
Holding. A brake is spring-engaged, so this is its powered-off state.
@ kNotConfigured
No brake configured.
constexpr FirmwareErrorType kFirmwareErrorTypes[]
Every firmware error type, ascending.
Definition somanet_drive.h:417
VelocitySource
Where the velocity control loop takes its feedback from (OS command 18). The enum value is the trigge...
Definition somanet_drive.h:267
constexpr FirmwareErrorEffect effectOf(FirmwareErrorType type)
What type does, from the firmware's own case bodies rather than from its name.
Definition somanet_drive.h:361
ChirpSignalType
Which excitation the system-identification run sweeps with (parameter 4).
Definition somanet_drive.h:462
@ kLogarithmic
Logarithmic frequency sweep whose amplitude rises with it, from half the target to the target.
@ kLinear
Linear frequency sweep at a constant amplitude.
std::optional< FirmwareService > parseFirmwareService(std::string_view token)
Parses a service token ("drive-control" / "motion-control") — the inverse of toString....
Definition somanet_drive.cc:427
constexpr uint32_t kMinChirpTransitionTimeMs
1 s.
Definition somanet_drive.h:522
std::optional< FirmwareErrorType > parseFirmwareErrorType(std::string_view token)
Parses a firmware error type token — the inverse of toString.
Definition somanet_drive.cc:418
MotorMeasurementFault
The faults the current-injecting motor measurements report as their command-specific OS error code — ...
Definition somanet_drive.h:863
@ kCurrentAmplitudeError
The drive could not reach the current amplitude it needed.
constexpr uint32_t kMinChirpFrequencyMilliHz
The bounds the firmware enforces on a chirp configuration.
Definition somanet_drive.h:520
KueblerRegisterFault
What the Kübler encoder reported when a register access failed (OS command 19).
Definition somanet_drive.h:230
@ kAsyncInProgress
The encoder's asynchronous channel is busy with something else.
@ kInvalidRegisterLength
The length byte was below 1 or above 4.
@ kEncoderTimeout
The encoder returned no value within 10 ms. Reads only.
CommutationOffsetSetting
Sub-entries of 0x2009 (commutation offset detection). The enum value is the subindex.
Definition somanet_drive.h:75
@ kCommutationOffsetKi
REAL32 — phasing controller Ki; method 1 only.
Definition somanet_drive.h:86
@ kCommutationOffsetMethod
INTEGER8 — which method runs; see CommutationOffsetMethod.
Definition somanet_drive.h:84
@ kCommutationOffsetKp
REAL32 — phasing controller Kp; method 1 only.
Definition somanet_drive.h:85
@ kCommutationOffsetState
INTEGER16 — set to OFFSET_VALID by a successful command 5.
Definition somanet_drive.h:76
@ kCommutationOffsetKd
REAL32 — phasing controller Kd; method 1 only.
Definition somanet_drive.h:87
@ kCommutationOffsetAppliedTorquePercent
Definition somanet_drive.h:82
BrakeReleaseStrategy
How the brake is driven (0x2004:04).
Definition somanet_drive.h:700
@ kManualOutputVoltage
Not firmware-controlled — a raw phase-D voltage (0x2004:10).
@ kClutch
Standard brake: pull voltage for the pull time, then hold voltage.
@ kPin
Pin brake — releasing it moves the shaft (see releaseBrake).
constexpr uint32_t kMaxChirpFrequencyMilliHz
1000 Hz.
Definition somanet_drive.h:521
HrdStreamFault
The faults HRD streaming (command 3) reports as its command-specific OS error code.
Definition somanet_drive.h:628
@ kInitialization
The command could not initialise.
@ kDataIndex
The requested data index is not one the drive knows.
@ kDuration
The requested duration is above the limit for the chosen data index.
@ kStreaming
Something failed while the stream was running.
@ kAction
The requested action is neither configure nor start.
SystemIdentificationParameter
The settings of the system-identification chirp (OS command 15). The enum value is the parameter inde...
Definition somanet_drive.h:432
@ kTargetFrequency
Where it ends, in mHz. Must not be below the start frequency.
@ kStartFrequency
Where the sweep begins, in mHz.
@ kTargetAmplitude
Peak excitation, in per-mille of rated torque. See the note below.
@ kSignalType
Which chirp; see ChirpSignalType.
@ kStartProcedure
Arms the run; see SystemIdentificationStart.
@ kTransitionTime
How long the sweep takes, in ms.
SystemIdentificationStart
What writing parameter 5 does — arm the run, and on what trigger.
Definition somanet_drive.h:484
FirmwareLatency
Which internal firmware latency OS command 22 measures. The enum value is the latency index byte the ...
Definition somanet_drive.h:297
std::optional< SystemIdentificationStart > parseSystemIdentificationStart(std::string_view token)
Parses a start token ("none" / "immediately" / "after-hrd-stream-start").
Definition somanet_drive.cc:385
FirmwareErrorType
The errors OS command 16 can provoke in a firmware service. The enum value is the error-type byte the...
Definition somanet_drive.h:329
@ kResourceDependency
ET_RESOURCE_DEP. Not implemented.
@ kIllegalResource
ET_ILLEGAL_RESOURCE. Not implemented.
@ kIllegalPc
ET_ILLEGAL_PC. Not implemented.
@ kLinkError
ET_LINK_ERROR. Not implemented by the firmware.
@ kKcall
ET_KCALL. Not implemented.
@ kResettableFirmwareError
@ kArithmetic
ET_ARITHMETIC, by dividing by zero. Stops the service.
@ kIllegalPs
ET_ILLEGAL_PS. Not implemented.
@ kEcall
ET_ECALL, by an out-of-bounds array index. Stops the service.
@ kLoadStore
ET_LOAD_STORE, by an unaligned 64-bit store. Stops the service.
@ kIllegalInstruction
ET_ILLEGAL_INSTRUCTION. Not implemented.
FirmwareErrorEffect
What a firmware error type actually does on this firmware — which is not what every one of them is na...
Definition somanet_drive.h:348
@ kRaisesResettableError
A resettable error is reported and the drive reacts as 0x605A says. Recoverable.
std::optional< IcMuCalibrationMode > parseIcMuCalibrationMode(std::string_view token)
Parses a mode token ("configuration" / "raw" / "standard") — the inverse of toString....
Definition somanet_drive.cc:437
MotorSetting
Sub-entries of 0x2003 (motor specific settings). The enum value is the subindex.
Definition somanet_drive.h:50
@ kMotorPolePairs
UNSIGNED8 — where a pole pair count (command 7) belongs.
Definition somanet_drive.h:51
@ kMotorTorqueConstant
Definition somanet_drive.h:56
@ kMotorPhasesInverted
BOOLEAN — the phase order motor phase order detection (4) writes.
Definition somanet_drive.h:67
@ kMotorPhaseResistance
Definition somanet_drive.h:61
@ kMotorPhaseInductance
Definition somanet_drive.h:66
constexpr OperationMode kOperationModes[]
Every SOMANET operation mode, ascending — the manufacturer half of a mode list.
Definition somanet_drive.h:949
HrdData
Which signal a high resolution data (HRD) stream records — OS command 3's data index....
Definition somanet_drive.h:577
@ kSystemIdentificationData
OperationMode
SOMANET's manufacturer-specific operation modes — the negative half of 0x6060, which CiA402 leaves to...
Definition somanet_drive.h:895
@ kSystemIdentification
System identification mode. Deprecated by the firmware.
@ kCoggingCompensationRecording
Cogging torque table recording.
@ kImpedance
Impedance mode.
@ kOpenLoopField
Open loop field control mode.
@ kJointTorque
Joint torque mode.
Definition bus_health_source.h:7
HrdSamples decodeHrdSamples(std::span< const uint8_t > bytes, somanet::HrdData data)
Decodes the concatenated contents of a recording's files into samples.
Definition somanet_drive.cc:1045
std::variant< int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, float, double, std::string, std::vector< uint8_t > > DeviceParameterValue
Decoded value of a single device parameter (CoE object dictionary entry).
Definition device_parameter.h:33
std::expected< void, std::string > removeDeviceFile(Device &device, const std::string &filename)
Deletes a file from a SOMANET drive's flash (FoE read of "fs-remove=<filename>").
Definition somanet_drive.cc:1142
std::string_view toString(FirmwareMatch match)
What a match is called, for a message or a JSON body: "none", "assembly", "device".
Definition firmware_package.cc:295
OsCommandError
The general OS error codes — the ones any command can report, counting down from 254....
Definition somanet_drive.h:985
@ kReserved
Reserved for future expansion of the feature.
@ kNotAllowed
Preconditions not met (wrong mode of operation, say).
std::variant< std::vector< HrdEncoderSample >, std::vector< HrdSystemIdentificationSample > > HrdSamples
A decoded recording's samples: exactly one vector, whichever the data selection implies.
Definition somanet_drive.h:1289
std::vector< std::string_view > hrdColumns(somanet::HrdData data)
The column names of one decoded sample of data, in the order a row carries them.
Definition somanet_drive.cc:982
constexpr size_t kOsCommandSize
Byte length of the OS command and response octet strings (0x1023:01 / 0x1023:03). Manufacturer-specif...
Definition somanet_drive.h:969
std::vector< DeviceFile > parseDeviceFileList(std::string_view text)
Parses the body of a fs-getlist read into one entry per line.
Definition somanet_drive.cc:936
void to_json(nlohmann::json &j, const Cia402Status &s)
Serialises a Cia402Status. Emits state/modeName as human-readable strings alongside the numeric statu...
Definition cia402_drive.cc:13
std::optional< FsBufferTransfer > parseFsBufferTransfer(std::string_view token)
Reads an fs-buffer direction back from its name. std::nullopt if token names none.
Definition somanet_drive.cc:452
std::string toCsv(const HrdRecording &recording)
Renders a recording as CSV: one header row of column names, then one row per sample.
Definition somanet_drive.cc:1015
FsBufferTransfer
Which way an OS command's fs-buffer transfer moves bytes.
Definition somanet_drive.h:1035
@ kNone
The command uses no fs-buffer. The default.
@ kRead
Read what the command writes (an FoE read of kFsBufferFilename).
@ kWrite
Send the command what it needs (an FoE write of kFsBufferFilename).
@ kFailed
Finished badly; ProgressStep::error says why.
constexpr std::string_view kFsBufferFilename
The FoE filename that moves bulk data for an OS command.
Definition somanet_drive.h:1032
OsCommandStatus
Terminal OS command status — byte 0 of the response (0x1023:03), which the firmware mirrors from 0x10...
Definition somanet_drive.h:974
@ kFailedWithData
Completed with error, OS error code and response data available.
@ kCompleted
Completed, no error, no response data.
@ kFailed
Completed with error, no response data.
@ kCompletedWithData
Completed, no error, response data available.
constexpr std::array< uint32_t, 1 > kObjectsOutsideOdValues
The entries a SOMANET drive answers for over CoE that OS command 21 does not carry.
Definition somanet_drive.h:1124
constexpr uint32_t makeParameterKey(uint16_t index, uint8_t subindex)
Packs an object dictionary index and subindex into a single 32-bit key.
Definition device_parameter.h:38
std::expected< ObjectDictionaryValues, std::string > decodeObjectDictionaryValues(std::span< const uint8_t > data, const std::vector< DeviceParameter > &definitions)
Splits what OS command 21 sent into one value per entry of definitions.
Definition somanet_drive.cc:711
std::expected< SomanetDrive, std::string > createSomanetDrive(Device &device)
Validates that device is a SOMANET drive, then binds a view to it.
Definition somanet_drive.cc:2021
std::optional< std::string_view > osCommandErrorName(uint8_t code)
Names a general OS error code, or std::nullopt when code is command-specific.
Definition somanet_drive.cc:462
@ kNone
Neither — the package is for other hardware.
bool releaseBrake
Definition somanet_procedures.cc:436
The brake's configuration and its current state — one read of the parts of 0x2004 that decide what a ...
Definition somanet_drive.h:1184
somanet::BrakeReleaseStrategy releaseStrategy
0x2004:04.
Definition somanet_drive.h:1186
bool softwareControllable() const
Whether the firmware drives the brake, i.e. whether commanding 0x2004:07 does anything....
Definition somanet_drive.h:1194
somanet::BrakeStatus status
0x2004:07.
Definition somanet_drive.h:1185
uint32_t holdVoltageMv
0x2004:02.
Definition somanet_drive.h:1190
std::chrono::milliseconds pullTime
0x2004:03.
Definition somanet_drive.h:1188
uint32_t pullVoltageMv
0x2004:01.
Definition somanet_drive.h:1189
bool releaseMovesShaft() const
Whether releasing this brake turns the motor — true only for a pin brake, whose release procedure lif...
Definition somanet_drive.h:1200
What commutation offset measurement (command 5) measured.
Definition somanet_drive.h:1383
std::string describe() const
One line describing the measurement, ready to put in front of a user.
Definition somanet_drive.cc:1384
somanet::CommutationOffsetMethod method
The method the measurement ran under, which decides whether the rotor turned.
Definition somanet_drive.h:1387
int16_t angleOffset
The measured offset, signed as the drive's own 0x2001 is.
Definition somanet_drive.h:1384
One file stored on a device, as its file list reports it.
Definition somanet_drive.h:1225
std::string name
Filename as FoE addresses it, e.g. "hr_data0.bin".
Definition somanet_drive.h:1226
std::optional< size_t > byteCount
Size the device reported, when it reported one.
Definition somanet_drive.h:1227
What one encoder register access did — the result of both a read and a write, since the drive answers...
Definition somanet_drive.h:1210
std::optional< uint8_t > value
What the register holds, when the drive reported it.
Definition somanet_drive.h:1214
somanet::EncoderOrdinal encoder
Which encoder answered.
Definition somanet_drive.h:1211
uint8_t registerAddress
The register accessed.
Definition somanet_drive.h:1212
std::string describe() const
One line describing the access, ready to put in front of a user.
Definition somanet_drive.cc:1263
bool wrote
Whether this was a write; false for a read.
Definition somanet_drive.h:1213
The maximum one firmware latency reached, as command 22 reported it.
Definition somanet_drive.h:1525
uint32_t configuredNanoseconds
Definition somanet_drive.h:1537
uint32_t maximumNanoseconds
Definition somanet_drive.h:1533
somanet::FirmwareLatency latency
Which latency.
Definition somanet_drive.h:1526
std::string describe() const
One line describing the reading, ready to put in front of a user.
Definition somanet_drive.cc:1782
One sample of somanet::HrdData::kEncoderRawData.
Definition somanet_drive.h:1269
uint16_t masterCount
Bits 0-13: the master track's count.
Definition somanet_drive.h:1271
uint16_t noniusCount
Bits 14-27: the nonius track's count.
Definition somanet_drive.h:1272
uint32_t raw
The 32-bit word as the file holds it.
Definition somanet_drive.h:1270
One high resolution data recording, read back from the drive's files and decoded.
Definition somanet_drive.h:1297
somanet::HrdData data
Which signal this recorded.
Definition somanet_drive.h:1298
size_t byteCount
Total bytes read across them.
Definition somanet_drive.h:1300
size_t trailingBytes
Bytes past the last whole sample; padding, not data.
Definition somanet_drive.h:1301
size_t sampleCount() const
How many samples were decoded, whichever format they are in.
Definition somanet_drive.cc:989
HrdSamples samples
The decoded samples.
Definition somanet_drive.h:1302
std::vector< DeviceFile > files
The files it was read from, in order.
Definition somanet_drive.h:1299
One sample of somanet::HrdData::kSystemIdentificationData.
Definition somanet_drive.h:1276
int16_t torquePermil
The torque actual value, in per mille of rated torque — the file's own unit.
Definition somanet_drive.h:1281
double velocityRpm
The velocity actual value, converted from the file's Q15 fixed point to real RPM.
Definition somanet_drive.h:1278
What one Kübler register access produced (command 19).
Definition somanet_drive.h:1489
std::vector< uint8_t > bytes
Definition somanet_drive.h:1500
uint8_t length
Bytes transferred, 1 to 4.
Definition somanet_drive.h:1491
uint32_t value
Definition somanet_drive.h:1506
uint8_t address
The register accessed.
Definition somanet_drive.h:1490
bool wrote
Whether this was a write; the drive echoes the value either way.
Definition somanet_drive.h:1492
std::string describe() const
One line describing the access, ready to put in front of a user.
Definition somanet_drive.cc:1658
What motor phase order detection (command 4) found.
Definition somanet_drive.h:1367
somanet::MotorPhaseOrder order
What the drive detected.
Definition somanet_drive.h:1368
bool inverted() const
Whether the phases are inverted — the one bit a caller normally branches on.
Definition somanet_drive.h:1371
std::string describe() const
One line describing the finding, ready to put in front of a user.
Definition somanet_drive.cc:1351
One object dictionary entry, as OS command 21 delivered it.
Definition somanet_drive.h:1129
DeviceParameterValue value
Definition somanet_drive.h:1132
uint8_t subindex
CoE object subindex.
Definition somanet_drive.h:1131
uint16_t index
CoE object index.
Definition somanet_drive.h:1130
Every object dictionary value the drive holds, read in one transfer by OS command 21.
Definition somanet_drive.h:1151
size_t byteCount
Bytes the drive sent. Equals the widths of values added up.
Definition somanet_drive.h:1152
std::vector< ObjectDictionaryValue > values
Definition somanet_drive.h:1153
What open phase detection found.
Definition somanet_drive.h:1349
std::optional< uint8_t > faultCode
The raw code, present whenever phaseOpened.
Definition somanet_drive.h:1355
std::optional< somanet::OpenPhaseFault > fault
Definition somanet_drive.h:1354
std::string describe() const
One line describing the finding, ready to put in front of a user.
Definition somanet_drive.cc:1293
bool phaseOpened
True when the drive found an open phase.
Definition somanet_drive.h:1350
Timing and cancellation for SomanetDrive::runOsCommand.
Definition somanet_drive.h:1096
std::stop_token stop
Requesting a stop aborts the command; default never stops.
Definition somanet_drive.h:1102
std::chrono::milliseconds timeout
Ceiling on the whole command.
Definition somanet_drive.h:1097
std::chrono::milliseconds pollInterval
Delay between response polls.
Definition somanet_drive.h:1099
std::chrono::milliseconds abortTimeout
Time allowed to confirm a forced abort.
Definition somanet_drive.h:1101
An OS command's fs-buffer transfer — the data that does not fit in the 8 command bytes.
Definition somanet_drive.h:1078
FsBufferTransfer transfer
What to move; kNone moves nothing.
Definition somanet_drive.h:1079
std::vector< uint8_t > payload
What to send. Read by kWrite, ignored otherwise.
Definition somanet_drive.h:1080
A completed OS command's response — the decoded form of 0x1023:03.
Definition somanet_drive.h:1010
OsCommandStatus status
Terminal status (response byte 0).
Definition somanet_drive.h:1011
std::vector< uint8_t > data
Service response payload, if any.
Definition somanet_drive.h:1012
bool failed() const
Whether the drive reported the command as failed (status 2 or 3). A failed command is still a respons...
Definition somanet_drive.h:1021
std::optional< uint8_t > errorCode
Definition somanet_drive.h:1013
std::vector< uint8_t > fsBuffer
Definition somanet_drive.h:1016
What phase inductance measurement (command 9) measured.
Definition somanet_drive.h:1428
std::string describe() const
One line describing the measurement, ready to put in front of a user.
Definition somanet_drive.cc:1472
uint32_t microhenries
Phase inductance in µH, exactly as the drive reported it.
Definition somanet_drive.h:1429
What phase resistance measurement (command 8) measured.
Definition somanet_drive.h:1413
uint32_t milliohms
Phase resistance in mΩ, exactly as the drive reported it.
Definition somanet_drive.h:1414
std::string describe() const
One line describing the measurement, ready to put in front of a user.
Definition somanet_drive.cc:1449
What pole pair detection (command 7) found.
Definition somanet_drive.h:1395
std::string describe() const
One line describing the finding, ready to put in front of a user.
Definition somanet_drive.cc:1426
uint8_t polePairs
Pole pairs the drive counted.
Definition somanet_drive.h:1396
What the skipped cycles counter (command 13) reported for one control loop.
Definition somanet_drive.h:1464
std::string describe() const
One line describing the reading, ready to put in front of a user.
Definition somanet_drive.cc:1521
somanet::FirmwareService service
Which loop.
Definition somanet_drive.h:1465
uint32_t skippedCycles
Cycles that loop has skipped since it started.
Definition somanet_drive.h:1466
What torque constant measurement (command 10) measured.
Definition somanet_drive.h:1450
std::string describe() const
One line describing the measurement, ready to put in front of a user.
Definition somanet_drive.cc:1495
int32_t milliNewtonMetresPerAmpere
Torque constant in mNm/A_rms, as the drive reported.
Definition somanet_drive.h:1451
What one trigger-error run did (command 16).
Definition somanet_drive.h:1474
somanet::FirmwareService service
Which service.
Definition somanet_drive.h:1475
somanet::FirmwareErrorType type
What was asked.
Definition somanet_drive.h:1476
bool serviceStopped
Definition somanet_drive.h:1481
somanet::FirmwareErrorEffect effect
Definition somanet_drive.h:1477
std::string describe() const
One line describing what happened, ready to put in front of a user.
Definition somanet_drive.cc:1628