Motor Configuration¶
Configuration of the PiMotion™ motion controller is specific to the type of motor being controlled. PiMotion™ can be configured for 3-Phase brushless, stepper and voice-coil motors.
See also
See Configuration of 3-Phase Motors and Stepper motors for source code examples.
3-Phase Motor Configuration (with Encoder)¶
PiMotion™ is capable of being configured to control a 3-phase motor with an attached encoder. The encoder is used for both phase commutation and position feedback. Position feedback can also be generated from an option auxiliary encoder.
Motor and Encoder Type¶
The following parameters are required for configuration:
Parameter | Function/Method | Description |
---|---|---|
Motor Type | mtr_set_mtr_type | Set the Motor Type to MTR_TYPE_3PHASE. |
Poles | mtr_set_poles | Set the number of poles of the motor. |
Encoder Counts Per Rotation | mtr_set_enc_counts_per_rot | Set the number of encoder counts for one full rotation of the motor. Note: Counts are generated on the rising and falling edge of the encoder digital signals, therefore a 512 line encoder would have4 * 512 = 2048 counts per rotation. |
Encoder Polarity | mtr_set_enc_polarity | Set the motor type to MTR_TYPE_3PHASE. See Motor Type. |
Servo Loop (PID) Parameters¶
With the PiMotion™ 3-Phase brushless motors are controlled in a closed loop when used with an encoder. The following parameters need to be configured for PID Algorithm.
Parameter | Function/Method | Description |
---|---|---|
Encoder to use for PID | mtr_set_use_aux_enc_for_servo | It is possible to use the auxiliary encoder input for the PID. |
PID output polarity | mtr_set_output_polarity | The output of the PID can be inverted depending on how the system is configured. |
Servo loop update rate | mtr_set_elec_cycle_div | Set the update rate of the PID loop and Trajectory Generator. Output of the PID loop is calculated at this rate. |
Maximum current output | mtr_set_max_pid_output | Set the maximum allowed current to the motor. |
Maximum position error | mtr_set_max_pos_error | If the position error exceeds this value, the motor will turn off. |
Proportional gain | mtr_set_kp | Set the proportional gain. |
Integral gain | mtr_set_ki | Set the integral gain. |
Derivative gain | mtr_set_kd | Set the derivative gain. |
Integral limit | mtr_set_ilim | Set the integral limit. |
Commutation (reset) Configuration¶
With a 3-phase motor, the output waveform to each phase of the motor is specific to the poles and encoder counts per rotation. The PiMotion™ motor controller utilizes a waveform memory location to hold a custom waveform specific to the motor configuration. To align the phases of the motor with the attached encoder, a commutation (reset) sequence is required. The phases of the motor are energized and once the motor stops moving, the encoder position is captured. This captured encoder position is used as the phase offset.
Parameter | Function/Method | Description |
---|---|---|
Reset current | mtr_set_reset_current | Set the amount of current to energize the motor with during reset. |
Reset wait | mtr_set_reset_wait_time_ms | Set the amount of time to wait for the motor to stabilize (stop moving). |
Write phase memory | mtr_write_phase_mem_default | Create a waveform based on phases, poles, and encoder counts per rotation and write it to the phase memory table. |
Perform reset | mtr_reset | Start the reset sequence. This call will energize the motor with the specified current and after the specified wait time will then read the phase offset (from the encoder). |
Determine if complete | mtr_get_reset_state | This function can be called to see when the motor reset has completed. |
Stepper Motor Configuration (Open Loop)¶
The following parameters are required for configuration of a stepper motor in open-loop mode:
Parameter | Function/Method | Description |
---|---|---|
Motor Type | mtr_set_mtr_type | Set the Motor Type to MTR_TYPE_STEPPER. |
Trajectory generator update rate | mtr_set_elec_cycle_div | Set the update rate of the Trajectory Generator. |
Drive current to motor | mtr_set_open_loop_drive_current | The stepper motor is continuously driven at this current setting. |
Write phase memory | mtr_write_phase_mem_stepper | Create a waveform based on the microstepping multiplier and write it to the phase memory table. |
Perform reset | mtr_reset | Start the reset sequence. This call will energize the motor with the specified current. |
Determine if complete | mtr_get_reset_state | This function can be called to see when the motor reset has completed. |