Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
cia402_drive.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <expected>
5#include <nlohmann/json_fwd.hpp>
6#include <optional>
7#include <string>
8#include <string_view>
9
10#include "node/cia402.h"
11#include "node/profile_device.h"
12
13namespace mm::node {
14
29
32void to_json(nlohmann::json& j, const Cia402Status& s);
33
36 int32_t min{};
37 int32_t max{};
38};
39
42 int32_t min{};
43 int32_t max{};
44};
45
47struct GearRatio {
48 uint32_t motorRevolutions{};
49 uint32_t shaftRevolutions{};
50};
51
54 uint32_t feed{};
55 uint32_t shaftRevolutions{};
56};
57
60 uint32_t switchSearch{};
61 uint32_t zeroSearch{};
62};
63
66 uint32_t physicalOutputs{};
67 uint32_t bitMask{};
68};
69
73
76std::optional<Cia402Command> parseCia402Command(std::string_view token);
77
82
85std::optional<Cia402TargetKind> parseCia402TargetKind(std::string_view token);
86
105 public:
108
110 std::expected<cia402::State, std::string> state() const;
111
113 std::expected<uint16_t, std::string> statusword() const;
114
116 std::expected<uint16_t, std::string> controlword() const;
117
123 std::expected<void, std::string> setControlword(uint16_t value);
124
126 std::expected<cia402::OperationMode, std::string> operationMode() const;
127
129 std::expected<void, std::string> setOperationMode(cia402::OperationMode mode);
130
138 std::expected<int8_t, std::string> operationModeValue() const;
139
142 std::expected<int8_t, std::string> operationModeValueDisplay() const;
143
148 std::expected<void, std::string> setOperationModeValue(int8_t mode);
149
165 std::expected<void, std::string> applyOperationMode(
166 int8_t mode, std::chrono::milliseconds timeout = std::chrono::milliseconds(200));
167
169 std::expected<Cia402Status, std::string> readStatus() const;
170
171 // --- State-machine transitions ------------------------------------------------------------
172 // Each issues exactly one controlword edge via a read-modify-write that touches only the
173 // command bits (cia402::kCommandMask), preserving mode-specific / halt / manufacturer bits.
174 // They command a transition; they do not wait for the drive to reach the target state.
175
177 std::expected<void, std::string> shutdown();
178
180 std::expected<void, std::string> switchOn();
181
183 std::expected<void, std::string> enableOperation();
184
186 std::expected<void, std::string> disableVoltage();
187
189 std::expected<void, std::string> quickStop();
190
197 std::expected<void, std::string> faultReset();
198
199 // --- Convenience walks ---------------------------------------------------------------------
200
235 std::expected<void, std::string> transitionToState(
236 cia402::State target, std::chrono::milliseconds timeout = std::chrono::milliseconds(2000),
237 bool allowQuickStopOverride = false);
238
248 std::expected<void, std::string> enable(
249 std::chrono::milliseconds timeout = std::chrono::milliseconds(2000));
250
252 std::expected<void, std::string> disable();
253
254 // --- Cyclic setpoints (typed convenience over the standard objects) ------------------------
255
257 std::expected<int32_t, std::string> targetPosition() const;
258
260 std::expected<void, std::string> setTargetPosition(int32_t counts);
261
263 std::expected<int32_t, std::string> targetVelocity() const;
264
266 std::expected<void, std::string> setTargetVelocity(int32_t value);
267
269 std::expected<int16_t, std::string> targetTorque() const;
270
272 std::expected<void, std::string> setTargetTorque(int16_t perMille);
273
275 std::expected<int32_t, std::string> positionActualValue() const;
276
278 std::expected<int32_t, std::string> velocityActualValue() const;
279
281 std::expected<int16_t, std::string> torqueActualValue() const;
282
283 // --- Profile objects (0x603F..0x6502) --------------------------------------------------------
284 // Flag-aware accessors over the remaining standard drive-profile objects, ordered by
285 // index/subindex. Every getter re-reads the device on each call (these objects are writable or
286 // volatile) except supportedDriveModes(), a constant capability field cached after the first
287 // read.
288
290 std::expected<uint16_t, std::string> errorCode() const;
291
293 std::expected<int16_t, std::string> quickStopOptionCode() const;
294
296 std::expected<void, std::string> setQuickStopOptionCode(int16_t value);
297
299 std::expected<int32_t, std::string> positionDemandValue() const;
300
302 std::expected<uint32_t, std::string> followingErrorWindow() const;
303
305 std::expected<void, std::string> setFollowingErrorWindow(uint32_t value);
306
308 std::expected<uint16_t, std::string> followingErrorTimeout() const;
309
311 std::expected<void, std::string> setFollowingErrorTimeout(uint16_t value);
312
314 std::expected<uint32_t, std::string> positionWindow() const;
315
317 std::expected<void, std::string> setPositionWindow(uint32_t value);
318
320 std::expected<uint16_t, std::string> positionWindowTime() const;
321
323 std::expected<void, std::string> setPositionWindowTime(uint16_t value);
324
326 std::expected<int32_t, std::string> velocityDemandValue() const;
327
329 std::expected<uint16_t, std::string> velocityWindow() const;
330
332 std::expected<void, std::string> setVelocityWindow(uint16_t value);
333
335 std::expected<uint16_t, std::string> velocityWindowTime() const;
336
338 std::expected<void, std::string> setVelocityWindowTime(uint16_t value);
339
341 std::expected<uint16_t, std::string> velocityThreshold() const;
342
344 std::expected<void, std::string> setVelocityThreshold(uint16_t value);
345
347 std::expected<uint16_t, std::string> velocityThresholdTime() const;
348
350 std::expected<void, std::string> setVelocityThresholdTime(uint16_t value);
351
353 std::expected<uint16_t, std::string> maxTorque() const;
354
356 std::expected<void, std::string> setMaxTorque(uint16_t perMille);
357
359 std::expected<uint16_t, std::string> maxCurrent() const;
360
362 std::expected<void, std::string> setMaxCurrent(uint16_t perMille);
363
365 std::expected<int16_t, std::string> torqueDemand() const;
366
368 std::expected<uint32_t, std::string> motorRatedCurrent() const;
369
371 std::expected<void, std::string> setMotorRatedCurrent(uint32_t milliamps);
372
374 std::expected<uint32_t, std::string> motorRatedTorque() const;
375
377 std::expected<void, std::string> setMotorRatedTorque(uint32_t millinewtonMetres);
378
380 std::expected<uint32_t, std::string> dcLinkCircuitVoltage() const;
381
383 std::expected<PositionRangeLimit, std::string> positionRangeLimit() const;
384
386 std::expected<void, std::string> setPositionRangeLimit(const PositionRangeLimit& limit);
387
389 std::expected<int32_t, std::string> homeOffset() const;
390
392 std::expected<void, std::string> setHomeOffset(int32_t value);
393
395 std::expected<SoftwarePositionLimit, std::string> softwarePositionLimit() const;
396
398 std::expected<void, std::string> setSoftwarePositionLimit(const SoftwarePositionLimit& limit);
399
401 std::expected<uint8_t, std::string> polarity() const;
402
404 std::expected<void, std::string> setPolarity(uint8_t value);
405
407 std::expected<uint32_t, std::string> maxMotorSpeed() const;
408
410 std::expected<void, std::string> setMaxMotorSpeed(uint32_t value);
411
413 std::expected<uint32_t, std::string> profileVelocity() const;
414
416 std::expected<void, std::string> setProfileVelocity(uint32_t value);
417
419 std::expected<uint32_t, std::string> profileAcceleration() const;
420
422 std::expected<void, std::string> setProfileAcceleration(uint32_t value);
423
425 std::expected<uint32_t, std::string> profileDeceleration() const;
426
428 std::expected<void, std::string> setProfileDeceleration(uint32_t value);
429
431 std::expected<uint32_t, std::string> quickStopDeceleration() const;
432
434 std::expected<void, std::string> setQuickStopDeceleration(uint32_t value);
435
437 std::expected<int16_t, std::string> motionProfileType() const;
438
440 std::expected<void, std::string> setMotionProfileType(int16_t value);
441
443 std::expected<uint32_t, std::string> torqueSlope() const;
444
446 std::expected<void, std::string> setTorqueSlope(uint32_t value);
447
449 std::expected<int16_t, std::string> torqueProfileType() const;
450
452 std::expected<void, std::string> setTorqueProfileType(int16_t value);
453
455 std::expected<GearRatio, std::string> gearRatio() const;
456
459 std::expected<void, std::string> setGearRatio(const GearRatio& ratio);
460
462 std::expected<FeedConstant, std::string> feedConstant() const;
463
466 std::expected<void, std::string> setFeedConstant(const FeedConstant& constant);
467
469 std::expected<int8_t, std::string> homingMethod() const;
470
472 std::expected<void, std::string> setHomingMethod(int8_t method);
473
475 std::expected<HomingSpeeds, std::string> homingSpeeds() const;
476
478 std::expected<void, std::string> setHomingSpeeds(const HomingSpeeds& speeds);
479
481 std::expected<uint32_t, std::string> homingAcceleration() const;
482
484 std::expected<void, std::string> setHomingAcceleration(uint32_t value);
485
487 std::expected<uint32_t, std::string> siUnitVelocity() const;
488
490 std::expected<void, std::string> setSiUnitVelocity(uint32_t value);
491
493 std::expected<int32_t, std::string> velocityOffset() const;
494
496 std::expected<void, std::string> setVelocityOffset(int32_t value);
497
499 std::expected<int16_t, std::string> torqueOffset() const;
500
502 std::expected<void, std::string> setTorqueOffset(int16_t value);
503
505 std::expected<uint16_t, std::string> touchProbeFunction() const;
506
508 std::expected<void, std::string> setTouchProbeFunction(uint16_t value);
509
511 std::expected<uint16_t, std::string> touchProbeStatus() const;
512
514 std::expected<int32_t, std::string> touchProbe1PositiveEdge() const;
515
517 std::expected<int32_t, std::string> touchProbe1NegativeEdge() const;
518
520 std::expected<uint32_t, std::string> touchProbeTimeStamp1PositiveValue() const;
521
523 std::expected<uint32_t, std::string> touchProbeTimeStamp1NegativeValue() const;
524
526 std::expected<uint16_t, std::string> positioningOptionCode() const;
527
529 std::expected<void, std::string> setPositioningOptionCode(uint16_t value);
530
532 std::expected<int32_t, std::string> followingErrorActualValue() const;
533
535 std::expected<int32_t, std::string> controlEffort() const;
536
538 std::expected<int32_t, std::string> positionDemandInternalValue() const;
539
541 std::expected<uint32_t, std::string> digitalInputs() const;
542
544 std::expected<DigitalOutputs, std::string> digitalOutputs() const;
545
549 std::expected<void, std::string> setDigitalOutputs(const DigitalOutputs& outputs);
550
553 std::expected<uint32_t, std::string> supportedDriveModes() const;
554
555 private:
558 std::expected<void, std::string> applyCommand(uint16_t command);
559};
560
570std::expected<Cia402Drive, std::string> createCia402Drive(Device& device);
571
572} // namespace mm::node
Pure CiA402 (CANopen drive profile, ETG.6010) vocabulary — object indices, control/status word bit la...
Borrowed view of a CiA402 drive — the device control state machine, operation modes,...
Definition cia402_drive.h:104
std::expected< void, std::string > quickStop()
Quick stop: → QuickStopActive.
Definition cia402_drive.cc:253
std::expected< void, std::string > setMotorRatedCurrent(uint32_t milliamps)
Writes the motor rated current (0x6075, UNSIGNED32, mA).
Definition cia402_drive.cc:575
std::expected< int32_t, std::string > touchProbe1NegativeEdge() const
Reads the position latched at touch probe 1's falling edge (0x60BB, INTEGER32).
Definition cia402_drive.cc:844
std::expected< int8_t, std::string > operationModeValue() const
Reads the requested operation mode (0x6060) as its raw value.
Definition cia402_drive.cc:135
std::expected< int8_t, std::string > homingMethod() const
Reads the homing method (0x6098, INTEGER8).
Definition cia402_drive.cc:765
std::expected< PositionRangeLimit, std::string > positionRangeLimit() const
Reads the position range limit (0x607B) — both sub-entries.
Definition cia402_drive.cc:591
std::expected< int32_t, std::string > velocityOffset() const
Reads the velocity offset (0x60B1, INTEGER32) — CSP/CSV velocity feed-forward.
Definition cia402_drive.cc:812
std::expected< uint32_t, std::string > digitalInputs() const
Reads the digital inputs (0x60FD, UNSIGNED32) — input bit field.
Definition cia402_drive.cc:876
std::expected< int32_t, std::string > homeOffset() const
Reads the home offset (0x607C, INTEGER32).
Definition cia402_drive.cc:615
std::expected< void, std::string > setMotionProfileType(int16_t value)
Writes the motion profile type (0x6086, INTEGER16).
Definition cia402_drive.cc:699
std::expected< void, std::string > setVelocityThresholdTime(uint16_t value)
Writes the velocity threshold time (0x6070, UNSIGNED16, ms).
Definition cia402_drive.cc:547
std::expected< void, std::string > setPositionWindow(uint32_t value)
Writes the position window (0x6067, UNSIGNED32).
Definition cia402_drive.cc:503
std::expected< void, std::string > enableOperation()
Enable operation: SwitchedOn → OperationEnabled.
Definition cia402_drive.cc:245
std::expected< void, std::string > faultReset()
Fault reset: asserts the rising edge of controlword bit 7 to clear a latched fault.
Definition cia402_drive.cc:257
std::expected< void, std::string > setFollowingErrorTimeout(uint16_t value)
Writes the following error time out (0x6066, UNSIGNED16, ms).
Definition cia402_drive.cc:495
std::expected< void, std::string > setProfileDeceleration(uint32_t value)
Writes the profile deceleration (0x6084, UNSIGNED32).
Definition cia402_drive.cc:683
std::expected< uint32_t, std::string > profileDeceleration() const
Reads the profile deceleration (0x6084, UNSIGNED32).
Definition cia402_drive.cc:679
std::expected< void, std::string > setTorqueSlope(uint32_t value)
Writes the torque slope (0x6087, UNSIGNED32).
Definition cia402_drive.cc:707
std::expected< void, std::string > disable()
Brings the drive to SwitchOnDisabled (disable voltage). Single transition.
Definition cia402_drive.cc:296
std::expected< void, std::string > setVelocityWindowTime(uint16_t value)
Writes the velocity window time (0x606E, UNSIGNED16, ms).
Definition cia402_drive.cc:531
std::expected< uint32_t, std::string > dcLinkCircuitVoltage() const
Reads the DC link circuit voltage (0x6079, UNSIGNED32, mV).
Definition cia402_drive.cc:587
std::expected< uint16_t, std::string > followingErrorTimeout() const
Reads the following error time out (0x6066, UNSIGNED16, ms).
Definition cia402_drive.cc:491
std::expected< uint32_t, std::string > motorRatedTorque() const
Reads the motor rated torque (0x6076, UNSIGNED32, mNm).
Definition cia402_drive.cc:579
std::expected< void, std::string > shutdown()
Shutdown: → ReadyToSwitchOn.
Definition cia402_drive.cc:237
std::expected< uint16_t, std::string > touchProbeFunction() const
Reads the touch probe function (0x60B8, UNSIGNED16) — arm/config bits.
Definition cia402_drive.cc:828
std::expected< uint32_t, std::string > touchProbeTimeStamp1NegativeValue() const
Reads the time stamp of touch probe 1's falling edge (0x60D2, UNSIGNED32).
Definition cia402_drive.cc:852
std::expected< void, std::string > setQuickStopDeceleration(uint32_t value)
Writes the quick stop deceleration (0x6085, UNSIGNED32).
Definition cia402_drive.cc:691
std::expected< void, std::string > setVelocityOffset(int32_t value)
Writes the velocity offset (0x60B1, INTEGER32).
Definition cia402_drive.cc:816
std::expected< uint16_t, std::string > velocityWindow() const
Reads the velocity window (0x606D, UNSIGNED16) — the target-reached tolerance.
Definition cia402_drive.cc:519
std::expected< DigitalOutputs, std::string > digitalOutputs() const
Reads the digital outputs (0x60FE) — both sub-entries.
Definition cia402_drive.cc:880
std::expected< uint32_t, std::string > siUnitVelocity() const
Reads the SI unit velocity (0x60A9, UNSIGNED32) — the unit code of velocity objects.
Definition cia402_drive.cc:804
std::expected< GearRatio, std::string > gearRatio() const
Reads the gear ratio (0x6091) — both sub-entries.
Definition cia402_drive.cc:719
Cia402Drive(Device &device)
Binds an (unchecked) CiA402 view to device. Prefer createCia402Drive.
Definition cia402_drive.h:107
std::expected< void, std::string > disableVoltage()
Disable voltage: → SwitchOnDisabled.
Definition cia402_drive.cc:249
std::expected< void, std::string > setTorqueProfileType(int16_t value)
Writes the torque profile type (0x6088, INTEGER16).
Definition cia402_drive.cc:715
std::expected< void, std::string > setVelocityWindow(uint16_t value)
Writes the velocity window (0x606D, UNSIGNED16).
Definition cia402_drive.cc:523
std::expected< uint32_t, std::string > followingErrorWindow() const
Reads the following error window (0x6065, UNSIGNED32).
Definition cia402_drive.cc:483
std::expected< void, std::string > setMaxCurrent(uint16_t perMille)
Writes max current (0x6073, UNSIGNED16, per-mille of rated).
Definition cia402_drive.cc:563
std::expected< cia402::OperationMode, std::string > operationMode() const
Reads the active operation mode (display object 0x6061).
Definition cia402_drive.cc:123
std::expected< int16_t, std::string > torqueOffset() const
Reads the torque offset (0x60B2, INTEGER16) — torque feed-forward.
Definition cia402_drive.cc:820
std::expected< int32_t, std::string > followingErrorActualValue() const
Reads the following error actual value (0x60F4, INTEGER32).
Definition cia402_drive.cc:864
std::expected< void, std::string > setDigitalOutputs(const DigitalOutputs &outputs)
Writes the digital outputs (0x60FE) — levels first (inert while masked off), then the enable mask,...
Definition cia402_drive.cc:896
std::expected< int8_t, std::string > operationModeValueDisplay() const
Reads the active operation mode (0x6061) as its raw value — the display counterpart of operationModeV...
Definition cia402_drive.cc:139
std::expected< int16_t, std::string > motionProfileType() const
Reads the motion profile type (0x6086, INTEGER16).
Definition cia402_drive.cc:695
std::expected< void, std::string > setFeedConstant(const FeedConstant &constant)
Writes the feed constant (0x6092) — feed then shaft revolutions; aborts on first failure.
Definition cia402_drive.cc:758
std::expected< void, std::string > setSiUnitVelocity(uint32_t value)
Writes the SI unit velocity (0x60A9, UNSIGNED32).
Definition cia402_drive.cc:808
std::expected< uint32_t, std::string > supportedDriveModes() const
Reads the supported drive modes (0x6502, UNSIGNED32) — the capability bit field. Constant,...
Definition cia402_drive.cc:905
std::expected< void, std::string > setSoftwarePositionLimit(const SoftwarePositionLimit &limit)
Writes the software position limit (0x607D) — min then max; aborts on first failure.
Definition cia402_drive.cc:639
std::expected< void, std::string > transitionToState(cia402::State target, std::chrono::milliseconds timeout=std::chrono::milliseconds(2000), bool allowQuickStopOverride=false)
Drives the state machine to target, walking every intermediate transition.
Definition cia402_drive.cc:298
std::expected< int32_t, std::string > targetPosition() const
Reads the last-commanded target position (0x607A, INTEGER32).
Definition cia402_drive.cc:431
std::expected< uint16_t, std::string > positioningOptionCode() const
Reads the positioning option code (0x60F2, UNSIGNED16) — PP behaviour options.
Definition cia402_drive.cc:856
std::expected< void, std::string > setMaxMotorSpeed(uint32_t value)
Writes the max motor speed (0x6080, UNSIGNED32).
Definition cia402_drive.cc:659
std::expected< void, std::string > setProfileVelocity(uint32_t value)
Writes the profile velocity (0x6081, UNSIGNED32).
Definition cia402_drive.cc:667
std::expected< uint16_t, std::string > touchProbeStatus() const
Reads the touch probe status (0x60B9, UNSIGNED16) — latch status bits.
Definition cia402_drive.cc:836
std::expected< void, std::string > setMaxTorque(uint16_t perMille)
Writes max torque (0x6072, UNSIGNED16, per-mille of rated).
Definition cia402_drive.cc:555
std::expected< void, std::string > setHomingSpeeds(const HomingSpeeds &speeds)
Writes the homing speeds (0x6099) — switch then zero search; aborts on first failure.
Definition cia402_drive.cc:789
std::expected< void, std::string > setFollowingErrorWindow(uint32_t value)
Writes the following error window (0x6065, UNSIGNED32).
Definition cia402_drive.cc:487
std::expected< uint32_t, std::string > profileVelocity() const
Reads the profile velocity (0x6081, UNSIGNED32) — PP cruise velocity.
Definition cia402_drive.cc:663
std::expected< void, std::string > setTargetVelocity(int32_t value)
Writes target velocity (0x60FF, INTEGER32) — CSV / PV.
Definition cia402_drive.cc:443
std::expected< uint8_t, std::string > polarity() const
Reads the polarity (0x607E, UNSIGNED8) — position/velocity inversion bits.
Definition cia402_drive.cc:647
std::expected< void, std::string > setHomeOffset(int32_t value)
Writes the home offset (0x607C, INTEGER32).
Definition cia402_drive.cc:619
std::expected< uint32_t, std::string > positionWindow() const
Reads the position window (0x6067, UNSIGNED32) — the target-reached tolerance.
Definition cia402_drive.cc:499
std::expected< void, std::string > enable(std::chrono::milliseconds timeout=std::chrono::milliseconds(2000))
Drives the state machine to OperationEnabled.
Definition cia402_drive.cc:424
std::expected< void, std::string > setHomingMethod(int8_t method)
Writes the homing method (0x6098, INTEGER8).
Definition cia402_drive.cc:769
std::expected< uint16_t, std::string > errorCode() const
Reads the error code (0x603F, UNSIGNED16) — the code of the last drive fault.
Definition cia402_drive.cc:467
std::expected< uint16_t, std::string > positionWindowTime() const
Reads the position window time (0x6068, UNSIGNED16, ms).
Definition cia402_drive.cc:507
std::expected< int32_t, std::string > positionDemandInternalValue() const
Reads the position demand internal value (0x60FC, INTEGER32).
Definition cia402_drive.cc:872
std::expected< int16_t, std::string > torqueActualValue() const
Reads actual torque (0x6077, INTEGER16, per-mille of rated).
Definition cia402_drive.cc:463
std::expected< uint16_t, std::string > velocityThresholdTime() const
Reads the velocity threshold time (0x6070, UNSIGNED16, ms).
Definition cia402_drive.cc:543
std::expected< void, std::string > switchOn()
Switch on: ReadyToSwitchOn → SwitchedOn (also disables operation from enabled).
Definition cia402_drive.cc:241
std::expected< int32_t, std::string > touchProbe1PositiveEdge() const
Reads the position latched at touch probe 1's rising edge (0x60BA, INTEGER32).
Definition cia402_drive.cc:840
std::expected< uint32_t, std::string > profileAcceleration() const
Reads the profile acceleration (0x6083, UNSIGNED32).
Definition cia402_drive.cc:671
std::expected< int32_t, std::string > positionActualValue() const
Reads actual position (0x6064, INTEGER32).
Definition cia402_drive.cc:455
std::expected< uint32_t, std::string > homingAcceleration() const
Reads the homing acceleration (0x609A, UNSIGNED32).
Definition cia402_drive.cc:796
std::expected< uint16_t, std::string > maxTorque() const
Reads max torque (0x6072, UNSIGNED16, per-mille of rated).
Definition cia402_drive.cc:551
std::expected< void, std::string > setTargetTorque(int16_t perMille)
Writes target torque (0x6071, INTEGER16, per-mille of rated) — CST / PT.
Definition cia402_drive.cc:451
std::expected< uint16_t, std::string > velocityWindowTime() const
Reads the velocity window time (0x606E, UNSIGNED16, ms).
Definition cia402_drive.cc:527
std::expected< void, std::string > setTargetPosition(int32_t counts)
Writes target position (0x607A, INTEGER32) — CSP / PP.
Definition cia402_drive.cc:435
std::expected< void, std::string > applyOperationMode(int8_t mode, std::chrono::milliseconds timeout=std::chrono::milliseconds(200))
Writes mode to 0x6060 and waits until the drive reports it active in 0x6061.
Definition cia402_drive.cc:147
std::expected< int16_t, std::string > quickStopOptionCode() const
Reads the quick stop option code (0x605A, INTEGER16).
Definition cia402_drive.cc:471
std::expected< void, std::string > setTouchProbeFunction(uint16_t value)
Writes the touch probe function (0x60B8, UNSIGNED16).
Definition cia402_drive.cc:832
std::expected< uint32_t, std::string > quickStopDeceleration() const
Reads the quick stop deceleration (0x6085, UNSIGNED32).
Definition cia402_drive.cc:687
std::expected< void, std::string > setPositionRangeLimit(const PositionRangeLimit &limit)
Writes the position range limit (0x607B) — min then max; aborts on first failure.
Definition cia402_drive.cc:607
std::expected< uint32_t, std::string > touchProbeTimeStamp1PositiveValue() const
Reads the time stamp of touch probe 1's rising edge (0x60D1, UNSIGNED32).
Definition cia402_drive.cc:848
std::expected< void, std::string > setHomingAcceleration(uint32_t value)
Writes the homing acceleration (0x609A, UNSIGNED32).
Definition cia402_drive.cc:800
std::expected< cia402::State, std::string > state() const
Reads and decodes the current state machine state (statusword 0x6041).
Definition cia402_drive.cc:119
std::expected< uint16_t, std::string > statusword() const
Reads the raw statusword (0x6041).
Definition cia402_drive.cc:107
std::expected< HomingSpeeds, std::string > homingSpeeds() const
Reads the homing speeds (0x6099) — both sub-entries.
Definition cia402_drive.cc:773
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
std::expected< void, std::string > setVelocityThreshold(uint16_t value)
Writes the velocity threshold (0x606F, UNSIGNED16).
Definition cia402_drive.cc:539
std::expected< void, std::string > setPositioningOptionCode(uint16_t value)
Writes the positioning option code (0x60F2, UNSIGNED16).
Definition cia402_drive.cc:860
std::expected< uint32_t, std::string > maxMotorSpeed() const
Reads the max motor speed (0x6080, UNSIGNED32).
Definition cia402_drive.cc:655
std::expected< uint32_t, std::string > motorRatedCurrent() const
Reads the motor rated current (0x6075, UNSIGNED32, mA).
Definition cia402_drive.cc:571
std::expected< SoftwarePositionLimit, std::string > softwarePositionLimit() const
Reads the software position limit (0x607D) — both sub-entries.
Definition cia402_drive.cc:623
std::expected< int16_t, std::string > torqueDemand() const
Reads the torque demand (0x6074, INTEGER16) — control loop output.
Definition cia402_drive.cc:567
std::expected< int16_t, std::string > torqueProfileType() const
Reads the torque profile type (0x6088, INTEGER16).
Definition cia402_drive.cc:711
std::expected< uint16_t, std::string > controlword() const
Reads the last-commanded controlword (0x6040).
Definition cia402_drive.cc:111
std::expected< uint16_t, std::string > velocityThreshold() const
Reads the velocity threshold (0x606F, UNSIGNED16) — the standstill threshold.
Definition cia402_drive.cc:535
std::expected< uint16_t, std::string > maxCurrent() const
Reads max current (0x6073, UNSIGNED16, per-mille of rated).
Definition cia402_drive.cc:559
std::expected< void, std::string > setTorqueOffset(int16_t value)
Writes the torque offset (0x60B2, INTEGER16).
Definition cia402_drive.cc:824
std::expected< void, std::string > setPolarity(uint8_t value)
Writes the polarity (0x607E, UNSIGNED8).
Definition cia402_drive.cc:651
std::expected< void, std::string > setGearRatio(const GearRatio &ratio)
Writes the gear ratio (0x6091) — motor then shaft revolutions; aborts on first failure.
Definition cia402_drive.cc:735
std::expected< void, std::string > setPositionWindowTime(uint16_t value)
Writes the position window time (0x6068, UNSIGNED16, ms).
Definition cia402_drive.cc:511
std::expected< Cia402Status, std::string > readStatus() const
Reads state, statusword, controlword, and the active mode in one shot.
Definition cia402_drive.cc:176
std::expected< FeedConstant, std::string > feedConstant() const
Reads the feed constant (0x6092) — both sub-entries.
Definition cia402_drive.cc:742
std::expected< int32_t, std::string > targetVelocity() const
Reads the last-commanded target velocity (0x60FF, INTEGER32).
Definition cia402_drive.cc:439
std::expected< int32_t, std::string > positionDemandValue() const
Reads the position demand value (0x6062, INTEGER32) — trajectory generator output.
Definition cia402_drive.cc:479
std::expected< void, std::string > setControlword(uint16_t value)
Writes the controlword (0x6040) verbatim.
Definition cia402_drive.cc:115
std::expected< int32_t, std::string > controlEffort() const
Reads the control effort (0x60FA, INTEGER32) — position loop output.
Definition cia402_drive.cc:868
std::expected< void, std::string > setOperationModeValue(int8_t mode)
Writes a raw operation-mode value to 0x6060 — the counterpart of operationModeValue.
Definition cia402_drive.cc:143
std::expected< uint32_t, std::string > torqueSlope() const
Reads the torque slope (0x6087, UNSIGNED32) — PT torque ramp rate.
Definition cia402_drive.cc:703
std::expected< int32_t, std::string > velocityActualValue() const
Reads actual velocity (0x606C, INTEGER32).
Definition cia402_drive.cc:459
std::expected< int16_t, std::string > targetTorque() const
Reads the last-commanded target torque (0x6071, INTEGER16, per-mille of rated).
Definition cia402_drive.cc:447
std::expected< void, std::string > setProfileAcceleration(uint32_t value)
Writes the profile acceleration (0x6083, UNSIGNED32).
Definition cia402_drive.cc:675
std::expected< int32_t, std::string > velocityDemandValue() const
Reads the velocity demand value (0x606B, INTEGER32) — ramp generator output.
Definition cia402_drive.cc:515
std::expected< void, std::string > setQuickStopOptionCode(int16_t value)
Writes the quick stop option code (0x605A, INTEGER16) — the quick-stop reaction.
Definition cia402_drive.cc:475
std::expected< void, std::string > setMotorRatedTorque(uint32_t millinewtonMetres)
Writes the motor rated torque (0x6076, UNSIGNED32, mNm).
Definition cia402_drive.cc:583
Represents a single node on the fieldbus.
Definition device.h:116
Root of the drive-profile view hierarchy — a concrete, instantiable, borrowed view over a Device that...
Definition profile_device.h:151
Device & device()
The underlying generic device this view operates on.
Definition profile_device.h:157
OperationMode
CiA402 operation modes (object 0x6060 / 0x6061 values).
Definition cia402.h:98
State
States of the CiA402 device control state machine (decoded from the statusword).
Definition cia402.h:139
Definition bus_health_source.h:7
std::expected< Cia402Drive, std::string > createCia402Drive(Device &device)
Validates that device implements the CiA402 profile, then binds a view to it.
Definition cia402_drive.cc:909
std::optional< Cia402TargetKind > parseCia402TargetKind(std::string_view token)
Parses a target-kind token ("position" / "velocity" / "torque").
Definition cia402_drive.cc:41
Cia402Command
High-level state-machine actions a client can command (the named transitions a UI exposes as buttons)...
Definition cia402_drive.h:72
std::optional< Cia402Command > parseCia402Command(std::string_view token)
Parses a command token ("enable" / "disable" / "quickStop" / "faultReset").
Definition cia402_drive.cc:25
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
Cia402TargetKind
Which cyclic setpoint a target write addresses. Exactly one is active at a time — the one matching th...
Definition cia402_drive.h:81
std::chrono::milliseconds timeout
Definition somanet_procedures.cc:438
A snapshot of a CiA402 drive's control state — the values a control UI needs to show at a glance: the...
Definition cia402_drive.h:19
cia402::State state
Decoded from the statusword (0x6041).
Definition cia402_drive.h:20
uint16_t controlword
Last-commanded controlword (0x6040).
Definition cia402_drive.h:22
uint16_t statusword
Raw statusword (0x6041).
Definition cia402_drive.h:21
cia402::OperationMode modeOfOperationDisplay
Definition cia402_drive.h:23
int32_t target
Definition cia402_drive.h:27
Digital outputs (0x60FE) — commanded output levels gated by an enable mask.
Definition cia402_drive.h:65
uint32_t bitMask
0x60FE:02 — 1 = the corresponding output bit is driven.
Definition cia402_drive.h:67
uint32_t physicalOutputs
0x60FE:01 — commanded output bit levels.
Definition cia402_drive.h:66
Feed constant (0x6092) — feed (position units) per driving shaft revolutions.
Definition cia402_drive.h:53
uint32_t shaftRevolutions
0x6092:02 — denominator.
Definition cia402_drive.h:55
uint32_t feed
0x6092:01 — numerator.
Definition cia402_drive.h:54
Gear ratio (0x6091) — motor revolutions per driving shaft revolutions.
Definition cia402_drive.h:47
uint32_t shaftRevolutions
0x6091:02 — denominator.
Definition cia402_drive.h:49
uint32_t motorRevolutions
0x6091:01 — numerator.
Definition cia402_drive.h:48
Homing speeds (0x6099) — the two velocities of a homing run.
Definition cia402_drive.h:59
uint32_t switchSearch
0x6099:01 — speed during search for the reference switch.
Definition cia402_drive.h:60
uint32_t zeroSearch
0x6099:02 — speed during search for the zero position.
Definition cia402_drive.h:61
Position range limit (0x607B) — the range position values wrap around in.
Definition cia402_drive.h:35
int32_t max
0x607B:02 — max position range limit.
Definition cia402_drive.h:37
int32_t min
0x607B:01 — min position range limit.
Definition cia402_drive.h:36
Software position limit (0x607D) — the absolute end stops enforced in software.
Definition cia402_drive.h:41
int32_t min
0x607D:01 — min position limit.
Definition cia402_drive.h:42
int32_t max
0x607D:02 — max position limit.
Definition cia402_drive.h:43