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.

Switching between torque control and speed control?

Other Parts Discussed in Thread: MOTORWARE

Hello -

Is it possible to modify the lab 5b source code from Motorware such that i can flip a flag back and forth in the watch window to switch between using just the torque control loop and the speed (torque + speed) control loops? Any pointers on this?

Thanks!

-asifjahmed

  • yes, you can write logic to do this.

    what you will want to do though is make sure that as you switch from torque mode to speed that you seed the output of the speed controller with the present Iq_ref. This way you don't create a torque "blip"
  • Hello InstaSPIN Team!

    I need to bring this thread up from the dead. I'm just now getting around to focusing on this functionality in our project.

    I want to use speed control at low throttle values, and then transition (as seamlessly as possible) to torque control once the throttle reference reaches a threshold.

    I currently have the controllers switching back forth by simply using "CTRL_setFlag_enableSpeedCtrl". I do in fact get a torque blip when switching from Torque control to speed control (not the other way around, obviously).

    The confusion comes into play with regard to setting the proper reference values. I wrote some code to seed the Speed reference with the current measured speed when enabling speed control, but i still get the blip. I've seen suggestions to "seed the output value of the Speed controller with the current Iq ref" and this makes perfect sense on paper, but it is really unclear how to do this in code. Can someone please point me to which values need to be updated? An example of this would be a great bonus as well.

    Best,

    -asifjahmed

  • I'll let Yanming respond, but you need to set the Ui value in the Speed PID equal to the IqRef_pu of the throttle
  • As Chris reply, you need to set the Ui value of speed PID as below when switch between speed control and torque control.

    1. Switch from speed control to torque control

    CTRL_setFlag_enableSpeedCtrl(ctrlHandle, false);

    _iq Iq_ref_threshold = CTRL_getSpd_out_pu(ctrlHandle);

    CTRL_setIq_ref_pu(ctrlHandle, Iq_ref_threshold)

    And then increase/decrease Iq_ref_threshold to target throttle value.

    2. Switch from torque control to speed control

    _iq Iq_ref_threshold = CTRL_getIq_ref_pu(ctrlHandle);

    CTRL_setUi(ctrlHandle, CTRL_Type_PID_spd, Iq_ref_threshold)

    _iq Spd_ref_threshold = EST_getFm_pu(obj->estHandle);
    TRAJ_setIntValue(obj->trajHandle_spd, Spd_ref_threshold);

    CTRL_setFlag_enableSpeedCtrl(ctrlHandle, true);

    And then increase/decrease Spd_ref_threshold to target speed value.
  • Asif,

    I understand you mastered the switch between speed and torque control and back. Did you implement finally on proj_lab05b? I am currently using proj_lab05e.

    1. Why did you decide not to use the SpinTAC speed controller?

    2. Would you mind sharing your code with  me?

    3. Do you think a similar apporach can be applied to SpinTAC controller?

    (I am still investigating myself and I wll keep the forum posted with my progress. Just I wanted to try to get early feedback.)

    Thank you,
    Tomas

  • Hi Tomas -

    Yes, I made the modifications to lab 5b and 11b.

    I do not use SpinTAC in this application because I do not need position control, and the C2000 processers are quite cheaper with just FOC and not MOTION.

    I will share the code. Actually, I have shared it here before, please see 

    Lastly, yes I am sure this can easily be implemented on SpinTAC. But I have not done so.

    Best,

    -asifjahmed

  • Thank you Asif!

    I could make it work for SpinTAC with the link.