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.

[Beginner] Looking for guidance to control rpm of hobby motor (lab4)

Other Parts Discussed in Thread: TMS320F28027F

So my goal is to be able to control the rpm of a hobby motor up to ~2000 rpm. I have no experience in working with motors and so I hoped purchasing TI's motor solutions items would allow me to accomplish my seemingly trivial goal quickly.

I have completed the InstaSPIN labs up to lab4 and I do not have a issues with finding the calibrated motor values such as Rs, Ld, etc but I cannot get the motor to spin as I increase gMotorVars.IqRef_A. As I increment by 0.1, when I get to 0.9 my motor goes nuts (along with my power supply) and I need to immediately shut off power.

I have followed all of the steps in the lab document so I am not sure what could be causing this. One idea is that I have some incorrect values in my user.h file, but as I am new to motors, it is difficult for me to make sure they are all correct. 

I'd really appreciate help with this. Thank you in advance.

The current parameters I set that I was not sure of are:

#define USER_IQ_FULL_SCALE_FREQ_Hz        (800.0)

#define USER_IQ_FULL_SCALE_VOLTAGE_V      (18.0)

#define USER_IQ_FULL_SCALE_CURRENT_A         (20.0)

#define USER_PWM_FREQ_kHz                (45.0)

#define USER_MOTOR_RES_EST_CURRENT      (1.5)
#define USER_MOTOR_IND_EST_CURRENT      (-1.5)
#define USER_MOTOR_FLUX_EST_FREQ_Hz     (200.0)

Here is a list of all the things I am using:

-Motor: Turnigy Park250 Brushless Outrunner 2200kv

-BOOSTXL-DRV8301 REVB

-30V 1A DC Power Supply (set to 18 V)

-C2000 TMS320F28027F

The only specs provided for the motor are:


Spec.
Battery: 2 Cell /7.4V
RPM: 2200kv
Max current: 7A
No load current: 7.4V/0.45A
Current capacity: 8A/15sec
Internal resistance: 0.25 ohm
Weight: 14g  (not including connectors)
Diameter of shaft: 2mm
Dimensions: 35x23mm

