Motion Master 6.0.0-alpha.111
Next-generation motion control software
Loading...
Searching...
No Matches
somanet_drive.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <chrono>
5#include <cstddef>
6#include <cstdint>
7#include <expected>
8#include <nlohmann/json_fwd.hpp>
9#include <optional>
10#include <span>
11#include <stop_token>
12#include <string>
13#include <string_view>
14#include <variant>
15#include <vector>
16
17#include "node/cia402_drive.h"
19
20namespace mm::node {
21
22// Defined in plant_identification.h, which includes this header for the recording's sample type.
23// A caller of readPlantModel includes that header; this one only names the type.
24struct PlantModel;
25
32namespace somanet {
33
47
55
66
68enum class EncoderType : uint8_t {
69 kNone = 0,
70 kHallSensor = 1,
71 kIncremental = 2,
72 kNikonAFormat = 3,
73 kBiss = 4,
74 kInternal = 5,
75 kSsi = 7,
76 kSinCosModule = 9,
77};
78
80constexpr std::string_view toString(EncoderType type) {
81 switch (type) {
83 return "none";
85 return "hallSensor";
87 return "incremental";
89 return "nikonAFormat";
91 return "biss";
93 return "internal";
95 return "ssi";
97 return "sinCosModule";
98 }
99 return "unknown";
100}
101
106
132
152
163enum class CommutationOffsetMethod : uint8_t {
169 kRotating = 0,
170
176 kRotatingTuned = 1,
177
187 kStationary = 2,
188};
189
191constexpr std::string_view toString(CommutationOffsetMethod method) {
192 switch (method) {
194 return "rotating";
196 return "rotatingTuned";
198 return "stationary";
199 }
200 return "unknown";
201}
202
215
223enum class EncoderOrdinal : uint8_t {
224 kEncoder1 = 1,
225 kEncoder2 = 2,
226};
227
229constexpr std::string_view toString(EncoderOrdinal encoder) {
230 switch (encoder) {
232 return "encoder 1";
234 return "encoder 2";
235 }
236 return "unknown encoder";
237}
238
244enum class IcMuCalibrationMode : uint8_t {
249 kConfiguration = 0,
250
253 kRaw = 1,
254
256 kStandard = 2,
257};
258
260constexpr std::string_view toString(IcMuCalibrationMode mode) {
261 switch (mode) {
263 return "configuration";
265 return "raw";
267 return "standard";
268 }
269 return "unknown";
270}
271
274std::optional<IcMuCalibrationMode> parseIcMuCalibrationMode(std::string_view token);
275
284enum class FirmwareService : uint8_t {
285 kDriveControl = 0,
286 kMotionControl = 1,
287};
288
290constexpr std::string_view toString(FirmwareService service) {
291 switch (service) {
293 return "drive-control";
295 return "motion-control";
296 }
297 return "unknown";
298}
299
302std::optional<FirmwareService> parseFirmwareService(std::string_view token);
303
309enum class KueblerRegisterFault : uint8_t {
310 kAsyncInProgress = 0,
312 kEncoderTimeout = 2,
313 kWrongByteCount = 3,
318 kEncoderBusy = 4,
319};
320
322constexpr std::string_view toString(KueblerRegisterFault fault) {
323 switch (fault) {
325 return "the encoder's asynchronous channel is busy with another transaction";
327 return "the register length must be 1 to 4 bytes";
329 return "the encoder did not return a value within 10 ms";
331 return "the encoder answered with a different number of bytes than were asked for";
333 return "the encoder is accessing its flash memory and cannot service this register";
334 }
335 return "unknown fault";
336}
337
346enum class VelocitySource : uint8_t {
350 kFirmware = 0,
354 kEncoder = 1,
355};
356
358constexpr std::string_view toString(VelocitySource source) {
359 switch (source) {
361 return "firmware";
363 return "encoder";
364 }
365 return "unknown";
366}
367
369std::optional<VelocitySource> parseVelocitySource(std::string_view token);
370
376enum class FirmwareLatency : uint8_t {
380 kSetpoint = 0,
384 kFeedback = 1,
385};
386
388constexpr std::string_view toString(FirmwareLatency latency) {
389 switch (latency) {
391 return "setpoint";
393 return "feedback";
394 }
395 return "unknown";
396}
397
399std::optional<FirmwareLatency> parseFirmwareLatency(std::string_view token);
400
408enum class FirmwareErrorType : uint8_t {
409 kLinkError = 0,
410 kIllegalPc = 1,
412 kIllegalResource = 3,
413 kLoadStore = 4,
414 kIllegalPs = 5,
415 kArithmetic = 6,
416 kEcall = 7,
418 kKcall = 9,
419 kEndlessLoop = 10,
424};
425
440
462
464constexpr std::string_view toString(FirmwareErrorType type) {
465 switch (type) {
467 return "link-error";
469 return "illegal-pc";
471 return "illegal-instruction";
473 return "illegal-resource";
475 return "load-store";
477 return "illegal-ps";
479 return "arithmetic";
481 return "ecall";
483 return "resource-dependency";
485 return "kcall";
487 return "endless-loop";
489 return "resettable-firmware-error";
490 }
491 return "unknown";
492}
493
495std::optional<FirmwareErrorType> parseFirmwareErrorType(std::string_view token);
496
506
513enum class SystemIdentificationParameter : uint8_t {
514 kStartFrequency = 0,
515 kTargetFrequency = 1,
516 kTargetAmplitude = 2,
517 kTransitionTime = 3,
518 kSignalType = 4,
519 kStartProcedure = 5,
520};
521
524constexpr std::string_view toString(SystemIdentificationParameter parameter) {
525 switch (parameter) {
527 return "start frequency";
529 return "target frequency";
531 return "target amplitude";
533 return "transition time";
535 return "signal type";
537 return "start the procedure";
538 }
539 return "unknown parameter";
540}
541
543enum class ChirpSignalType : uint8_t {
545 kLogarithmic = 0,
547 kLinear = 1,
548};
549
551constexpr std::string_view toString(ChirpSignalType type) {
552 switch (type) {
554 return "logarithmic";
556 return "linear";
557 }
558 return "unknown";
559}
560
562std::optional<ChirpSignalType> parseChirpSignalType(std::string_view token);
563
565enum class SystemIdentificationStart : uint8_t {
569 kNone = 0,
570 kImmediately = 1,
574};
575
577constexpr std::string_view toString(SystemIdentificationStart start) {
578 switch (start) {
580 return "none";
582 return "immediately";
584 return "after-hrd-stream-start";
585 }
586 return "unknown";
587}
588
590std::optional<SystemIdentificationStart> parseSystemIdentificationStart(std::string_view token);
591
601inline constexpr uint32_t kMinChirpFrequencyMilliHz = 100;
602inline constexpr uint32_t kMaxChirpFrequencyMilliHz = 1'000'000;
603inline constexpr uint32_t kMinChirpTransitionTimeMs = 1'000;
604inline constexpr uint32_t kMaxChirpTransitionTimeMs = 20'000;
605
611enum class EncoderRegisterFault : uint8_t {
612 kInvalidResponse = 0,
614};
615
618constexpr std::string_view toString(EncoderRegisterFault fault) {
619 switch (fault) {
621 return "invalid response";
623 return "register not allowed";
624 }
625 return "unknown";
626}
627
630constexpr std::string_view describe(EncoderRegisterFault fault) {
631 switch (fault) {
633 return "the register communication transaction failed internally, which a BiSS clock "
634 "frequency set too high can cause";
636 return "the register cannot be accessed at the moment, which happens when the firmware is "
637 "itself using it — an iC-MU I2C register while iC-PVL registers are being monitored, "
638 "say";
639 }
640 return "unknown fault";
641}
642
658enum class HrdData : uint8_t {
662 kEncoderRawData = 0,
663
668};
669
671constexpr std::string_view toString(HrdData data) {
672 switch (data) {
674 return "encoder-raw";
676 return "system-identification";
677 }
678 return "unknown";
679}
680
683std::optional<HrdData> parseHrdData(std::string_view token);
684
689constexpr size_t hrdSampleSize(HrdData data) { return data == HrdData::kEncoderRawData ? 4 : 6; }
690
700constexpr std::chrono::milliseconds maxHrdStreamDuration(HrdData data) {
701 return data == HrdData::kEncoderRawData ? std::chrono::milliseconds(10000)
702 : std::chrono::milliseconds(6000);
703}
704
709enum class HrdStreamFault : uint8_t {
710 kInitialization = 0,
711 kStreaming = 1,
712 kDuration = 2,
713 kDataIndex = 3,
714 kAction = 4,
715};
716
719constexpr std::string_view toString(HrdStreamFault fault) {
720 switch (fault) {
722 return "initialization error";
724 return "streaming error";
726 return "duration value";
728 return "data index value";
730 return "action value";
731 }
732 return "unknown";
733}
734
737constexpr std::string_view describe(HrdStreamFault fault) {
738 switch (fault) {
740 return "the drive could not start the recording";
742 return "the recording failed part way through, so whatever reached the drive's files is "
743 "incomplete";
745 return "the requested duration is longer than the drive allows for the chosen data, which is "
746 "10000 ms for encoder raw data and 6000 ms for system identification data";
748 return "the drive does not know the requested data index, which means its firmware records a "
749 "different set of signals than this build expects";
751 return "the drive does not know the requested action, which means its firmware drives HRD "
752 "streaming differently than this build expects";
753 }
754 return "unknown fault";
755}
756
776
781enum class BrakeReleaseStrategy : uint8_t {
783 kClutch = 1,
784 kPin = 2,
785};
786
788enum class BrakeStatus : uint8_t {
789 kNotConfigured = 0,
790 kEngaged = 1,
791 kDisengaged = 2,
792};
793
795constexpr std::string_view toString(BrakeStatus status) {
796 switch (status) {
798 return "notConfigured";
800 return "engaged";
802 return "disengaged";
803 }
804 return "unknown";
805}
806
808constexpr std::string_view toString(BrakeReleaseStrategy strategy) {
809 switch (strategy) {
811 return "manualOutputVoltage";
813 return "clutch";
815 return "pin";
816 }
817 return "unknown";
818}
819
846
853enum class OpenPhaseFault : uint8_t {
854 kOpenTerminalA = 0,
855 kOpenTerminalB = 1,
856 kOpenTerminalC = 2,
857 kOpenFetAHigh = 3,
858 kOpenFetALow = 4,
859 kOpenFetBHigh = 5,
860 kOpenFetBLow = 6,
861 kOpenFetCHigh = 7,
862 kOpenFetCLow = 8,
863};
864
866constexpr std::string_view toString(OpenPhaseFault fault) {
867 switch (fault) {
869 return "open terminal A";
871 return "open terminal B";
873 return "open terminal C";
875 return "open FET A high";
877 return "open FET A low";
879 return "open FET B high";
881 return "open FET B low";
883 return "open FET C high";
885 return "open FET C low";
886 }
887 return "unknown";
888}
889
891constexpr std::string_view describe(OpenPhaseFault fault) {
892 switch (fault) {
894 return "terminal A of the drive is not connected";
896 return "terminal B of the drive is not connected";
898 return "terminal C of the drive is not connected";
900 return "the upper FET in leg A is not conducting (open circuit fault)";
902 return "the lower FET in leg A is not conducting (open circuit fault)";
904 return "the upper FET in leg B is not conducting (open circuit fault)";
906 return "the lower FET in leg B is not conducting (open circuit fault)";
908 return "the upper FET in leg C is not conducting (open circuit fault)";
910 return "the lower FET in leg C is not conducting (open circuit fault)";
911 }
912 return "unknown fault";
913}
914
920enum class MotorPhaseOrder : uint8_t {
921 kNormal = 0,
922 kInverted = 1,
923};
924
926constexpr std::string_view toString(MotorPhaseOrder order) {
927 switch (order) {
929 return "normal";
931 return "inverted";
932 }
933 return "unknown";
934}
935
944enum class MotorMeasurementFault : uint8_t {
946};
947
950constexpr std::string_view toString(MotorMeasurementFault fault) {
951 switch (fault) {
953 return "current amplitude error";
954 }
955 return "unknown";
956}
957
960constexpr std::string_view describe(MotorMeasurementFault fault) {
961 switch (fault) {
963 return "the drive could not raise the motor phase currents to the amplitude it needed, which "
964 "a limited DC-link voltage or a high motor phase impedance can both cause";
965 }
966 return "unknown fault";
967}
968
976enum class OperationMode : int8_t {
977 kImpedance = -6,
978 kJointTorque = -5,
980 kOpenLoopField = -3,
981 kDiagnostics = -2,
984};
985
988constexpr std::string_view toString(OperationMode mode) {
989 switch (mode) {
991 return "Impedance";
993 return "JointTorque";
995 return "SystemIdentification";
997 return "OpenLoopField";
999 return "Diagnostics";
1001 return "CoggingCompensationRecording";
1002 }
1003 return "Unknown";
1004}
1005
1007constexpr std::string_view describe(OperationMode mode) {
1008 switch (mode) {
1010 return "Impedance mode";
1012 return "Joint torque mode";
1014 return "System identification mode";
1016 return "Open loop field mode";
1018 return "Diagnostics mode";
1020 return "Cogging compensation recording mode";
1021 }
1022 return "Unknown mode";
1023}
1024
1038
1041constexpr bool isDeprecated(OperationMode mode) {
1043}
1044
1045} // namespace somanet
1046
1050inline constexpr size_t kOsCommandSize = 8;
1051
1055enum class OsCommandStatus : uint8_t {
1056 kCompleted = 0,
1057 kCompletedWithData = 1,
1058 kFailed = 2,
1059 kFailedWithData = 3,
1060};
1061
1066enum class OsCommandError : uint8_t {
1067 kNotAllowed = 251,
1068 kAborted = 252,
1074 kTimeout = 253,
1075 kUnsupported = 254,
1076 kReserved = 255,
1077};
1078
1083std::optional<std::string_view> osCommandErrorName(uint8_t code);
1084
1093 std::vector<uint8_t> data;
1094 std::optional<uint8_t> errorCode;
1097 std::vector<uint8_t> fsBuffer;
1098
1105};
1106
1113inline constexpr std::string_view kFsBufferFilename = "fs-buffer";
1114
1116enum class FsBufferTransfer : uint8_t {
1117 kNone,
1118 kRead,
1119 kWrite,
1120};
1121
1123constexpr std::string_view toString(FsBufferTransfer transfer) {
1124 switch (transfer) {
1126 return "read";
1128 return "write";
1130 break;
1131 }
1132 return "none";
1133}
1134
1136std::optional<FsBufferTransfer> parseFsBufferTransfer(std::string_view token);
1137
1163
1178 std::chrono::milliseconds timeout{1000};
1179
1180 std::chrono::milliseconds pollInterval{10};
1181
1182 std::chrono::milliseconds abortTimeout{10000};
1183 std::stop_token stop{};
1184};
1185
1205inline constexpr std::array<uint32_t, 1> kObjectsOutsideOdValues{
1206 makeParameterKey(0x10F8, 0x00), // Timestamp Object, served by the EtherCAT stack.
1207};
1208
1215void to_json(nlohmann::json& j, const ObjectDictionaryValue& entry);
1216
1233 size_t byteCount{};
1234 std::vector<ObjectDictionaryValue> values;
1235};
1236void to_json(nlohmann::json& j, const ObjectDictionaryValues& values);
1237
1255std::expected<ObjectDictionaryValues, std::string> decodeObjectDictionaryValues(
1256 std::span<const uint8_t> data, const std::vector<DeviceParameter>& definitions);
1257
1283void to_json(nlohmann::json& j, const BrakeState& state);
1284
1298
1302struct Encoders {
1303 std::vector<EncoderConfiguration> encoders;
1304 std::optional<somanet::EncoderOrdinal> position;
1305 std::optional<somanet::EncoderOrdinal> velocity;
1306 std::optional<somanet::EncoderOrdinal> commutation;
1307};
1308
1309void to_json(nlohmann::json& j, const EncoderConfiguration& encoder);
1310void to_json(nlohmann::json& j, const Encoders& encoders);
1311
1320 uint8_t registerAddress = 0;
1321 bool wrote = false;
1322 std::optional<uint8_t> value;
1323
1325 std::string describe() const;
1326};
1327void to_json(nlohmann::json& j, const EncoderRegisterResult& result);
1328
1334 std::string name;
1335 std::optional<size_t> byteCount;
1336};
1337void to_json(nlohmann::json& j, const DeviceFile& file);
1338
1349std::vector<DeviceFile> parseDeviceFileList(std::string_view text);
1350
1369std::expected<void, std::string> removeDeviceFile(Device& device, const std::string& filename);
1370
1378 uint32_t raw = 0;
1379 uint16_t masterCount = 0;
1380 uint16_t noniusCount = 0;
1381};
1382
1386 double velocityRpm = 0.0;
1387
1389 int16_t torquePermil = 0;
1390};
1391
1397 std::variant<std::vector<HrdEncoderSample>, std::vector<HrdSystemIdentificationSample>>;
1398
1407 std::vector<DeviceFile> files;
1408 size_t byteCount = 0;
1409 size_t trailingBytes = 0;
1411
1413 size_t sampleCount() const;
1414};
1415void to_json(nlohmann::json& j, const HrdRecording& recording);
1416
1426std::string toCsv(const HrdRecording& recording);
1427
1432std::vector<std::string_view> hrdColumns(somanet::HrdData data);
1433
1448HrdSamples decodeHrdSamples(std::span<const uint8_t> bytes, somanet::HrdData data);
1449
1458 bool phaseOpened = false;
1459
1462 std::optional<somanet::OpenPhaseFault> fault;
1463 std::optional<uint8_t> faultCode;
1464
1466 std::string describe() const;
1467};
1468void to_json(nlohmann::json& j, const OpenPhaseResult& result);
1469
1484void to_json(nlohmann::json& j, const MotorPhaseOrderResult& result);
1485
1500void to_json(nlohmann::json& j, const CommutationOffsetResult& result);
1501
1504 uint8_t polePairs = 0;
1505
1507 std::string describe() const;
1508};
1509void to_json(nlohmann::json& j, const PolePairResult& result);
1510
1522 uint32_t milliohms = 0;
1523
1525 std::string describe() const;
1526};
1527void to_json(nlohmann::json& j, const PhaseResistanceResult& result);
1528
1537 uint32_t microhenries = 0;
1538
1540 std::string describe() const;
1541};
1542void to_json(nlohmann::json& j, const PhaseInductanceResult& result);
1543
1560
1562 std::string describe() const;
1563};
1564void to_json(nlohmann::json& j, const TorqueConstantResult& result);
1565
1579void to_json(nlohmann::json& j, const SkippedCyclesResult& result);
1580
1594void to_json(nlohmann::json& j, const TriggerErrorResult& result);
1595
1598 uint8_t address = 0;
1599 uint8_t length = 0;
1600 bool wrote = false;
1601
1608 std::vector<uint8_t> bytes;
1609
1614 uint32_t value = 0;
1615
1617 std::string describe() const;
1618};
1619void to_json(nlohmann::json& j, const KueblerRegisterResult& result);
1620
1650void to_json(nlohmann::json& j, const FirmwareLatencyResult& result);
1651
1669 public:
1672
1721 std::expected<OsCommandResponse, std::string> runOsCommand(
1722 const std::vector<uint8_t>& command, const OsCommandConfig& config = {},
1723 const OsCommandFsBuffer& fsBuffer = {});
1724
1744 std::expected<ObjectDictionaryValues, std::string> readObjectDictionaryValues(
1745 const OsCommandConfig& config = {});
1746
1753 std::expected<std::string, std::string> errorReport() const;
1754
1755 // --- Brake (0x2004) --------------------------------------------------------------------------
1756
1758 std::expected<BrakeState, std::string> brakeState() const;
1759
1761 std::expected<Encoders, std::string> encoders() const;
1762
1764 std::expected<somanet::BrakeStatus, std::string> brakeStatus() const;
1765
1770 std::expected<void, std::string> setBrakeStatus(somanet::BrakeStatus status);
1771
1799 std::expected<BrakeState, std::string> releaseBrake(
1800 std::chrono::milliseconds settle = std::chrono::milliseconds(50));
1801
1810 std::expected<BrakeState, std::string> engageBrake(
1811 std::chrono::milliseconds settle = std::chrono::milliseconds(50));
1812
1813 // --- Vendor operation modes (0x6060) ---------------------------------------------------------
1814
1815 // Keep the inherited standard-mode setter visible: declaring an overload below would otherwise
1816 // hide it, since name lookup stops at the first scope that has a match.
1818
1820 std::expected<void, std::string> setOperationMode(somanet::OperationMode mode);
1821
1822 // --- Typed OS commands -----------------------------------------------------------------------
1823
1844 std::expected<EncoderRegisterResult, std::string> readEncoderRegister(
1845 somanet::EncoderOrdinal encoder, uint8_t registerAddress,
1846 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
1847 .pollInterval = std::chrono::milliseconds(20)});
1848
1867 std::expected<EncoderRegisterResult, std::string> writeEncoderRegister(
1868 somanet::EncoderOrdinal encoder, uint8_t registerAddress, uint8_t value,
1869 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
1870 .pollInterval = std::chrono::milliseconds(20)});
1871
1895 std::expected<void, std::string> setIcMuCalibrationMode(
1897 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
1898 .pollInterval = std::chrono::milliseconds(20)});
1899
1923 std::expected<void, std::string> configureHrdStream(
1924 somanet::HrdData data, std::chrono::milliseconds duration,
1925 const OsCommandConfig& config = {.timeout = std::chrono::seconds(10),
1926 .pollInterval = std::chrono::milliseconds(100)});
1927
1948 std::expected<void, std::string> startHrdStream(const OsCommandConfig& config);
1949
1971 std::expected<HrdRecording, std::string> readHrdRecording(somanet::HrdData data) const;
1972
1984 std::expected<std::vector<DeviceFile>, std::string> readFileList() const;
1985
1998 std::expected<HardwareDescription, std::string> readHardwareDescription() const;
1999
2013 std::expected<std::optional<IntegroVariant>, std::string> readIntegroVariant() const;
2014
2024 std::expected<std::optional<PlantModel>, std::string> readPlantModel() const;
2025
2034 std::expected<FullFirmwareDescriptors, std::string> readFullFirmwareDescriptors() const;
2035
2048 std::expected<FirmwareCompatibility, std::string> checkFirmwarePackage(
2049 std::string_view packageFilename) const;
2050
2073 std::expected<OpenPhaseResult, std::string> runOpenPhaseDetection(
2074 const OsCommandConfig& config = {.timeout = std::chrono::seconds(10),
2075 .pollInterval = std::chrono::milliseconds(100)});
2076
2099 std::expected<MotorPhaseOrderResult, std::string> runMotorPhaseOrderDetection(
2100 const OsCommandConfig& config = {.timeout = std::chrono::seconds(60),
2101 .pollInterval = std::chrono::milliseconds(100)});
2102
2110 std::expected<somanet::CommutationOffsetMethod, std::string> commutationOffsetMethod() const;
2111
2134 std::expected<CommutationOffsetResult, std::string> runCommutationOffsetMeasurement(
2136 const OsCommandConfig& config = {.timeout = std::chrono::seconds(60),
2137 .pollInterval = std::chrono::milliseconds(100)});
2138
2157 std::expected<PolePairResult, std::string> runPolePairDetection(
2158 const OsCommandConfig& config = {.timeout = std::chrono::seconds(60),
2159 .pollInterval = std::chrono::milliseconds(100)});
2160
2181 std::expected<PhaseResistanceResult, std::string> runPhaseResistanceMeasurement(
2182 const OsCommandConfig& config = {.timeout = std::chrono::seconds(30),
2183 .pollInterval = std::chrono::milliseconds(100)});
2184
2197 std::expected<PhaseInductanceResult, std::string> runPhaseInductanceMeasurement(
2198 const OsCommandConfig& config = {.timeout = std::chrono::seconds(30),
2199 .pollInterval = std::chrono::milliseconds(100)});
2200
2229 std::expected<TorqueConstantResult, std::string> runTorqueConstantMeasurement(
2230 const OsCommandConfig& config = {.timeout = std::chrono::seconds(60),
2231 .pollInterval = std::chrono::milliseconds(100)});
2232
2263 std::expected<TriggerErrorResult, std::string> triggerError(
2265 const OsCommandConfig& config = {.timeout = std::chrono::seconds(3),
2266 .pollInterval = std::chrono::milliseconds(20)});
2267
2294 std::expected<KueblerRegisterResult, std::string> accessKueblerRegister(
2295 uint8_t address, uint8_t length, bool write = false, uint32_t value = 0,
2296 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2297 .pollInterval = std::chrono::milliseconds(20)});
2298
2318 std::expected<void, std::string> setVelocitySource(
2320 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2321 .pollInterval = std::chrono::milliseconds(20)});
2322
2340 std::expected<void, std::string> startFirmwareLatencyMeasurement(
2342 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2343 .pollInterval = std::chrono::milliseconds(20)});
2344
2358 std::expected<FirmwareLatencyResult, std::string> readMaximumFirmwareLatency(
2360 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2361 .pollInterval = std::chrono::milliseconds(20)});
2362
2371 std::expected<void, std::string> stopFirmwareLatencyMeasurements(
2372 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2373 .pollInterval = std::chrono::milliseconds(20)});
2374
2402 std::expected<SkippedCyclesResult, std::string> readSkippedCycles(
2404 const OsCommandConfig& config = {.timeout = std::chrono::seconds(30),
2405 .pollInterval = std::chrono::milliseconds(20)});
2406
2435 std::expected<void, std::string> setIgnoreBissStatusBits(
2436 somanet::EncoderOrdinal encoder, bool ignore,
2437 const OsCommandConfig& config = {.timeout = std::chrono::seconds(30),
2438 .pollInterval = std::chrono::milliseconds(20)});
2439
2462 std::expected<void, std::string> setSystemIdentificationParameter(
2463 somanet::SystemIdentificationParameter parameter, uint32_t value,
2464 const OsCommandConfig& config = {.timeout = std::chrono::seconds(5),
2465 .pollInterval = std::chrono::milliseconds(20)});
2466
2467 // SOMANET-specific synchronous object-dictionary accessors are added here as their object
2468 // indices are confirmed (encoder type/resolution, motor pole pairs, commutation offset, ...).
2469 // Each is a thin typed read/write over device(); none holds state.
2470};
2471
2480std::expected<SomanetDrive, std::string> createSomanetDrive(Device& device);
2481
2482} // namespace mm::node
Borrowed view of a CiA402 drive — the device control state machine, operation modes,...
Definition cia402_drive.h:132
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:173
Represents a single node on the fieldbus.
Definition device.h:120
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:1668
std::expected< HardwareDescription, std::string > readHardwareDescription() const
Reads and parses the drive's .hardware_description file (FoE).
Definition somanet_drive.cc:1255
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:1180
std::expected< Encoders, std::string > encoders() const
Reads both encoder configuration records and the encoder each controller uses.
Definition somanet_drive.cc:846
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:1801
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:1479
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:1653
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:1405
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:817
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:1598
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:1575
std::expected< BrakeState, std::string > brakeState() const
Reads the whole brake configuration and its current state in one call.
Definition somanet_drive.cc:917
std::expected< FullFirmwareDescriptors, std::string > readFullFirmwareDescriptors() const
Reads both files and assembles the descriptors this drive accepts firmware under.
Definition somanet_drive.cc:1306
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:1231
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:1214
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:2059
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:1529
std::expected< std::optional< IntegroVariant >, std::string > readIntegroVariant() const
Reads and parses the drive's .variant file (FoE).
Definition somanet_drive.cc:1287
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:978
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:1704
SomanetDrive(Device &device)
Binds an (unchecked) SOMANET view to device. Prefer createSomanetDrive.
Definition somanet_drive.h:1671
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:2013
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:1319
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:482
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:996
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:2096
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:1434
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:1338
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:769
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:1400
std::expected< void, std::string > setOperationMode(somanet::OperationMode mode)
Requests one of SOMANET's manufacturer-specific operation modes (0x6060).
Definition somanet_drive.cc:2135
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:2039
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:1997
std::expected< std::optional< PlantModel >, std::string > readPlantModel() const
Reads and parses the drive's plant_model.csv (FoE), which plant identification writes.
Definition somanet_drive.cc:1269
std::expected< std::string, std::string > errorReport() const
Reads the drive's description of its most recent fault (0x203F:01).
Definition somanet_drive.cc:805
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:1552
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:1622
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:1870
std::expected< somanet::BrakeStatus, std::string > brakeStatus() const
Reads the brake state (0x2004:07).
Definition somanet_drive.cc:809
std::expected< somanet::CommutationOffsetMethod, std::string > commutationOffsetMethod() const
Reads which commutation offset method is configured (0x2009:03).
Definition somanet_drive.cc:1513
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:378
std::optional< FirmwareLatency > parseFirmwareLatency(std::string_view token)
Parses a firmware latency token ("setpoint" / "feedback"). std::nullopt otherwise.
Definition somanet_drive.cc:411
constexpr bool requiresBrakeReleased(CommutationOffsetMethod method)
Whether the method needs the brake released, as opposed to engaged.
Definition somanet_drive.h:212
constexpr uint32_t kMaxChirpTransitionTimeMs
20 s.
Definition somanet_drive.h:604
CommutationOffsetMethod
How commutation offset measurement (command 5) is performed (0x2009:03).
Definition somanet_drive.h:163
OpenPhaseFault
The faults open phase detection (command 6) reports, as its command-specific OS error code.
Definition somanet_drive.h:853
@ 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:244
@ 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:689
FirmwareService
One of the drive's two independently-scheduled control loops, as the firmware's FirmwareServiceId nam...
Definition somanet_drive.h:284
@ 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:1041
OsCommandId
OS command IDs (byte 0 of 0x1023:01).
Definition somanet_drive.h:824
@ 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.
@ 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:630
EncoderRegisterFault
The faults encoder register communication (command 0) reports as its command-specific OS error code.
Definition somanet_drive.h:611
@ 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:401
constexpr std::chrono::milliseconds maxHrdStreamDuration(HrdData data)
The longest stream the drive will record for data.
Definition somanet_drive.h:700
ErrorReportEntry
Sub-entries of 0x203F (error report). The enum value is the subindex.
Definition somanet_drive.h:103
@ kErrorReportDescription
STRING — what the drive says about its most recent fault.
Definition somanet_drive.h:104
ControllerEncoderSource
The sub-entry of each controller record that names its encoder. The enum value is the subindex,...
Definition somanet_drive.h:50
@ kPositionControllerEncoderSource
UNSIGNED8 — 0x2012:09.
Definition somanet_drive.h:53
@ kTorqueControllerEncoderSource
UNSIGNED8 — 0x2010:0C; see EncoderOrdinal, 0 for none.
Definition somanet_drive.h:51
@ kVelocityControllerEncoderSource
UNSIGNED8 — 0x2011:05.
Definition somanet_drive.h:52
EncoderOrdinal
Which of a drive's two encoders a command addresses. The enum value is the ordinal the firmware expec...
Definition somanet_drive.h:223
@ 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:35
@ kVelocityController
RECORD — :05 names the encoder velocity control uses.
Definition somanet_drive.h:41
@ kMotorSpecificSettings
RECORD — motor configuration; :05 is the phase order.
Definition somanet_drive.h:37
@ kEncoder2Configuration
RECORD — the encoder the firmware calls encoder 2.
Definition somanet_drive.h:45
@ kTorqueController
RECORD — :0C names the encoder commutation uses.
Definition somanet_drive.h:40
@ kCommutationAngleOffset
INTEGER16 — the offset command 5 measures and writes.
Definition somanet_drive.h:36
@ kPositionController
RECORD — :09 names the encoder position control uses.
Definition somanet_drive.h:42
@ kBrakeOptions
RECORD — brake voltages, timing, release strategy, status.
Definition somanet_drive.h:38
@ kCommutationOffsetDetection
RECORD — how commutation offset (5) is measured.
Definition somanet_drive.h:39
@ kEncoder1Configuration
RECORD — the encoder the firmware calls encoder 1.
Definition somanet_drive.h:44
@ kErrorReport
RECORD — :01 describes the drive's most recent fault.
Definition somanet_drive.h:43
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:368
BrakeOption
Sub-entries of 0x2004 (brake options). The enum value is the subindex.
Definition somanet_drive.h:758
@ kBrakePullVoltage
UNSIGNED32, mV — voltage that disengages the brake.
Definition somanet_drive.h:759
@ kBrakeStatus
UNSIGNED8 — reports and commands the brake; see BrakeStatus.
Definition somanet_drive.h:765
@ kBrakeReleaseStrategy
UNSIGNED8 — how the brake is driven; see BrakeReleaseStrategy.
Definition somanet_drive.h:762
@ kBrakeControllerDisableDelay
UNSIGNED16, ms — engage-to-controller-off delay.
Definition somanet_drive.h:763
@ kBrakePinInitialDirection
INTEGER8 — which way a pin-brake release moves first.
Definition somanet_drive.h:774
@ kBrakeDcBusVoltage
UNSIGNED16 — deprecated; the drive still lists it.
Definition somanet_drive.h:764
@ kBrakeMinimumDisplacement
UNSIGNED32 — pin-brake release travel threshold.
Definition somanet_drive.h:766
@ kBrakePullTime
UNSIGNED16, ms — how long the pull voltage is applied.
Definition somanet_drive.h:761
@ kBrakeHoldVoltage
UNSIGNED32, mV — lower voltage that keeps it disengaged.
Definition somanet_drive.h:760
@ kBrakeSwitchingFrequency
UNSIGNED8 — phase-D PWM rate (0: 16, 1: 32, 2: 64 kHz).
Definition somanet_drive.h:773
@ kBrakeOutputVoltage
UNSIGNED16, mV — phase-D voltage in manual mode.
Definition somanet_drive.h:772
@ kBrakePinCurrentPercent
Definition somanet_drive.h:770
MotorPhaseOrder
Which way round the motor's phases are wired, as motor phase order detection (command 4) reports it a...
Definition somanet_drive.h:920
@ 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:788
@ 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:498
VelocitySource
Where the velocity control loop takes its feedback from (OS command 18). The enum value is the trigge...
Definition somanet_drive.h:346
EncoderConfigurationEntry
Sub-entries of 0x2110 and 0x2112 (encoder configuration). The enum value is the subindex,...
Definition somanet_drive.h:58
@ kEncoderResolution
UNSIGNED32 — counts per revolution.
Definition somanet_drive.h:61
@ kEncoderType
UNSIGNED8 — see EncoderType.
Definition somanet_drive.h:60
@ kEncoderPolarity
UNSIGNED8 — 0 normal, 1 inverted.
Definition somanet_drive.h:62
@ kEncoderSensorPort
UNSIGNED8 — 0 for none, else the port the encoder is wired to.
Definition somanet_drive.h:59
@ kEncoderSingleturnBits
UNSIGNED8 — bits of the position within a turn in the frame.
Definition somanet_drive.h:64
@ kEncoderMultiturnBits
UNSIGNED8 — bits of the turn counter in the frame.
Definition somanet_drive.h:63
constexpr FirmwareErrorEffect effectOf(FirmwareErrorType type)
What type does, from the firmware's own case bodies rather than from its name.
Definition somanet_drive.h:442
ChirpSignalType
Which excitation the system-identification run sweeps with (parameter 4).
Definition somanet_drive.h:543
@ 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:430
constexpr uint32_t kMinChirpTransitionTimeMs
1 s.
Definition somanet_drive.h:603
std::optional< FirmwareErrorType > parseFirmwareErrorType(std::string_view token)
Parses a firmware error type token — the inverse of toString.
Definition somanet_drive.cc:421
MotorMeasurementFault
The faults the current-injecting motor measurements report as their command-specific OS error code — ...
Definition somanet_drive.h:944
@ 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:601
KueblerRegisterFault
What the Kübler encoder reported when a register access failed (OS command 19).
Definition somanet_drive.h:309
@ 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:138
@ kCommutationOffsetKi
REAL32 — phasing controller Ki; method 1 only.
Definition somanet_drive.h:149
@ kCommutationOffsetMethod
INTEGER8 — which method runs; see CommutationOffsetMethod.
Definition somanet_drive.h:147
@ kCommutationOffsetKp
REAL32 — phasing controller Kp; method 1 only.
Definition somanet_drive.h:148
@ kCommutationOffsetState
INTEGER16 — set to OFFSET_VALID by a successful command 5.
Definition somanet_drive.h:139
@ kCommutationOffsetKd
REAL32 — phasing controller Kd; method 1 only.
Definition somanet_drive.h:150
@ kCommutationOffsetAppliedTorquePercent
Definition somanet_drive.h:145
BrakeReleaseStrategy
How the brake is driven (0x2004:04).
Definition somanet_drive.h:781
@ 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:602
EncoderType
The kind of encoder a configuration record describes (0x2110:02, 0x2112:02).
Definition somanet_drive.h:68
HrdStreamFault
The faults HRD streaming (command 3) reports as its command-specific OS error code.
Definition somanet_drive.h:709
@ 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:513
@ 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:565
FirmwareLatency
Which internal firmware latency OS command 22 measures. The enum value is the latency index byte the ...
Definition somanet_drive.h:376
std::optional< SystemIdentificationStart > parseSystemIdentificationStart(std::string_view token)
Parses a start token ("none" / "immediately" / "after-hrd-stream-start").
Definition somanet_drive.cc:388
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:408
@ 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.
@ 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:428
std::optional< IcMuCalibrationMode > parseIcMuCalibrationMode(std::string_view token)
Parses a mode token ("configuration" / "raw" / "standard") — the inverse of toString....
Definition somanet_drive.cc:440
MotorSetting
Sub-entries of 0x2003 (motor specific settings). The enum value is the subindex.
Definition somanet_drive.h:113
@ kMotorPolePairs
UNSIGNED8 — where a pole pair count (command 7) belongs.
Definition somanet_drive.h:114
@ kMotorTorqueConstant
Definition somanet_drive.h:119
@ kMotorPhasesInverted
BOOLEAN — the phase order motor phase order detection (4) writes.
Definition somanet_drive.h:130
@ kMotorPhaseResistance
Definition somanet_drive.h:124
@ kMotorPhaseInductance
Definition somanet_drive.h:129
constexpr OperationMode kOperationModes[]
Every SOMANET operation mode, ascending — the manufacturer half of a mode list.
Definition somanet_drive.h:1030
HrdData
Which signal a high resolution data (HRD) stream records — OS command 3's data index....
Definition somanet_drive.h:658
OperationMode
SOMANET's manufacturer-specific operation modes — the negative half of 0x6060, which CiA402 leaves to...
Definition somanet_drive.h:976
@ kSystemIdentification
System identification mode. Deprecated by the firmware.
@ kCoggingCompensationRecording
Cogging torque table recording.
@ 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:1143
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:1240
std::string_view toString(Cia402TargetKind kind)
The token parseCia402TargetKind reads, for a JSON answer.
Definition cia402_drive.cc:59
OsCommandError
The general OS error codes — the ones any command can report, counting down from 254....
Definition somanet_drive.h:1066
@ 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:1397
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:1080
constexpr size_t kOsCommandSize
Byte length of the OS command and response octet strings (0x1023:01 / 0x1023:03). Manufacturer-specif...
Definition somanet_drive.h:1050
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:1034
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:455
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:1113
FsBufferTransfer
Which way an OS command's fs-buffer transfer moves bytes.
Definition somanet_drive.h:1116
@ 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:1113
OsCommandStatus
Terminal OS command status — byte 0 of the response (0x1023:03), which the firmware mirrors from 0x10...
Definition somanet_drive.h:1055
@ 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:1205
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:714
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:2139
std::expected< Encoders, std::string > encoders(DeviceManager &deviceManager, uint16_t slavePosition)
Releases (disengages) a drive's brake, then waits for the release to finish.
Definition somanet_control.cc:39
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:465
@ kNone
Neither — the package is for other hardware.
std::string text
Definition soem_fieldbus_driver.cc:1254
uint32_t code
Definition soem_fieldbus_driver.cc:1253
bool releaseBrake
Definition somanet_procedures.cc:462
std::size_t bytes
Definition spoe_connection.cc:24
The brake's configuration and its current state — one read of the parts of 0x2004 that decide what a ...
Definition somanet_drive.h:1265
somanet::BrakeReleaseStrategy releaseStrategy
0x2004:04.
Definition somanet_drive.h:1267
bool softwareControllable() const
Whether the firmware drives the brake, i.e. whether commanding 0x2004:07 does anything....
Definition somanet_drive.h:1275
somanet::BrakeStatus status
0x2004:07.
Definition somanet_drive.h:1266
uint32_t holdVoltageMv
0x2004:02.
Definition somanet_drive.h:1271
std::chrono::milliseconds pullTime
0x2004:03.
Definition somanet_drive.h:1269
uint32_t pullVoltageMv
0x2004:01.
Definition somanet_drive.h:1270
bool releaseMovesShaft() const
Whether releasing this brake turns the motor — true only for a pin brake, whose release procedure lif...
Definition somanet_drive.h:1281
What commutation offset measurement (command 5) measured.
Definition somanet_drive.h:1491
std::string describe() const
One line describing the measurement, ready to put in front of a user.
Definition somanet_drive.cc:1502
somanet::CommutationOffsetMethod method
The method the measurement ran under, which decides whether the rotor turned.
Definition somanet_drive.h:1495
int16_t angleOffset
The measured offset, signed as the drive's own 0x2001 is.
Definition somanet_drive.h:1492
One file stored on a device, as its file list reports it.
Definition somanet_drive.h:1333
std::string name
Filename as FoE addresses it, e.g. "hr_data0.bin".
Definition somanet_drive.h:1334
std::optional< size_t > byteCount
Size the device reported, when it reported one.
Definition somanet_drive.h:1335
One of a drive's two encoder configuration records, 0x2110 or 0x2112, as the drive reports it....
Definition somanet_drive.h:1289
uint8_t singleturnBits
:0C.
Definition somanet_drive.h:1296
uint8_t sensorPort
:01, 0 for none.
Definition somanet_drive.h:1291
somanet::EncoderOrdinal encoder
Definition somanet_drive.h:1290
bool inverted
:05.
Definition somanet_drive.h:1294
somanet::EncoderType type
:02.
Definition somanet_drive.h:1292
uint32_t resolution
:03, counts per revolution.
Definition somanet_drive.h:1293
uint8_t multiturnBits
:0A.
Definition somanet_drive.h:1295
What one encoder register access did — the result of both a read and a write, since the drive answers...
Definition somanet_drive.h:1318
std::optional< uint8_t > value
What the register holds, when the drive reported it.
Definition somanet_drive.h:1322
somanet::EncoderOrdinal encoder
Which encoder answered.
Definition somanet_drive.h:1319
uint8_t registerAddress
The register accessed.
Definition somanet_drive.h:1320
std::string describe() const
One line describing the access, ready to put in front of a user.
Definition somanet_drive.cc:1381
bool wrote
Whether this was a write; false for a read.
Definition somanet_drive.h:1321
Both encoder records and which of them each controller uses. One read answers every "which encoder do...
Definition somanet_drive.h:1302
std::optional< somanet::EncoderOrdinal > velocity
0x2011:05.
Definition somanet_drive.h:1305
std::vector< EncoderConfiguration > encoders
Definition somanet_drive.h:1303
std::optional< somanet::EncoderOrdinal > position
0x2012:09; empty for "no encoder".
Definition somanet_drive.h:1304
std::optional< somanet::EncoderOrdinal > commutation
0x2010:0C.
Definition somanet_drive.h:1306
The maximum one firmware latency reached, as command 22 reported it.
Definition somanet_drive.h:1633
uint32_t configuredNanoseconds
Definition somanet_drive.h:1645
uint32_t maximumNanoseconds
Definition somanet_drive.h:1641
somanet::FirmwareLatency latency
Which latency.
Definition somanet_drive.h:1634
std::string describe() const
One line describing the reading, ready to put in front of a user.
Definition somanet_drive.cc:1900
One sample of somanet::HrdData::kEncoderRawData.
Definition somanet_drive.h:1377
uint16_t masterCount
Bits 0-13: the master track's count.
Definition somanet_drive.h:1379
uint16_t noniusCount
Bits 14-27: the nonius track's count.
Definition somanet_drive.h:1380
uint32_t raw
The 32-bit word as the file holds it.
Definition somanet_drive.h:1378
One high resolution data recording, read back from the drive's files and decoded.
Definition somanet_drive.h:1405
somanet::HrdData data
Which signal this recorded.
Definition somanet_drive.h:1406
size_t byteCount
Total bytes read across them.
Definition somanet_drive.h:1408
size_t trailingBytes
Bytes past the last whole sample; padding, not data.
Definition somanet_drive.h:1409
size_t sampleCount() const
How many samples were decoded, whichever format they are in.
Definition somanet_drive.cc:1087
HrdSamples samples
The decoded samples.
Definition somanet_drive.h:1410
std::vector< DeviceFile > files
The files it was read from, in order.
Definition somanet_drive.h:1407
One sample of somanet::HrdData::kSystemIdentificationData.
Definition somanet_drive.h:1384
int16_t torquePermil
The torque actual value, in per mille of rated torque — the file's own unit.
Definition somanet_drive.h:1389
double velocityRpm
The velocity actual value, converted from the file's Q15 fixed point to real RPM.
Definition somanet_drive.h:1386
What one Kübler register access produced (command 19).
Definition somanet_drive.h:1597
std::vector< uint8_t > bytes
Definition somanet_drive.h:1608
uint8_t length
Bytes transferred, 1 to 4.
Definition somanet_drive.h:1599
uint32_t value
Definition somanet_drive.h:1614
uint8_t address
The register accessed.
Definition somanet_drive.h:1598
bool wrote
Whether this was a write; the drive echoes the value either way.
Definition somanet_drive.h:1600
std::string describe() const
One line describing the access, ready to put in front of a user.
Definition somanet_drive.cc:1776
What motor phase order detection (command 4) found.
Definition somanet_drive.h:1475
somanet::MotorPhaseOrder order
What the drive detected.
Definition somanet_drive.h:1476
bool inverted() const
Whether the phases are inverted — the one bit a caller normally branches on.
Definition somanet_drive.h:1479
std::string describe() const
One line describing the finding, ready to put in front of a user.
Definition somanet_drive.cc:1469
One object dictionary entry, as OS command 21 delivered it.
Definition somanet_drive.h:1210
DeviceParameterValue value
Definition somanet_drive.h:1213
uint8_t subindex
CoE object subindex.
Definition somanet_drive.h:1212
uint16_t index
CoE object index.
Definition somanet_drive.h:1211
Every object dictionary value the drive holds, read in one transfer by OS command 21.
Definition somanet_drive.h:1232
size_t byteCount
Bytes the drive sent. Equals the widths of values added up.
Definition somanet_drive.h:1233
std::vector< ObjectDictionaryValue > values
Definition somanet_drive.h:1234
What open phase detection found.
Definition somanet_drive.h:1457
std::optional< uint8_t > faultCode
The raw code, present whenever phaseOpened.
Definition somanet_drive.h:1463
std::optional< somanet::OpenPhaseFault > fault
Definition somanet_drive.h:1462
std::string describe() const
One line describing the finding, ready to put in front of a user.
Definition somanet_drive.cc:1411
bool phaseOpened
True when the drive found an open phase.
Definition somanet_drive.h:1458
Timing and cancellation for SomanetDrive::runOsCommand.
Definition somanet_drive.h:1177
std::stop_token stop
Requesting a stop aborts the command; default never stops.
Definition somanet_drive.h:1183
std::chrono::milliseconds timeout
Ceiling on the whole command.
Definition somanet_drive.h:1178
std::chrono::milliseconds pollInterval
Delay between response polls.
Definition somanet_drive.h:1180
std::chrono::milliseconds abortTimeout
Time allowed to confirm a forced abort.
Definition somanet_drive.h:1182
An OS command's fs-buffer transfer — the data that does not fit in the 8 command bytes.
Definition somanet_drive.h:1159
FsBufferTransfer transfer
What to move; kNone moves nothing.
Definition somanet_drive.h:1160
std::vector< uint8_t > payload
What to send. Read by kWrite, ignored otherwise.
Definition somanet_drive.h:1161
A completed OS command's response — the decoded form of 0x1023:03.
Definition somanet_drive.h:1091
OsCommandStatus status
Terminal status (response byte 0).
Definition somanet_drive.h:1092
std::vector< uint8_t > data
Service response payload, if any.
Definition somanet_drive.h:1093
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:1102
std::optional< uint8_t > errorCode
Definition somanet_drive.h:1094
std::vector< uint8_t > fsBuffer
Definition somanet_drive.h:1097
What phase inductance measurement (command 9) measured.
Definition somanet_drive.h:1536
std::string describe() const
One line describing the measurement, ready to put in front of a user.
Definition somanet_drive.cc:1590
uint32_t microhenries
Phase inductance in µH, exactly as the drive reported it.
Definition somanet_drive.h:1537
What phase resistance measurement (command 8) measured.
Definition somanet_drive.h:1521
uint32_t milliohms
Phase resistance in mΩ, exactly as the drive reported it.
Definition somanet_drive.h:1522
std::string describe() const
One line describing the measurement, ready to put in front of a user.
Definition somanet_drive.cc:1567
What pole pair detection (command 7) found.
Definition somanet_drive.h:1503
std::string describe() const
One line describing the finding, ready to put in front of a user.
Definition somanet_drive.cc:1544
uint8_t polePairs
Pole pairs the drive counted.
Definition somanet_drive.h:1504
What the skipped cycles counter (command 13) reported for one control loop.
Definition somanet_drive.h:1572
std::string describe() const
One line describing the reading, ready to put in front of a user.
Definition somanet_drive.cc:1639
somanet::FirmwareService service
Which loop.
Definition somanet_drive.h:1573
uint32_t skippedCycles
Cycles that loop has skipped since it started.
Definition somanet_drive.h:1574
What torque constant measurement (command 10) measured.
Definition somanet_drive.h:1558
std::string describe() const
One line describing the measurement, ready to put in front of a user.
Definition somanet_drive.cc:1613
int32_t milliNewtonMetresPerAmpere
Torque constant in mNm/A_rms, as the drive reported.
Definition somanet_drive.h:1559
What one trigger-error run did (command 16).
Definition somanet_drive.h:1582
somanet::FirmwareService service
Which service.
Definition somanet_drive.h:1583
somanet::FirmwareErrorType type
What was asked.
Definition somanet_drive.h:1584
bool serviceStopped
Definition somanet_drive.h:1589
somanet::FirmwareErrorEffect effect
Definition somanet_drive.h:1585
std::string describe() const
One line describing what happened, ready to put in front of a user.
Definition somanet_drive.cc:1746