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.

Velocity control Lab13e

Other Parts Discussed in Thread: MOTORWARE

Hi,

I am using the lab13e and it is working good. Now I trying to set the motor velocity by reading a potenciometer (like a did successfully in lab12b).

I try:

 gPotentiometer = HAL_readPotentiometerData(halHandle);
 gMotorVars.MaxVel_krpm =  gPotentiometer ;

It does not working.

How can I do this ?


Thanks in advance !

Paulo

  • Paulo,

    How are you converting from the raw ADC reading to IQ24 value required for gMotorVars.MaxVel_krpm? Are you doing this in the background loop?

    The other issue could be that you are updating the gMotorVars.MaxVel_krpm value too frequently. What can happen is that the profile generator will start to converge on the new value and go into halt mode, and it will do this continuously since the potentiometer value has some small amount of jitter to it. This means that the reference velocity will never settle and it won't work. One thing you could try is to look at how much jitter there is on the potentiometer when it is stationary and mask off the lower bits so that the jitter is ignored, and only meaningful rotation is seen as an input.
  • Adam,

    I'm using the method described in the motorware_hal_tutorial document:

    /! \brief Reads the Potentiometer
    //! \param[in] handle The hardware abstraction layer (HAL) handle
    //! \return The potentiometer value from _IQ(-1.0) to _IQ(1.0)
    static inline _iq HAL_readPotentiometerData(HAL_Handle handle)
    {
    HAL_Obj *obj = (HAL_Obj *)handle;
    _iq value, pot1 ;
    // convert potentiometer from IQ12 to IQ24.
    value = _IQ12toIQ((_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_8));
    pot1 = (value * 3.1) ; // 0 to 3100 rpm
    return(pot1);
    } // end of HAL_readPotentiometerData() function

    I think the problem is because of the jitter, when the pot reachs the maximum value its stabilize and at this point the motor starts spining.

    How can I mask off the lower bits IQ (0.000XXXXXX) ?

    Thank You !
    Paulo
  • Paulo,

    I think there in an issue is in the math that you are using to scale the potentiometer command from 0 to 1 into 0 to 3.1 krpm.

    PAULO SIQUEIRA said:
    pot1 = (value * 3.1) ; // 0 to 3100 rpm

    The above line needs to be the following:

    pot1 = _IQmpy(value, _IQ(3.1)) ; // 0 to 3100 rpm

    You were multiplying a float with an IQ which will not return a valid IQ variable.

    In order to mask off the lower bits you can do the following before returning pot1

    pot1 = pot1 & 0xFFFF0000;

  • Adam,

    Now everything is working good !

    Thank You !
    Paulo