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.

Convert ADC values to float volts and amps

Other Parts Discussed in Thread: DRV8301, TMS320F28027F

Hi;

I am trying to modify project_lab11 for the TMS320F28027F LaunchPad with the DRV8301 revB motor driver and a bldc motor.

The modification should allow the "enable_run" flag to be set high when the motor is being driven at a particular speed by another motor.

So far, I have located the point within the .c files ISR where I wish to insert my code.

My code uses a set of equations that converts the terminal voltage of the floating phase into a back emf, and then calculates the angular rotation of the rotor from there.

int Vc = gAdcData.V.value[2];
int VBus = gAdcData.dcBus;

These are the two variables I will be using, however in order for them to work with my equations; I need to convert their value a regular float...

Any suggestions?

Also I have made the assumption that Vc is always updated in the ISR to be the floating terminal.

Thank you! 

  • Hi Morikeh,

    Your post is being moved to the C2000 forum for better support.
  • Hi,

    Simply Type cast from int to float. Refer the following link:
    www.tutorialspoint.com/.../c_type_casting.htm

    Regards,
    Gautam
  • Casting, actually wasn't what I needed.

    can you direct me to a resource about the "pu" (per unit)

    Basically, I am trying to write a piece of code in the main ISR that checks the value of the back emf in the motor, while being driven by another motor- as the back emf is proportional to the speed. When the speed > 600 rpm, I want the enable run flag to be high.

    The code I have is clean.
    In one attempt, I used the speed_pu as the speed of the motor.
    I think this value is omega, and is returned from the estimator.
    I'm not sure if this value can only be used when the motor is driving or can be used when the motor s being driven?

    In another attempt, I used the values released from the Adc- I have explained this in the previous message.

    In the expressions table
    gAdcData.V.value[2] and gAdcData.dcBus "long" data types, I can't understand their value and they are also changing , seemingly arbitrarily.

    I have read the code, and it makes sense. I thought; if I wrote a simple mathematical equation- using the Adc voltage values before they are sent to the Clark transformation- to calculate the rotor speed and then an if statement, referencing a threshold speed value, then the motor would run or not run.

    The closest I have gotten is that the enable run flag switch randomly between the states.

    I have taken a look at the coding standards document, but tbh, I dont know how its contents relate to my problem.
    ????? to all

    Cheers