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.

CCS/MSP430F5132: Floating point implementations for ADC measurements.

Part Number: MSP430F5132

Tool/software: Code Composer Studio

Hi sir,

I am working on MSP430F5132 mcu on CCU environment for a DC DC converter. I am trying to implement the floating point data type for ADC measurements and computations. But while implementation all float

variables are displaying zero's.How can i implement float operation in algorithm ? do i need any float libraries to add. Does CCU allows the float math for MSP430 controllers.

Please suggest how to implement float math in CCU.

Thanks & Regards

Naveen

   

  • Can you provide an example? My first guess is that you're using one of the printf() functions.

    You get the floating-point support automatically, just by declaring something "float". This is not the case for printf(), where you have to explicitly enable it in your build settings. In CCS 8.1, set [Build Settings->Compiler->Advanced->Language Options->Level of printf support] to "full".

    This will make your program quite a bit bigger. The other day I couldn't fit "full" support on an FR2433 (16K of program memory).
  • HI Bruce ,
    1) Thank You for the reply, i am not using the printf() functions,instead iam trying to implement float math on general ADC measurements and calculation of the system (DC - DC Converter) .
    2) As shown in the example below how i am implementing float math.

    // In variable Initialisations //
    float Input_Voltage_Temp =0.0;
    float Input_Voltage_Avg =0.0;
    float Input_Voltage =0.0;
    float Output_Voltage_Temp=0.0;
    float Output_Voltage_Avg =0.0;
    float Output_Voltage =0.0;

    // In ADC measurements and calculation part in super loop//

    Input_Voltage_Temp = Input_Voltage_Avg / 64.0;
    Input_Voltage = Input_Voltage_Temp *44.0/348.0;
    Output_Voltage_Temp = Output_Voltage_Avg / 64.0;
    Output_Voltage = Output_Voltage_Temp * 28.0/435.0;

    While '64.0' is my averaging constant and other numerical parts are scaling constants of input and output voltages . I need to send these measurements through serial port. When i try to debug this measurement part i can see all measurements are becoming zero.
    Is this is the correct way to implement. please guide.

    Regards
    Naveen
  • This looks OK as far as it goes. What is the procedure for computing Input_Voltage_Avg?

    When you say "i can see all measurements", are you looking at the debugger display, or the serial port? Are you sending the raw floating-point values through the serial port, or are you truncating them to integers?
  • Hi Bruce,

    thanks for the reply. Input_Voltage_Avg is the sum of 64 adc samples of input voltage measurement. Yes i am looking at debugger display which displays all measurements as zero when i use "float" data type. Right now i am not sending this data to serial port .

    Regards
    Naveen
  • I was kind of looking for more detail. In the code above, if Input_Voltage_Avg were =0, then everything else would be as well, and the code that sets it is elsewhere.

    I'm wondering if there's an overflow or a conversion goof (sometimes all it takes is a typo) that's causing that variable to become =0.

**Attention** This is a public forum