This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28069: InstaSPIN Motorware change motor parameters

Part Number: TMS320F28069
Other Parts Discussed in Thread: MOTORWARE

Tool/software: Code Composer Studio

Hi,

I am using InstaSPIN Motorware and I defined my motor in user.h with its parameters.

My motor is running correctly after setting gMotorVars.Flag_Run_Identify = true.

Now we have an EEPROM on our board, which stores different motorparameters for different motors. We get these parameters all with the motoridentification from lab02a. When I want to change the motor (motor is not running), I get new parameter from eeprom and store these parameter in gMotorVars and gUserParams and I call CTRL_setParams().

Starting the other motor by setting gMotorVars.Flag_Run_Identify = true doesn't works now and I don't know why. The motor is trying to start but it is not running.

When I change the motor parameters in user.h it works fine with the other motor.

What do I have to do, to change motor in runtime (motor is not running)?

This is my code running, when I change the motor parameters:

    gMotorVars.Rs_Ohm = eeprom_structure.motor_params_arr[mot].Rs_Ohm;
    gMotorVars.Rr_Ohm = eeprom_structure.motor_params_arr[mot].Rr_Ohm;

    gMotorVars.Lsd_H = eeprom_structure.motor_params_arr[mot].Ls_q_d_H;
    gMotorVars.Lsq_H = eeprom_structure.motor_params_arr[mot].Ls_q_d_H;

    gMotorVars.MagnCurr_A = eeprom_structure.motor_params_arr[mot].magnetizing_current_A;
    gMotorVars.SpeedRef_krpm = _IQ(eeprom_structure.motor_params_arr[mot].speed_run_rpm / 1000.0);
    gMotorVars.MaxAccel_krpmps = _IQ(eeprom_structure.motor_params_arr[mot].speed_run_accel_rpmps / 1000.0);

    gMotorVars.Kp_spd = _IQ(eeprom_structure.motor_params_arr[mot].Kp_spd);
    gMotorVars.Ki_spd = _IQ(eeprom_structure.motor_params_arr[mot].Ki_spd);

    gMotorVars.Kp_Idq = _IQ(eeprom_structure.motor_params_arr[mot].Kp_Idq);
    gMotorVars.Ki_Idq = _IQ(eeprom_structure.motor_params_arr[mot].Ki_Idq);

    // set the kp and ki speed values from the watch window
    CTRL_setKp(ctrlHandle, CTRL_Type_PID_spd, gMotorVars.Kp_spd);
    CTRL_setKi(ctrlHandle, CTRL_Type_PID_spd, gMotorVars.Ki_spd);

    // set the kp and ki current values for Id and Iq from the watch window
    CTRL_setKp(ctrlHandle, CTRL_Type_PID_Id, gMotorVars.Kp_Idq);
    CTRL_setKi(ctrlHandle, CTRL_Type_PID_Id, gMotorVars.Ki_Idq);
    CTRL_setKp(ctrlHandle, CTRL_Type_PID_Iq, gMotorVars.Kp_Idq);
    CTRL_setKi(ctrlHandle, CTRL_Type_PID_Iq, gMotorVars.Ki_Idq);

    gMotorVars.RsOnLineCurrent_A = (0.1 * eeprom_structure.motor_params_arr[mot].max_current_A);

    gUserParams.maxCurrent = eeprom_structure.motor_params_arr[mot].max_current_A;
    gUserParams.motor_numPolePairs = eeprom_structure.motor_params_arr[mot].motor_num_pole_pairs;
    gUserParams.motor_ratedFlux = eeprom_structure.motor_params_arr[mot].motor_rated_flux_VpHz;
    gUserParams.motor_Rr = gMotorVars.Rr_Ohm;
    gUserParams.motor_Rs = gMotorVars.Rs_Ohm;
    gUserParams.motor_Ls_d = gMotorVars.Lsd_H;
    gUserParams.motor_Ls_q = gMotorVars.Lsq_H;
    gUserParams.IdRated = eeprom_structure.motor_params_arr[mot].magnetizing_current_A;
    gUserParams.fluxEstFreq_Hz = eeprom_structure.motor_params_arr[mot].flux_est_freq_Hz;
    gUserParams.maxNegativeIdCurrent_a = (-0.5 * gUserParams.maxCurrent);

    // set the default controller parameters
    CTRL_setParams(ctrlHandle,&gUserParams);

Best regards,

Dani

  • It's probably not a good idea to invoke CTRL_setParams() as it will also reset the Ctrl freq, counters, and a bunch of flags. You most likely only need to call CTRL_setMotorParams() specifically.

    We don't advocate changing the values on the fly, and don't have an example that performs this function. Please try calling just CTRL_setMotorParams() and let us know the results

    Sean
  • Hi,

    Calling only function CTRL_setMotorParams() does not work. Is it better to make some global variables for MotorParameters and restart the device to load everithing with the new parameters?

    Dani

  • Can you elaborate on "does not work?" If it is possible to restart the estimator and controller completely, that is definitely one way that you can reload the motor parameters

    Sean
  • It does not work means the motor is not starting with the new parameters.

    Changing only motorparameters does not work, because some motor-parameters are used for other defines in code.

    I changed the startup of my device now. First I initialize HAL driver, read eeprom values and then use this eeprom values to initialize gMotorVars and gUserParams. Then I do the complete startup of motorware afterwards. This works now. But I had to change USER_setParams() to work with variables and not with the defines in user.h and also the function USER_checkForErrors().

    After changing my motor, I do a restart of the device to load the new parameters.

    Best regards,

    Dani