Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
kuebler_registers.h
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <array>
5#include <cstdint>
6#include <nlohmann/json_fwd.hpp>
7#include <optional>
8#include <string_view>
9
10namespace mm::node::somanet {
11
37
39enum class KueblerFormat : uint8_t {
40 kUnsigned,
41 kSigned,
42 kBitField,
46};
47
49enum class KueblerAccess : uint8_t { kReadOnly, kWriteOnly, kReadWrite };
50
53 uint8_t address = 0;
54 uint8_t bits = 0;
55 std::string_view name;
57
62 bool implemented = false;
63
65
69 std::string_view definition;
70};
71
74void to_json(nlohmann::json& j, const KueblerRegister& r);
75
78inline constexpr auto kKueblerRegisters = std::to_array<KueblerRegister>({
79 {0x00, 32, "Identification pattern", KueblerAccess::kReadOnly, false, KueblerFormat::kUnsigned,
80 "TBD"},
81 // 32 bit, not the draft's 64: the encoder calibration sequence reads four bytes here and parses
82 // a version out of them. The draft's own format line describes 18 decimal digits, which those
83 // four bytes cannot hold, so the line below and the width disagree. The vendor specification is
84 // what settles it, and nobody has it yet.
85 {0x04, 32, "Firmware-version", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
86 "Major(3 digit).Minor(3 digit).Timestamp(12 digits); 001.002.2023.09.18.14.25 --> Version "
87 "1.2.202309181425"},
88 {0x10, 16, "POA start offset A", KueblerAccess::kReadOnly, true, KueblerFormat::kSigned,
89 "Bit 15 - 0: signed 16 bit integer"},
90 {0x12, 16, "POA start offset B", KueblerAccess::kReadOnly, true, KueblerFormat::kSigned,
91 "Bit 15 - 0: signed 16 bit integer"},
92 {0x14, 16, "POA start amplitude A", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
93 "Bit 15 - 0: unsigned 16 bit integer"},
94 {0x16, 16, "POA start amplitude B", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
95 "Bit 15 - 0: unsigned 16 bit integer"},
96 {0x18, 16, "POA start phase", KueblerAccess::kReadOnly, true, KueblerFormat::kSigned,
97 "Bit 15 - 0: signed 16 bit integer"},
98 {0x1A, 16, "POA current offset A", KueblerAccess::kReadOnly, true, KueblerFormat::kSigned,
99 "Bit 15 - 0: signed 16 bit integer"},
100 {0x1C, 16, "POA current offset B", KueblerAccess::kReadOnly, true, KueblerFormat::kSigned,
101 "Bit 15 - 0: signed 16 bit integer"},
102 {0x1E, 16, "POA current amplitude A", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
103 "Bit 15 - 0: unsigned 16 bit integer"},
104 {0x20, 16, "POA current amplitude B", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
105 "Bit 15 - 0: unsigned 16 bit integer"},
106 {0x22, 16, "POA current phase", KueblerAccess::kReadOnly, true, KueblerFormat::kSigned,
107 "Bit 15 - 0: signed 16 bit integer"},
108 {0x24, 8, "POA status", KueblerAccess::kReadOnly, true, KueblerFormat::kBitField,
109 "Bit 7 - 3: Reserved; Bit 2: POA saving active (1 = saving active / 0 = saving not active); "
110 "Bit 1: POA fast mode (1 = fast mode active / 0 = fast mode inactive); Bit 0: POA active (1 = "
111 "POA active / 0 = POA inactive)"},
112 {0x25, 8, "POA control", KueblerAccess::kWriteOnly, true, KueblerFormat::kBitField,
113 "Bit 7 - 3: Reserved; Bit 2: POA save values as startup; Bit 1: POA enable/disable fast mode "
114 "(1 = enable / 0 = disable); Bit 0: POA set active/inactive (1 = set active / 0 = set "
115 "inactive)"},
116 {0x30, 32, "Absolute position ST", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
117 "Left aligned 32 bit singleturn position"},
118 {0x34, 32, "Absolute position MT", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
119 "Right aligned 32 bit multiturn position"},
120 {0x38, 32, "Velocity", KueblerAccess::kReadOnly, true, KueblerFormat::kSigned,
121 "32 bit integer value (+/- FS --> +/- 125000 Hz)"},
122 {0x3C, 32, "Analog value A & B", KueblerAccess::kReadOnly, true, KueblerFormat::kSignedHalves,
123 "Bit 31 - 16: signed 16 bit integer (A); Bit 15 - 0: signed 16 bit integer (B)"},
124 {0x40, 32, "Magnitude", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
125 "sin^2+cos^2 adc values"},
126 {0x50, 16, "Correction control", KueblerAccess::kReadWrite, true, KueblerFormat::kBitField,
127 "Bit 15 - 8: Reserved; Bit 7: Wiegand compensation active; Bit 6: Correction table active; "
128 "Bit 5: Direct output; Bit 4: Save correction table; Bit 3: Erase current correction table; "
129 "Bit 2: Clear current correction table; Bit 1: start linear learn; Bit 0: start automatic "
130 "calibration"},
131 {0x52, 16, "Correction status", KueblerAccess::kReadOnly, true, KueblerFormat::kBitField,
132 "Bit 15 - 11: Reserved; Bit 10: learning direction; Bit 9: Processing active; Bit 8: Sampling "
133 "active; Bit 7: Wiegand compensation active; Bit 6: Correction table active; Bit 5: Direct "
134 "output active; Bit 4: Save correction table active; Bit 3: Erase current correction table "
135 "active; Bit 2: Reserved; Bit 1: linear learn active; Bit 0: automatic calibration active"},
136 {0x54, 8, "Configuration control", KueblerAccess::kWriteOnly, true, KueblerFormat::kBitField,
137 "Bit 7 - 2: Reserved; Bit 1: Load default configuration; Bit 0: Save current configuration"},
138 // Not in the vendor's draft. The encoder calibration sequence reads all four, two bytes each,
139 // around the correction table learning it does in each direction.
140 {0x56, 16, "CW start speed", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
141 "Not documented in the vendor's draft. The encoder calibration sequence reads it as an "
142 "unsigned 16-bit value. Write access is unknown."},
143 {0x58, 16, "CW end speed", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
144 "Not documented in the vendor's draft. The encoder calibration sequence reads it as an "
145 "unsigned 16-bit value. Write access is unknown."},
146 {0x5A, 16, "CCW start speed", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
147 "Not documented in the vendor's draft. The encoder calibration sequence reads it as an "
148 "unsigned 16-bit value. Write access is unknown."},
149 {0x5C, 16, "CCW end speed", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned,
150 "Not documented in the vendor's draft. The encoder calibration sequence reads it as an "
151 "unsigned 16-bit value. Write access is unknown."},
152 {0x60, 8, "Error status", KueblerAccess::kReadOnly, false, KueblerFormat::kBitField,
153 "Bit 7 - 3: Reserved; Bit 2: Command execution error; Bit 1: signal error; Bit 0: "
154 "Initialization error"},
155 {0x61, 8, "Error control", KueblerAccess::kWriteOnly, true, KueblerFormat::kBitField,
156 "Bit 7 - 2: Reserved; Bit 1: Clear all errors; Bit 0: Clear single error"},
157 {0x62, 32, "Error code 1", KueblerAccess::kReadOnly, false, KueblerFormat::kUnsigned, "TBD"},
158 {0x66, 32, "Error code 2", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned, "TBD"},
159 {0x6A, 32, "Error code 3", KueblerAccess::kReadOnly, true, KueblerFormat::kUnsigned, "TBD"},
160});
161
166constexpr std::optional<KueblerRegister> findKueblerRegister(uint8_t address) {
167 const auto entry = std::ranges::find(kKueblerRegisters, address, &KueblerRegister::address);
168 if (entry == kKueblerRegisters.end()) {
169 return std::nullopt;
170 }
171 return *entry;
172}
173
178inline constexpr uint8_t kMaxKueblerRegisterBytes = 4;
179
180} // namespace mm::node::somanet
Pure SOMANET (Synapticon manufacturer-specific) vocabulary — object indices, sub-entry numbers and en...
Definition ic_haus_registers.cc:7
void to_json(nlohmann::json &j, const IcHausField &field)
Serialises an IcHausField. Participates in nlohmann ADL.
Definition ic_haus_registers.cc:358
constexpr std::optional< KueblerRegister > findKueblerRegister(uint8_t address)
The register at address, or std::nullopt when the table has none.
Definition kuebler_registers.h:166
KueblerAccess
Whether the encoder allows reading a register, writing it, or both.
Definition kuebler_registers.h:49
constexpr uint8_t kMaxKueblerRegisterBytes
The largest register width OS command 19 can transfer, in bytes: its length byte is capped at 4....
Definition kuebler_registers.h:178
KueblerFormat
How a register's value should be read once assembled.
Definition kuebler_registers.h:39
@ kUnsigned
One unsigned integer of the register's width.
@ kSigned
One two's-complement integer of the register's width.
constexpr auto kKueblerRegisters
Every register known, ascending by address: the vendor's draft, plus the four the encoder calibration...
Definition kuebler_registers.h:78
One register of the Kübler encoder.
Definition kuebler_registers.h:52
std::string_view definition
Definition kuebler_registers.h:69
std::string_view name
The vendor's own name for it.
Definition kuebler_registers.h:55
uint8_t bits
Width in bits: 8, 16 or 32. See kMaxKueblerRegisterBytes.
Definition kuebler_registers.h:54
bool implemented
Definition kuebler_registers.h:62
KueblerAccess access
Definition kuebler_registers.h:56
KueblerFormat format
Definition kuebler_registers.h:64
uint8_t address
Register address, as OS command 19 carries it in byte 2.
Definition kuebler_registers.h:53