Position Sensor (positionSensor)
Reads the shaft angle, mechanical and electrical, as signals.
Group: Mechanical · Kind: {"element":"positionSensor","kind":"mechanical"}
When to use it
Use it to feed the rotor angle to field-oriented control or a Park transform. Use Incremental Encoder for counts, Resolver for sin and cos, and Hall Sensors for six-step drives.
Pins
| Pin | Domain | Meaning |
|---|---|---|
shaft |
mechanical | Shaft terminal, it reads speed and loads nothing |
out |
signal | Mechanical angle in rad, wraps every turn |
elec |
signal | Electrical angle in rad, wraps every cycle |
Common parameters
poles: Number of poles of the machine (Default: 2)theta0: Shaft angle at the start (Default: 0)
Parameters
| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
poles |
— | 2 | Number of poles of the machine | |
theta0 |
rad | 0 | Shaft angle at the start |
Parameter descriptions are in English in both languages.
Model
The sensor integrates the shaft speed by the trapezoidal rule starting at theta0, so the angle is not read from the machine. The outputs are out = angle wrapped to [0, 2π) and elec = (poles/2)·angle, wrapped the same way. The sensor is ideal, with no quantization, offset or noise.
Common mistakes
- The sensor angle starts at its own theta0 in mechanical radians, while the machine theta0 is an electrical angle. For a magnet machine set the sensor theta0 to the machine theta0 divided by the pole pairs, or the dq frame is rotated by the difference.
- poles must equal the pole count of the machine, not its pole pairs, and must be even. A mismatch makes the electrical angle run at the wrong rate, and an odd value is refused.
- The outputs wrap around every turn. A Park transform accepts the wrapped angle, but a controller that needs a continuous angle must integrate the speed itself.
Problems rules: compile.error
Datasheet and sources
poles is the pole count of the machine on the shaft, from its datasheet. theta0 is the rotor angle at the start of the run in mechanical radians, a design value that must match the starting position of the machine.
Example
Open the example with the command file.openExample and the name demo:positionSensor.
Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.