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.

Spin Motor user variables

Hi,

Does any one knows which variable is what ?

gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)};

I see there are 3 _IQ's to set here

Which one is doing what ?

these are part of this:

USER_Params gUserParams;

HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)};

HAL_AdcData_t gAdcData;

_iq gMaxCurrentSlope = _IQ(0.0);

in example of lab05a

I need to setup speed only of my Motor

Thanks,

Roee

  • "Which one is doing what ?"
    these are the duty cycles of the PWMs.

    "in example of lab05a

    I need to setup speed only of my Motor"

    5a is torque control. In 5a you set an IqRef_A. This is clearly discussed in the InstaSPIN_labs.pdf document. Are you reading the instructions?
  • OK,

    Let me know if I am correct:

    1. In Order to calculate Ki(series), I can do the following:

      a. Measure my coil resistance  by calculation-> this is by supplying current into 2 phases - when the motor is in static mode and looking at the current  (I am not sure if this is accurate) -> So My R=U/I (which I is the measured current), and the voltage is from my power supply

    2. I can measure My coil inductance with Inductance meter (I have pretty accurate one)

    -- This enable me to find my Ki(series) pretty accurate I think

    3. About Kp - I can use estimation of 10Khz (like in example), and calculate It with Ls*2pi*(10Khz/20)

    4. In the main loop I see I need to get and set these parameters?

    Also earlier labs -> shouldn't they show me these values by measuring actual parameters from Motor ?

    When trying to change them  (Ki and Kp Manually) I got this:

    And since The Motor is in close loop spinning perfectly so I can estimate that the values in the window are accurate.

    BTW when running few times some of parameters change ..... (so measure is not the same....)

    Now with these I need to set on Lab 5b the following: (on main proj_lab05b.c)

      gMotorVars.Flag_enableSys=1; //roee
      gMotorVars.Flag_Run_Identify = true; //roee
      gMotorVars.SpeedRef_krpm= 500;

    This is not working

    so I guess I need to setup something in the forever loop ?

    By lab5b I need in the forever loop to get these parameters while spinning and set them again all the time:

    By this:

    Is this correct ?

    Thanks,

    roee

  • USER_calcPIgains shows how the current control gains are calculated and set

    you shouldn't change them unless you have done a step response test and feel that they should be adjusted

    the speed control gains are NOT calculated for you. a starting Kp and Ki are chosen simply based off the USER_MOTOR_MAX_CURRENT setting. You should do step response testing and tune these values to meet your application requirements.
  • so I don't get it

    How come in Lab 2C My Motor is spinning OK

    And Lab 5B which uses the same user.h file and I have added thes to main.c of the project (proj_lab05b.c)

    gMotorVars.Flag_enableSys=1; //roee
    gMotorVars.Flag_Run_Identify = true; //roee
    gMotorVars.SpeedRef_krpm= 500;

    My Motor doesn't start to spin ?

  • try this

    gMotorVars.Flag_enableSys = 1; //roee
    gMotorVars.Flag_enableUserParams = 1;
    gMotorVars.Flag_Run_Identify = 1; //roee
    gMotorVars.SpeedRef_krpm = _IQ(0.5);


    before
    for(;;)
  • You are expert!
    Working
    But the speed seems much lower than 500 RPM
    What parameter I should play with now ?
    Thanks!
  • OK
    I see also that if I am changing my _IQ change my RPM changes according
    Seems like number of Poles incorrect?
    I have 6 poles in my Motor
    I have chosen:
    #define USER_MOTOR_NUM_POLE_PAIRS (3)
    Since these are PAIR
    Is this correct?
    Or I should put 6 ?
    Thanks
    Roee
  • 6 poles is 3 pairs
    _IQ(0.5) will set a speed of 0.5 KRPM = 500 RPM

    it is actually setting a frequency of 500 RPM * USER_MOTOR_NUM_POLE_PAIRS / 60 = 25 Hz

    everything inside the algorithm is in electrical Hz. The RPM is just created from # of pole pairs to give you an RPM.

    If you think it is low it could be you have # of poles incorrect, not enough voltage on the bus, or incorrect motor parameters
  • Thanks,
    Ok
    I have succeeded already to read my Potentiometer Value while spinning the motor.
    But when I am trying to change Motor _IQ -> to change spinning speed it doesn't
    Although I see that my reading are OK
    Isn't it enough to write this in order to change spinning rotation:

    if (gPotentiometer<0.1)
    {
    gMotorVars.SpeedRef_krpm = _IQ(1);
    }
    else
    {
    gMotorVars.SpeedRef_krpm = _IQ(2);
    }

    Do I need to do aditional thing while spinning to change spinning speed ?
    BR,
    Roee