Background details: Using tmc4671 eval board with the 10A70V-EV-KIT + mpr80 BLDC motor from Parker
Is there any way to expand the x axis at all? Additionally, when tuning the velocity loop, my velocity P value will go to the max for the autotuning and manually it does not go high enough to be able to properly control the motor in closed loop control. Is there a way to get this value to go higher at all or is there something else I could be missing when tuning this control loop?
I also have had many times when I tune the control loop and save all the settings into a script in the tmcl ide and the next day it will just stop working completely. I have checked that my encoders are not drifting and they are outputting the right data.
I have also been confused on commands in the scripting because it seems MVP commands do not work in closed loop control and I have been opting to use WMC position target commands instead. The documentation for the IDE is outdated and doesn't include much for PI control tuning testing scripts.
If someone could point me in the direction of documentation that is more updated or if you have any info on these problems please reach out. The code for the script is pasted below.
// Select module
#module 1 COM11/USB/id1/LandungsbrueckeV3
// Use TMC4671 register addresses
#include TMC4671_register_addresses.tpc
// (C:/Users/alex.ziegler/AppData/Roaming/TRINAMIC Motion Control GmbH & Co. KG/TMCL-IDE/TMCL-Script/TMC4671_register_addresses.tpc)
//
WMC PWM_MAXCNT , 0, $00000F9F, 1 //0x18: PWM maximum (count-1), PWM frequency is fPWM[Hz] = 100MHz/(PWM_MAXCNT+1)
WMC PWM_BBM_H_BBM_L , 0, $00001919, 1 //0x19: Break Before Make time tBBM_L[10ns] for low side MOS-FET gate control
WMC PWM_SV_CHOP , 0, $00000007, 1 //0x1A: PWM chopper mode, defining how to chopper
//
WMC ADC_I_SELECT , 0, $24000100, 1 //0x0A: Select input for raw current ADC_I0_RAW.
WMC dsADC_MCFG_B_MCFG_A, 0, $00100010, 1 //0x04:
WMC dsADC_MCLK_A , 0, $20000000, 1 //0x05: fMCLK_A = 2^31 / (fCLK * (dsADC_MCLK_A+1)), dsADC_MCLK_A = (2^31 / (fMCLK * fCLK)) - 1
WMC dsADC_MCLK_B , 0, $20000000, 1 //0x06: fMCLK_B = 2^31 / (fCLK * (dsADC_MCLK_B+1)), dsADC_MCLK_B = (2^31 / (fMCLK * fCLK)) - 1
WMC dsADC_MDEC_B_MDEC_A, 0, $014E014E, 1 //0x07: 0: PWM synchron, others according to register content
//
WMC ADC_I0_SCALE_OFFSET, 0, $01008144, 1 //0x09: Offset for current ADC channel 0.
WMC ADC_I1_SCALE_OFFSET, 0, $01008167, 1 //0x08: Offset for current ADC channel 1.
WMC ADC_I_SELECT , 0, $18000100, 1 //0x0A: Select input for raw current ADC_I0_RAW.
WMC UQ_UD_EXT , 0, $00000FA0, 1 //0x24: External writable parameter for open loop voltage control mode, usefull during system setup, U_D component.
WMC dsADC_MDEC_B_MDEC_A, 0, $014E014E, 1 //0x07: 0: PWM synchron, others according to register content
//
WMC ABN_DECODER_MODE , 0, $00000000, 1 //0x25: Polarity of A pulse.
WMC ABN_DECODER_PPR , 0, $00039D00, 1 //0x26: Decoder pulses per mechanical revolution.
WMC ABN_DECODER_COUNT , 0, $0000D5CA, 1 //0x27: Raw decoder count; the digital decoder engine counts modulo (decoder_ppr).
WMC ABN_DECODER_COUNT_N , 0, $0001B606, 1 //0x28: Decoder count latched on N pulse, when N pulse clears decoder_count also decoder_count_n is 0.
WMC ABN_DECODER_PHI_E_PHI_M_OFFSET, 0, $00000000, 1 //0x29: ABN_DECODER_PHI_M_OFFSET to shift (rotate) angle DECODER_PHI_M.
WMC ABN_DECODER_PHI_E_PHI_M , 0, $B1093B03, 1 //0x2A: ABN_DECODER_PHI_M = ABN_DECODER_COUNT * 2^16 / ABN_DECODER_PPR + ABN_DECODER_PHI_M_OFFSET;
WMC PID_POSITION_ACTUAL , 0, $FFAD9FC7, 1 //0x6B: Actual multi turn position for positioning. WRITE on PID_POSITION_ACTUAL writes same value into PID_POSITION_TARGET to avoid unwanted move.
WMC MOTOR_TYPE_N_POLE_PAIRS , 0, $00030003, 1 //0x1B: Number n of pole pairs of the motor for calcualtion phi_e = phi_m / N_POLE_PAIRS.
// --- Limiter setup (set before entering velocity/position mode) ---
WMC PIDOUT_UQ_UD_LIMITS , 0, $00007FFF, 1 //max PWM/voltage output = 32767 (full)
WMC PID_TORQUE_FLUX_LIMITS , 0, $000007D0, 1 //current limit = 2000 (see units note)
WMC PID_VELOCITY_LIMIT , 0, $0001E848, 1 //velocity clamp = 125000 (set high to start)
WMC PID_POSITION_LIMIT_LOW , 0, $800146C0, 1 //-2,147,400,000
WMC PID_POSITION_LIMIT_HIGH, 0, $7FFEB940, 1 //+2,147,400,000
WMC MODE_RAMP_MODE_MOTION, 0, $00000003, 1 //0x1F: position mode
WMC PHI_E_SELECTION, 0, $00000003, 1 //0x52:
WMC VELOCITY_SELECTION, 0, $00000009, 1 //0x50: phi_m_abn (mechanical angle from ABN)
WMC POSITION_SELECTION, 0, $00000009, 1 //0x51: phi_m_abn
// PI control parameters (P in [31:16], I in [15:0])
WMC PID_FLUX_P_FLUX_I , 0, $2EE01B58, 1 //0x54: PID_FLUX_P = 12000, PID_FLUX_I = 7000
WMC PID_TORQUE_P_TORQUE_I , 0, $2EE01B58, 1 //0x56: PID_TORQUE_P = 12000, PID_TORQUE_I = 7000
WMC PID_VELOCITY_P_VELOCITY_I,0, $7FFF0FA0, 1 //0x58: PID_VELOCITY_P = 32767, PID_VELOCITY_I = 4000
WMC PID_POSITION_P_POSITION_I,0, $008C0000, 1 //0x5A: PID_POSITION_P = 140, PID_POSITION_I = 0
WMC PID_POSITION_ACTUAL, 0, $00000000, 1 //set position to 0
WAIT TICKS, 0, 5000
Loop:
WMC PID_POSITION_TARGET, 0, 5000, 1 // quarter turn, direct
WAIT TICKS, 0, 2000
WMC PID_POSITION_TARGET, 0, 15000, 1
WAIT TICKS, 0, 2000
WMC PID_POSITION_TARGET, 0, 0, 1
WAIT TICKS, 0, 2000
JA Loop