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.

InstaSPIN add adc channel

For InstaSPIN-FOC

I want to direct the rotation speed of the external command voltage.
The rotational speed of FAST observer to estimate if you add a channel of the ADC
Will be unstable.
Is not how we improve?

  • Hayaoki,

    I'm sorry, I don't understand your question.  The voltage being used by the motor will have a frequency that matches the electrical Hz of the machine. This is part of the control loop if you choose to use the speed controller and give a command in RPM (which is translated to a Hz command based on the number of motor poles).

     

  • Thank you for reading
    I want to input an order of the rotary speed from ADC.
    I add SOC8 to the DRV_setupAdcs function inside
    I add data reading of SOC8 to DRV_readAdcData function
    When add a channel of the ADC; the rotary speed of the motor
    gMotorVars.krpm and the number of revolutions of the real motor double 1.5~2
    I understood a different thing.
    The order of the rotary speed by the analog voltage does not reach.
    SOC8 of the ADC merely reads it.
    When I want to control the rotary speed of the motor with the analog order voltage
    Please tell me DRV.c, the modification of DRV.h.

    thanks

  • you are trying to capture gMotorVars.SpeedRef_krpm or speed_ref_pu by using a potentiomenter through an ADC channel?

    what software command/logic are you using to take the result from SOC8 to equal a command for gMotorVars.SpeedRef_krpm or speed_ref_pu?

     

  • Yes, I have to try.
    Rotation speed was done by converting to krpm from the potentiometer.
    Instruction in the potentiometer was confirmed by a number of CCS krpm setting of the ADC added
    I can change without any problems.

    The problem, the numerical speed of rotation seen in debugging of CCS from the time of Indetifymode
    The number of actual equipment does not fit.
    Setting the ADC is in the default, no problem rotational speed.
    If you add a channel of the ADC, and be instructed in the Indenfify 6000rpm, rotating at 9000rpm.
    FAST observer may not work properly.

    Thanks

  • make sure

    1. you have the correct number of motor poles set in your user.h

    2. follow the instructions posted on setting your user.h, paying special attention to

    #define USER_IQ_FULL_SCALE_FREQ_Hz        (4 * USER_VOLTAGE_FILTER_POLE_Hz)

    3. Make sure your motor parameters are correct, especially Ls for higher speeds

    FAST observer works perfect when settings are correct.

  • IQ_FULL of the rotational speed of the USER.H (which is the default) 333 Volt_ploe at 1250Hz
    I tried also this other than, rotation speed NG is to read the potentiometer and (ADC-B0).
    This is the same even if I take off from the substrate potentiometer.
    We do not put out the command of the rotation speed a number of potentiometer at this time.
    I am entering a number of krpm from debugging of CCS.
    In addition, the rotational speed of the Identify running is also NG.
    However, InstaSPIN will work as expected if you do not add the channel of the ADC.

    Please tell us an improved method of and DRV.C DRV.H for reading the ADC potentiometer.
    It is a good even DRV8312-KIT-69M, and one of the DRV8301-KIT-69M because even does not matter
    Please tell me the recommended way of additional ADC channel to read the potentiometer.
    Thank you.

  • Hayaoki,

    I'm sorry, I'm having a hard time following your comments.

    "However, InstaSPIN will work as expected if you do not add the channel of the ADC. "

    You're saying that you get expected speed if using projects as-is, but as soon as you add an additional channel to be sampled the actual and estimated speeds do not agree?

    Is that a correct interpretation?

    How are you measuring the speeds to know that estimates are correct in one case and not in the other?

     

    Are you insuring that the extra sample isn't offsetting all future results?  Just a guess...although if this was happening the control results would be catastrophic.

    can you post the code you are using the save the extra sample?

     

  • Evaluation of rotational speed

    Actual rotational speed of the motor is measured using a Hall sensor
    I have to evaluate the difference between the rotational speed .

    This is the code that you added .
    Please tell me if there is a mistake .


    drv.c
    void DRV_setupAdcs (DRV_Handle handle)
    {
      
    DRV_Obj * obj = (DRV_Obj *) handle;

      
    / / Disable the ADCs
      
    ADC_disable (obj-> adcHandle);

      
    / / Power up the bandgap circuit
      
    ADC_enableBandGap (obj-> adcHandle);

      
    / / Set the ADC voltage reference source to internal
      
    ADC_setVoltRefSrc (obj-> adcHandle, ADC_VoltageRefSrc_Int);

      
    / / Enable the ADC reference buffers
      
    ADC_enableRefBuffers (obj-> adcHandle);

      
    / / Set main clock scaling factor (max45MHz clock for the ADC module)
      
    ADC_setDivideSelect (obj-> adcHandle, ADC_DivideSelect_ClkIn_by_2);

      
    / / Power up the ADCs
      
    ADC_powerUp (obj-> adcHandle);

      
    / / Enable the ADCs
      
    ADC_enable (obj-> adcHandle);

      
    / / Set the ADC interrupt pulse generation to prior
      
    ADC_setIntPulseGenMode (obj-> adcHandle, ADC_IntPulseGenMode_Prior);

      
    / / Set the temperature sensor source to external
      
    ADC_setTempSensorSrc (obj-> adcHandle, ADC_TempSensorSrc_Ext);

      
    / / Configure the interrupt sources
      
    ADC_disableInt (obj-> adcHandle, ADC_IntNumber_1);
      
    ADC_setIntMode (obj-> adcHandle, ADC_IntNumber_1, ADC_IntMode_ClearFlag);
      
    ADC_setIntSrc (obj-> adcHandle, ADC_IntNumber_1, ADC_IntSrc_EOC8);

      
    / / configure the SOCs for drv8301kit_revD
      
    / / Sample the first sample twice due to errata sprz342f
      
    ADC_setSocChanNumber (obj-> adcHandle, ADC_SocNumber_0, ADC_SocChanNumber_A6);
      
    ADC_setSocTrigSrc (obj-> adcHandle, ADC_SocNumber_0, ADC_SocTrigSrc_EPWM1_ADCSOCA);
      
    ADC_setSocSampleDelay (obj-> adcHandle, ADC_SocNumber_0, ADC_SocSampleDelay_9_cycles);

      
    ADC_setSocChanNumber (obj-> adcHandle, ADC_SocNumber_1, ADC_SocChanNumber_A6);
      
    ADC_setSocTrigSrc (obj-> adcHandle, ADC_SocNumber_1, ADC_SocTrigSrc_EPWM1_ADCSOCA);
      
    ADC_setSocSampleDelay (obj-> adcHandle, ADC_SocNumber_1, ADC_SocSampleDelay_9_cycles);

      
    ADC_setSocChanNumber (obj-> adcHandle, ADC_SocNumber_2, ADC_SocChanNumber_B6);
      
    ADC_setSocTrigSrc (obj-> adcHandle, ADC_SocNumber_2, ADC_SocTrigSrc_EPWM1_ADCSOCA);
      
    ADC_setSocSampleDelay (obj-> adcHandle, ADC_SocNumber_2, ADC_SocSampleDelay_9_cycles);

      
    ADC_setSocChanNumber (obj-> adcHandle, ADC_SocNumber_3, ADC_SocChanNumber_A0);
      
    ADC_setSocTrigSrc (obj-> adcHandle, ADC_SocNumber_3, ADC_SocTrigSrc_EPWM1_ADCSOCA);
      
    ADC_setSocSampleDelay (obj-> adcHandle, ADC_SocNumber_3, ADC_SocSampleDelay_9_cycles);

      
    ADC_setSocChanNumber (obj-> adcHandle, ADC_SocNumber_4, ADC_SocChanNumber_B7);
      
    ADC_setSocTrigSrc (obj-> adcHandle, ADC_SocNumber_4, ADC_SocTrigSrc_EPWM1_ADCSOCA);
      
    ADC_setSocSampleDelay (obj-> adcHandle, ADC_SocNumber_4, ADC_SocSampleDelay_9_cycles);

      
    ADC_setSocChanNumber (obj-> adcHandle, ADC_SocNumber_5, ADC_SocChanNumber_A7);
      
    ADC_setSocTrigSrc (obj-> adcHandle, ADC_SocNumber_5, ADC_SocTrigSrc_EPWM1_ADCSOCA);
      
    ADC_setSocSampleDelay (obj-> adcHandle, ADC_SocNumber_5, ADC_SocSampleDelay_9_cycles);

      
    ADC_setSocChanNumber (obj-> adcHandle, ADC_SocNumber_6, ADC_SocChanNumber_B4);
      
    ADC_setSocTrigSrc (obj-> adcHandle, ADC_SocNumber_6, ADC_SocTrigSrc_EPWM1_ADCSOCA);
      
    ADC_setSocSampleDelay (obj-> adcHandle, ADC_SocNumber_6, ADC_SocSampleDelay_9_cycles);

      
    ADC_setSocChanNumber (obj-> adcHandle, ADC_SocNumber_7, ADC_SocChanNumber_B2);
      
    ADC_setSocTrigSrc (obj-> adcHandle, ADC_SocNumber_7, ADC_SocTrigSrc_EPWM1_ADCSOCA);
      
    ADC_setSocSampleDelay (obj-> adcHandle, ADC_SocNumber_7, ADC_SocSampleDelay_9_cycles);

    / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
    / / / / / / / / / / / Add from here
      
    ADC_setSocChanNumber (obj-> adcHandle, ADC_SocNumber_8, ADC_SocChanNumber_B0);
      
    ADC_setSocTrigSrc (obj-> adcHandle, ADC_SocNumber_8, ADC_SocTrigSrc_EPWM1_ADCSOCA);
      
    ADC_setSocSampleDelay (obj-> adcHandle, ADC_SocNumber_8, ADC_SocSampleDelay_9_cycles);
    / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
    / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
      
    return;
    } / / End of DRV_setupAdcs () function



    drv.h
    static inline void DRV_readAdcData (DRV_Handle handle, DRV_AdcData_t * pAdcData) {
      
    DRV_Obj * obj = (DRV_Obj *) handle;

      
    _iq value;
      
    _iq current_sf = DRV_getCurrentScaleFactor (handle);
      
    _iq voltage_sf = DRV_getVoltageScaleFactor (handle);


      
    / / Convert current A
      
    / / Sample the first sample twice due to errata sprz342f, ignore the first sample
      
    value = (_iq) ADC_readResult (obj-> adcHandle, ADC_ResultNumber_1);
      
    value = _IQ12mpy (value, current_sf) - obj-> adcBias.I.value [0]; / / divide by 2 ^ numAdcBits = 2 ^ 12
      
    pAdcData-> I.value [0] = value;

      
    / / Convert current B
      
    value = (_iq) ADC_readResult (obj-> adcHandle, ADC_ResultNumber_2);
      
    value = _IQ12mpy (value, current_sf) - obj-> adcBias.I.value [1]; / / divide by 2 ^ numAdcBits = 2 ^ 12
      
    pAdcData-> I.value [1] = value;

      
    / / Convert current C
      
    value = (_iq) ADC_readResult (obj-> adcHandle, ADC_ResultNumber_3);
      
    value = _IQ12mpy (value, current_sf) - obj-> adcBias.I.value [2]; / / divide by 2 ^ numAdcBits = 2 ^ 12
      
    pAdcData-> I.value [2] = value;

      
    / / Convert voltage A
      
    value = (_iq) ADC_readResult (obj-> adcHandle, ADC_ResultNumber_4);
      
    value = _IQ12mpy (value, voltage_sf) - obj-> adcBias.V.value [0]; / / divide by 2 ^ numAdcBits = 2 ^ 12
      
    pAdcData-> V.value [0] = value;

      
    / / Convert voltage B
      
    value = (_iq) ADC_readResult (obj-> adcHandle, ADC_ResultNumber_5);
      
    value = _IQ12mpy (value, voltage_sf) - obj-> adcBias.V.value [1]; / / divide by 2 ^ numAdcBits = 2 ^ 12
      
    pAdcData-> V.value [1] = value;

      
    / / Convert voltage C
      
    value = (_iq) ADC_readResult (obj-> adcHandle, ADC_ResultNumber_6);
      
    value = _IQ12mpy (value, voltage_sf) - obj-> adcBias.V.value [2]; / / divide by 2 ^ numAdcBits = 2 ^ 12
      
    pAdcData-> V.value [2] = value;

      
    / / Read the dcBus voltage value
      
    value = (_iq) ADC_readResult (obj-> adcHandle, ADC_ResultNumber_7); / / divide by 2 ^ numAdcBits = 2 ^ 12
      
    value = _IQ12mpy (value, voltage_sf);
      
    pAdcData-> dcBus = value;

    / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
    / / / / / / / / / / Add from here
      
    / / Read the SpeedCommand voltage value
      
    value = (_iq) ADC_readResult (obj-> adcHandle, ADC_ResultNumber_8); / / divide by 2 ^ numAdcBits = 2 ^ 12
    / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
    / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /

      
    return;
    } / / End of DRV_readAdcData () function

    Sorry for your time.
    Thank you for your cooperation.

     

     

     

  • 1. what do you do with the value you read for Speed/Command voltage value?  How are you turning this into a Speed command?

    In general, what you are doing by adding a single channel to be read in the main interrupt should be fine....but I also don't know what you are doing with that ADC reading.

    2. Regardless of the potentiometer input, you should be able to manually input speed command and compare to a FAST estimated and HALL estimated (and preferably an externally measured device).  So please confirm that you think you are seeing a variation in FAST estimated speed and HALL estimated speed when the commanded speed is set using gMotorVars.Speed_krpm

    Does the speed error occur ALL the time? Previously you stated it only happens when you add the additional ADC reading: "Setting the ADC is in the default, no problem rotational speed.
    If you add a channel of the ADC, and be instructed in the Indenfify 6000rpm, rotating at 9000rpm. "

    3. How do you know your HALL capture is giving the correct estimated speed?

    4. Please attach the user.h you are using so I can check for errors