Required;
10A ESC
2S Li-Po / 6 cell Ni-MH/Ni-Cd
5.5x4.5 ~ 8x6(SF) prop
Suitable for sport and scale airplanes weighing 6 to 12 ounces (170g–340g).

  • did you use proj_lab02c to ID the motor?

    What values did you determine?

    upload your user.h please

  • 66760.user.h

    I am not 100% sure how to attach the user.h file in this forum but I gave it a shot, please let me know if you are able to see it. I think if you open it with a program like Notepad++ the formatting will not be messed up.


    I did do lab2c, these were the values I got:


    #define   I_A_offset    (0.8440861106)
    #define   I_B_offset    (0.8403304815)
    #define   I_C_offset    (0.8366284966)

    #define   V_A_offset    (0.5027044415)
    #define   V_B_offset    (0.5021540523)
    #define   V_C_offset    (0.5012609959)

  • you have a //
    before your #define for Rs. So Rs isn't getting loaded into the estimator. Why do you have that?

    if you do an Rs Recal you will get an Rs value though...

    can you confirm once you are running the motor in proj_lab05a that you have value Rs_Ohm value loaded?

    As you increase Iq_Ref_A the motor should spin up to near maximum speed.

    Once you move to proj_lab05b you will need to tune the speed controller. The KpKi values default are too stiff for these low inertia motors. Try to divide default values by 10 as a starting point.
  • I set the Rs value as NULL because I was performing an Rs Recal. I noticed, for some reason, that the motor would not go crazy if I had the the Rs defined as NULL and I did an Rs Recal (this contradicted the instructions in the lab but it was the only way I found to get the motor spinning). However, what would happen then is I had to set Iq_Ref_A to 12 in order to get the motor spinning, and when it started spinning it would be over 1000 rpm. So clearly something had to be wrong since I would think I can start from a very low rpm and gradually increase.

    I was not sure before that I needed to continue with the labs, so I will do both proj_lab05a and b and let you know what happens.

    Thank you for responding so quickly, I really appreciate it.
  • few things.

    1. your motor is rated to 7.4V. Don't run it at 18V. Reduce the bus voltage and the USER_IQ_VOLTAGE
    2. @ 7.4V and 2200 kv, that is 16280 RPM. IF you have 10 poles this is 1356 Hz. Set USER_IQ_FREQUENCY to (1400.0)
    3. update this #define USER_MAX_ACCEL_EST_Hzps (10.0)
    4. update this #define USER_MOTOR_FLUX_EST_FREQ_Hz (100.0)
    5. your power supply is only 1A? This isn't enough, even unloaded. There is a start-up current needed to get these motors spinning. And even unloaded it will have peaks (and probably continuous) over 1A. You need more current.
    6. update this #define USER_MOTOR_MAX_CURRENT (10.0)
    7. use proj_lab02c to ID. Make sure the motor starts spinning during RampUp phase and KEEPS spinning until the end of motor ID. Use your hand to help spin up the motor if it doesn't start during RampUp. You can/should also increase
    #define USER_MOTOR_RES_EST_CURRENT (1.5)
    until you no longer need to use your hand to help spin up the motor

    let's get through this phase first.
  • I made the changes you've mentioned, and I went through the labs again to ID my motor and find the I and V offset values too. This time when I ran proj_lab04 I increased gMotorVars.IqRef_A to around 1 and then the motor started spinning at its maximum RPM (close to 16280).

    4431.user.h

    Perhaps I am a bit ignorant on the topic, but I thought one of the purposes of the motor driver was to amplify the current to control the motor. In other words, the power supply feeding 7.4 V to the motor driver is not responsible for providing the current (such as the 7A maximum for the motor).

    I will move on to proj_lab05a and b now, and let you know how it goes. Again, thank you very much Chris!

  • I solved for the Kp and Ki values in proj_lab05a, but I am not sure if I did proj_lab05b correctly. Also, when I have the motor running in proj_lab05a, the Rs_Ohm value is loaded.

    However, perhaps that proj_lab05b labs are not necessary for me at this moment. As of right now, all I want to accomplish is being able to manually set the rpm of the motor to values between 0 and 2000 rpm (so far the motor is in two states: 0 rpm and max rpm). This should be possible, right?
  • The only thing the controller can control is the duty cycle to each phase of the inverter which effectively allows some % of voltage to be applied to each phase, which in turn allows some % of current to flow through the machine. The current of course has to come from the power supply.

    in 5a the values for the KpKi of both Iq and Id PI controllers are calculated for you based on the Rs, Ls, and frequencies of control. You shouldn't have to change them at all, especially for this type of application.

    For 5b, the lab write-up is quite confusing on how to calculate the values IMO, and it's essentially impossible without knowing the inertia of the system. I think a better approach is trial and error. I can tell you that the default KpKi values for the speed controller are based only the max current setting in user.h. So if you double the max current setting Kp and Ki both double. In general what you will find is that this default value is generally pretty good for larger inertia / larger motors but is too stiff (values are too high) for lower inertia / smaller motors. And the smaller you get the more you need to reduce the default settings. For these hobby motors I usually divide default values by 10 to start, and then do some testing at different speeds with maximum accelerations.

    "wever, perhaps that proj_lab05b labs are not necessary for me at this moment. As of right now, all I want to accomplish is being able to manually set the rpm of the motor to values between 0 and 2000 rpm (so far the motor is in two states: 0 rpm and max rpm). This should be possible, right?"

    5b is necessary to add the speed controller and be able to change the gains.

    It won't give you the maximum speed. You are limited to a purse sinewave in these labs unless you use the over-modulation in proj_lab10. This will allow you to achieve another 25%+ in speed by applying more voltage to the motor through extended duty cycles.
  • "and then do some testing at different speeds"

    Does this mean changing the value of SpeedReg_krpm from 0.0?

    So assuming I complete 5b via the trial and error method, if I wanted to run my motor at 200 rpm, would I just change gMotorVars.IqRef_A or is there some other variable I can change that will accomplish this?

  • yes, changing SpeedRef_krpm sets a new commanded speed in proj_lab05b (and in every lab except for 5a and 4 which don't have a speed loop).

    "So assuming I complete 5b via the trial and error method, if I wanted to run my motor at 200 rpm, would I just change gMotorVars.IqRef_A or is there some other variable I can change that will accomplish this?"

    you will set your target speed using SpeedRef_krpm
    200 RPM = 0.2 SpeedRef_krpm command
  • So for rpm values greater than 500, I have found pretty good values for Ki (0.01) and Kp (1.0) to get a good result.

    But for for like 100 and 200 rpm, I found I needed to increase Kp to like 5 or 10 to get it spinning continuously (but not very smoothly). However, the measured rpm fluctuates like +-30 rpm from the desired rpm, so do you have any suggestions on how to improve the stability at these low rpms?

  • Mihailo,
    The FAST estimator relies on Bemf voltage generated for tracking.

    Your little hobby motor only produces 0.0027 volts per Hz.

    200 RPM = 16.66 Hz

    so @ 16.66 Hz your motor is producing only 16.66 * 0.0027 = 0.045 V of Bemf.

    You are measuring 0 to 26.314V on your ADC, meaning you only have a signal of 0.17% resolution, or only 7 ADC counts out of the 2^12 (4096) available!

    To run down towards 1 Hz you need more voltage resolution, meaning a motor with more flux (magnets) or a much smaller overall voltage scale. If you changed the HW scaling to measure half the voltage @ 13.157V you could double your resolution.

    bottom line, low speed performance of small flux machines using a flux based estimator is EXTREMELY challenging. FAST (InstaSPIN-FOC) is the best solution on the market....but it may not meet your needs (it certainly should for a standard hobby motor application like a propeller, it will NOT if you are trying to use it for another purpose).
  • Thank you for clearing that up for me. I would be interested in trying to halve the voltage to 13.157. Would this require implementing hardware to the board or changing something in software? I assume hardware but I would just want to make sure.
  • see sec 5.2.3 of SPRUHJ1
    you will update all 4 voltage circuits
    and you will update
    #define USER_ADC_FULL_SCALE_VOLTAGE_V (26.314)
    and probably
    #define USER_VOLTAGE_FILTER_POLE_Hz (364.682) // keep this in the 400 Hz range for your motor
  • Ok, at the moment, where I am at should be fine. If I need to go at those low rpm values I will take your advice.

    Thanks again for everything! I really appreciate it!