|
MotorWare f2806x Module API Documentation
|
Data Structures | |
| struct | _ENC_Obj_ |
| Defines the encoder object. More... | |
Macros | |
| #define | ENC_SPEED_SCALING_FACTOR 16777216.0 |
| #define | ENC_ZERO_OFFSET 3813071.0 |
| #define | ENC_SPEED_CUTOFF_FREQ 100.0 |
| #define | ENC_SPEED_COEFF_Q 6 |
| #define | ENC_SPEED_COEFF_SCALING (1<<ENC_SPEED_COEFF_Q) |
| #define | ENC_2PI (2.0*3.14159) |
| #define | ENC_LOG_LEN 256 |
| #define | ENC_RPM_Q1 8 |
| #define | ENC_RPM_Q2 16 |
| #define | ENC_LOG_DELTA_TRIGGER_THRES 400 |
Typedefs | |
| typedef struct _ENC_Obj_ | ENC_Obj |
| Defines the encoder object. More... | |
| typedef struct _ENC_Obj_ * | ENC_Handle |
| Defines the encoder handle. More... | |
Enumerations | |
| enum | ENC_LOG_State_e { ENC_LOG_STATE_IDLE =0, ENC_LOG_STATE_FREERUN, ENC_LOG_STATE_ACQUIRE } |
| Enumeration for the encoder log states. More... | |
Functions | |
| void | ENC_calcElecAngle (ENC_Handle encHandle, uint32_t posnCounts) |
| Reads encoder and returns the electrical degrees in Q24 format. More... | |
| _iq | ENC_getElecAngle (ENC_Handle encHandle) |
| Returns the electrical angle. More... | |
| _iq | ENC_getMagneticAngle (ENC_Handle encHandle) |
| Returns the magnetic angle. More... | |
| _iq | ENC_getFilteredSpeed (ENC_Handle encHandle) |
| Returns the low-pass filtered speed output. More... | |
| int16_t | ENC_getSpeedRPM (ENC_Handle encHandle) |
| Returns the filtered speed in RPM. More... | |
| ENC_Handle | ENC_init (void *pMemory, const size_t numBytes) |
| Initializes the encoder object. More... | |
| 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". More... | |
| void | ENC_setIncrementalSlip (ENC_Handle encHandle, _iq incrementalSlip) |
| Set the amount of incremental slip. More... | |
| void | ENC_setRunFlag (ENC_Handle encHandle) |
| Start logging encoder data. More... | |
| void | ENC_setZeroOffset (ENC_Handle encHandle, uint32_t zeroOffset) |
| Sets the value for the encoder object zero offset. More... | |
| 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. More... | |
| struct _ENC_Obj_ |
| Data Fields | ||
|---|---|---|
| int32_t | delta_enc | encoder count delta |
| int32_t | enc_elec_angle | encoder current electrical angle |
| int32_t | enc_magnetic_angle | encoder current magnetic angle (compensated for slip) |
| int32_t | enc_slip_angle | amount of total slip |
| uint32_t | enc_zero_offset | encoder zero offset in counts |
| float_t | full_scale_freq | full scale frequency |
| int32_t | incremental_slip | incremental amount of slip |
| int16_t | log[ENC_LOG_LEN] | encoder log length |
| int32_t | log_idx | encoder log index |
| ENC_LOG_State_e | log_state | encoder log state |
| _iq | mech_angle_gain | gain which converts the encoder counts to Q24 mechanical degrees |
| uint16_t | num_enc_slots | number of encoder slots |
| uint16_t | num_pole_pairs | number of pole pairs in motor |
| int16_t | post_trigger_cnt | encoder log post trigger counter |
| int16_t | post_trigger_len | encoder log post trigger length |
| int32_t | prev_enc | previous encoder reading |
| int32_t | rpm_gain | gain which converts the Q24 normalized electrical freq to RPM |
| int16_t | run_flag | encoder log free run flag |
| int16_t | sample_count | when it reaches the sample period, collect & process encoder data |
| int16_t | sample_period | sample period of encoder processing |
| float_t | speed_cutoff | speed cutoff frequency in Hz |
| int32_t | speed_gain | gain which converts a difference in encoder counts to Q24 normalized electrical freq |
| int32_t | speed_lpf_cx | speed input coefficient |
| int32_t | speed_lpf_cy | speed output coefficient |
| int32_t | speed_lpf_out | speed lpf output |
| int16_t | trigger_delta | calculated delta when trigger happened |
| int16_t | trigger_idx | index where trigger event happened |
| #define ENC_2PI (2.0*3.14159) |
Definition at line 65 of file enc.h.
Referenced by ENC_setup().
| #define ENC_LOG_DELTA_TRIGGER_THRES 400 |
| #define ENC_LOG_LEN 256 |
Definition at line 66 of file enc.h.
Referenced by ENC_run(), and ENC_setup().
| #define ENC_RPM_Q1 8 |
Definition at line 67 of file enc.h.
Referenced by ENC_getSpeedRPM().
| #define ENC_RPM_Q2 16 |
Definition at line 68 of file enc.h.
Referenced by ENC_getSpeedRPM().
| #define ENC_SPEED_COEFF_SCALING (1<<ENC_SPEED_COEFF_Q) |
Definition at line 64 of file enc.h.
Referenced by ENC_setup().
| #define ENC_SPEED_SCALING_FACTOR 16777216.0 |
Definition at line 60 of file enc.h.
Referenced by ENC_setup().
| typedef struct _ENC_Obj_* ENC_Handle |
| enum ENC_LOG_State_e |
| void ENC_calcElecAngle | ( | ENC_Handle | encHandle, |
| uint32_t | posnCounts | ||
| ) |
Reads encoder and returns the electrical degrees in Q24 format.
| [in] | encHandle | Handle to the ENC object |
| [in] | posnCounts | Current position counts from encoder |
Definition at line 129 of file enc.c.
References _ENC_Obj_::enc_elec_angle, _ENC_Obj_::enc_magnetic_angle, _ENC_Obj_::enc_slip_angle, _ENC_Obj_::enc_zero_offset, _ENC_Obj_::incremental_slip, _ENC_Obj_::mech_angle_gain, and _ENC_Obj_::num_pole_pairs.
|
inline |
Returns the electrical angle.
| [in] | encHandle | Handle to the ENC object |
Definition at line 136 of file enc.h.
References _ENC_Obj_::enc_elec_angle.
|
inline |
Returns the low-pass filtered speed output.
| [in] | encHandle | Handle to the ENC object |
Definition at line 156 of file enc.h.
References _ENC_Obj_::speed_lpf_out.
|
inline |
Returns the magnetic angle.
| [in] | encHandle | Handle to the ENC object |
Definition at line 146 of file enc.h.
References _ENC_Obj_::enc_magnetic_angle.
| int16_t ENC_getSpeedRPM | ( | ENC_Handle | encHandle | ) |
Returns the filtered speed in RPM.
| [in] | encHandle | Handle to the ENC object |
Definition at line 300 of file enc.c.
References ENC_RPM_Q1, ENC_RPM_Q2, _ENC_Obj_::rpm_gain, and _ENC_Obj_::speed_lpf_out.
| ENC_Handle ENC_init | ( | void * | pMemory, |
| const size_t | numBytes | ||
| ) |
| 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".
| [in] | encHandle | Handle to the ENC object |
| [in] | posnCounts | Current position counts from encoder |
| [in] | indextFlag | If set, there was an index |
| [in] | dirFlag | Indicates direction of rotation |
| [in] | log_flag | If set, logs the encoder data |
Definition at line 163 of file enc.c.
References _ENC_Obj_::delta_enc, _ENC_Obj_::enc_elec_angle, ENC_LOG_DELTA_TRIGGER_THRES, ENC_LOG_LEN, ENC_LOG_STATE_ACQUIRE, ENC_LOG_STATE_FREERUN, ENC_LOG_STATE_IDLE, ENC_SPEED_COEFF_Q, _ENC_Obj_::enc_zero_offset, _ENC_Obj_::log, _ENC_Obj_::log_idx, _ENC_Obj_::log_state, _ENC_Obj_::mech_angle_gain, _ENC_Obj_::num_enc_slots, _ENC_Obj_::num_pole_pairs, _ENC_Obj_::post_trigger_cnt, _ENC_Obj_::post_trigger_len, _ENC_Obj_::prev_enc, _ENC_Obj_::run_flag, _ENC_Obj_::sample_count, _ENC_Obj_::sample_period, _ENC_Obj_::speed_gain, _ENC_Obj_::speed_lpf_cx, _ENC_Obj_::speed_lpf_cy, _ENC_Obj_::speed_lpf_out, _ENC_Obj_::trigger_delta, and _ENC_Obj_::trigger_idx.
|
inline |
Set the amount of incremental slip.
| [in] | encHandle | Handle to the ENC object |
| [in] | incrementalSlip | Amount of incremental slip in Electrical Angle |
Definition at line 189 of file enc.h.
References _ENC_Obj_::incremental_slip.
|
inline |
Start logging encoder data.
| [in] | encHandle | Handle to the ENC object |
Definition at line 201 of file enc.h.
References _ENC_Obj_::run_flag.
| 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.
| [in] | encHandle | Handle to the ENC object |
| [in] | sample_period | How often the encoder is read & processed |
| [in] | num_pole_pairs | Number of pole pairs in motor |
| [in] | num_enc_slots | Number of encoder slots |
| [in] | enc_zero_offset | Encoder zero offset in counts |
| [in] | full_scale_freq | Full scale speed for normalization |
| [in] | speed_update_freq | Update frequency in Hz for speed calculation |
| [in] | speed_cutoff | Speed calculation LPF cutoff frequency in Hz |
Definition at line 68 of file enc.c.
References _ENC_Obj_::delta_enc, ENC_2PI, _ENC_Obj_::enc_elec_angle, ENC_LOG_LEN, ENC_LOG_STATE_IDLE, ENC_SPEED_COEFF_SCALING, ENC_SPEED_SCALING_FACTOR, _ENC_Obj_::enc_zero_offset, _ENC_Obj_::full_scale_freq, _ENC_Obj_::log, _ENC_Obj_::log_idx, _ENC_Obj_::log_state, _ENC_Obj_::mech_angle_gain, _ENC_Obj_::num_enc_slots, _ENC_Obj_::num_pole_pairs, _ENC_Obj_::post_trigger_cnt, _ENC_Obj_::post_trigger_len, _ENC_Obj_::prev_enc, _ENC_Obj_::rpm_gain, _ENC_Obj_::run_flag, _ENC_Obj_::sample_count, _ENC_Obj_::sample_period, _ENC_Obj_::speed_cutoff, _ENC_Obj_::speed_gain, _ENC_Obj_::speed_lpf_cx, _ENC_Obj_::speed_lpf_cy, _ENC_Obj_::speed_lpf_out, _ENC_Obj_::trigger_delta, and _ENC_Obj_::trigger_idx.
|
inline |
Sets the value for the encoder object zero offset.
| [in] | encHandle | Handle to the ENC object |
| [in] | zeroOffset | New zero offset |
Definition at line 214 of file enc.h.
References _ENC_Obj_::enc_zero_offset, and _ENC_Obj_::mech_angle_gain.
1.8.9.1