Encoder and Position
JCS network on-axis absolute encoder is based on an Austria Micro AS5047p magnetic sensing absolute encoder.
At each encoder tick, the rotational position of the sense magnet is sampled and passed through a two state Kalman filter, from which an estimate of the rotational position and velocity of the magnet is obtained.
Encoder/estimator tick rate (\(f\)) | 10kHz |
op_state warning bits |
Bit 3 - Encoder zero'd flag Bit 4 - Velocity warning flag Bit 5 - Position maybe invalid flag |
Parameters
The following parameters are available for configuring the encoder:
Command | Type | Required | Description |
---|---|---|---|
encoder_position_zero |
command | Optional | Records the current encoder position as the zero offset. |
encoder_position_offset |
float32 | Optional | Sets or returns the rotor position offset. |
encoder_direction |
boolean | Required | Sets the encoder direction. |
encoder_linearisation_coeffs |
float32 array | Optional | An array of 64 coefficients for encoder linearisation. If any elements are non-zero, encoder linearisation is activated. |
encoder_error_rate_limit |
float32 | Optional | Encoder error rate limit. Default: 0.05 Set to 1.0f to disable. |
estimator_theta_passthrough |
boolean | Optional | Bypasses the estimator such that the position obtained from the encoder is presented to JCS output signal th .Note - The estimator will still produce a velocity estimate output at JCS signal w_m . |
Encoder position zeroing and offset
An encoder may be zeroed by either writing a zero offset or commanding the system to sample the current encoder position as the zero offset.
To store the encoder current position as the zero offset, issue JCS command encoder_position_zero
. The encoder position will be sampled and stored in encoder_position_offset
. The sampled zero position may be read as a float32 from encoder_position_offset
.
To write an encoder offset, write a float32 to encoder_position_offset
. Any existing entry will be overwritten.
Encoder direction
Set the encoder direction with a boolean write to encoder_direction
.
Encoder linearisation
The encoder system supports linearisation of the encoder position by means of a lookup table for correction. The linearisation process takes the scaled encoder value and adds a small corrective bias term that is derived from the linear interpolation of the correction table.
Encoders may be linearised by writing an array of 64 linearisation coefficients to encoder_linearisation_coeffs
.
Maximum velocity
If the rotational velocity exceeds the maximum rotational speed of the hardware device (28000RPM), op_state
velocity warning
flag will be latched.
The op_state
velocity warning
flag is cleared on zeroing the encoder, a call to start
or a power cycle.
Error error handling
The encoder system is monitored for errors and registers errors as they occur.
If an encoder error occurs, the previous timestep encoder value is used and the encoder manager will attempt to continue.
op_state
encoder warning
flag will be asserted for the duration of the error.
If a flood of errors occur such that the error rate goes above the limit set in encoder_error_rate_limit
, then an E-stop will be generated and the system will attempt to shut down.
To tune the encoder error rate monitor, write a float32 to encoder_error_rate_limit
:
Command | Type | Required | Description |
---|---|---|---|
encoder_error_rate_limit |
float32 | Optional | Configures the encoder error rate limit. Valid values between [0.0f, 1.0f] Default: 0.05f Set to 1.0f to disable. |
encoder_error_rate |
float32 | Optional | Returns the encoder error rate. Read only. |
Notes:
- Disabling the error rate monitor is recommended for encoder testing only.
- If the error rate monitor is disabled encoders will still attempt to return a valid position, regardless if the data is erroneous. This may be useful for debugging
- The encoder error rate is available as JCS signal
encoder_error_rate
even if the error rate monitor is disabled.
Supported Position and Velocity Estimators
The following position and velocity estimators are available:
Estimator type | Description |
---|---|
tracking_loop |
Tracking loop based estimator. Default |
kf |
Two state Kalman filter based estimator. |
Tracking Loop Estimator
A rotational tracking loop estimator that produces estimates of rotational position and velocity.
Select the tracking loop estimator by writing enum value tracking_loop
to estimator_type
.
The tracking loop estimator has good performance and is recommended as a starting point for many applications.
Configure the estimator with the following parameters:
Command | Type | Required | Description |
---|---|---|---|
estimator_tracking_loop_kp |
float32 | Optional | Tracking loop proportional gain term. |
estimator_tracking_loop_ki |
float32 | Optional | Tracking loop integral gain term. |
estimator_tracking_loop_bandwidth_hz |
float32 | Optional | Sets the tracking loop bandwidth (Hz). Kp and Ki will be computed and populated by setting this parameters. |
Compute gains from bandwidth
The tracking loop gains \(K_p\) and \(K_i\) may be computed from a desired bandwidth by setting parameter estimator_tracking_loop_bandwidth_hz
.
The gains are computed as:
\(BW_{rad/S} = 2\pi BW_{Hz}\)
\(K_p = 2 BW_{rad/S}\)
\(K_i = {1\over4} {K_p}^2\)
Estimator theta pass-through
Setting estimator_theta_bypass
to true will cause the system to derive the JCS signal th_m
directly from the encoder, rather than from the estimator.
JCS signal w_m
will still be derived from the active estimator.
Note that the bypassed theta position will still retain the following properties:
- May have zero offset applied
- May have linearisation compensation applied
- Normalised to \([-\pi, \pi]\)