60 #define ENC_SPEED_SCALING_FACTOR 16777216.0
61 #define ENC_ZERO_OFFSET 3813071.0
62 #define ENC_SPEED_CUTOFF_FREQ 100.0
63 #define ENC_SPEED_COEFF_Q 6
64 #define ENC_SPEED_COEFF_SCALING (1<<ENC_SPEED_COEFF_Q)
65 #define ENC_2PI (2.0*3.14159)
66 #define ENC_LOG_LEN 256
69 #define ENC_LOG_DELTA_TRIGGER_THRES 400
173 extern ENC_Handle
ENC_init(
void *pMemory,
const size_t numBytes);
183 void ENC_run(ENC_Handle encHandle, uint32_t posnCounts, uint16_t indextFlag, uint16_t dirFlag, int16_t log_flag);
242 #endif // end of _ENC_H_ definition
int16_t post_trigger_len
encoder log post trigger length
int16_t trigger_idx
index where trigger event happened
struct _ENC_Obj_ ENC_Obj
Defines the encoder object.
int16_t run_flag
encoder log free run flag
void ENC_run(ENC_Handle encHandle, uint32_t posnCounts, uint16_t indextFlag, uint16_t dirFlag, int16_t log_flag)
Based on the encoder reading, computes the electrical angle and the electrical "speed".
Contains the public interface to the types definitions.
float_t full_scale_freq
full scale frequency
void ENC_setZeroOffset(ENC_Handle encHandle, uint32_t zeroOffset)
Sets the value for the encoder object zero offset.
int32_t speed_lpf_cy
speed output coefficient
int32_t delta_enc
encoder count delta
int16_t sample_count
when it reaches the sample period, collect & process encoder data
int32_t speed_lpf_cx
speed input coefficient
int32_t rpm_gain
gain which converts the Q24 normalized electrical freq to RPM
uint16_t num_pole_pairs
number of pole pairs in motor
int32_t prev_enc
previous encoder reading
uint32_t enc_zero_offset
encoder zero offset in counts
Defines the encoder object.
_iq ENC_getFilteredSpeed(ENC_Handle encHandle)
Returns the low-pass filtered speed output.
int16_t sample_period
sample period of encoder processing
void ENC_setIncrementalSlip(ENC_Handle encHandle, _iq incrementalSlip)
Set the amount of incremental slip.
int16_t trigger_delta
calculated delta when trigger happened
int32_t incremental_slip
incremental amount of slip
_iq ENC_getMagneticAngle(ENC_Handle encHandle)
Returns the magnetic angle.
ENC_Handle ENC_init(void *pMemory, const size_t numBytes)
Initializes the encoder object.
void ENC_calcElecAngle(ENC_Handle encHandle, uint32_t posnCounts)
Reads encoder and returns the electrical degrees in Q24 format.
ENC_LOG_State_e
Enumeration for the encoder log states.
void ENC_setup(ENC_Handle encHandle, const int16_t sample_period, const uint16_t num_pole_pairs, const uint16_t num_enc_slots, const uint32_t enc_zero_offset, const float_t full_scale_freq, const float_t speed_update_freq, const float_t speed_cutoff)
Initializes encoder object parameters.
int32_t enc_elec_angle
encoder current electrical angle
int32_t log_idx
encoder log index
int16_t post_trigger_cnt
encoder log post trigger counter
uint16_t num_enc_slots
number of encoder slots
int32_t enc_magnetic_angle
encoder current magnetic angle (compensated for slip)
int32_t enc_slip_angle
amount of total slip
ENC_LOG_State_e log_state
encoder log state
int32_t speed_lpf_out
speed lpf output
void ENC_setRunFlag(ENC_Handle encHandle)
Start logging encoder data.
int16_t ENC_getSpeedRPM(ENC_Handle encHandle)
Returns the filtered speed in RPM.
int32_t speed_gain
gain which converts a difference in encoder counts to Q24 normalized electrical freq ...
float_t speed_cutoff
speed cutoff frequency in Hz
struct _ENC_Obj_ * ENC_Handle
Defines the encoder handle.
_iq mech_angle_gain
gain which converts the encoder counts to Q24 mechanical degrees
_iq ENC_getElecAngle(ENC_Handle encHandle)
Returns the electrical angle.
int16_t log[ENC_LOG_LEN]
encoder log length
float float_t
Defines the portable data type for 32 bit, signed floating-point data.