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.

Compiler/TMS320F2812: To convert IQ format number to float that needs to be sent to Simulink generated TwinCAT module

Part Number: TMS320F2812

Tool/software: TI C/C++ Compiler

Hi,

I have a simulink model to add two floating point numbers. This model is built and code is generated (using Simulink coder) to be run in TwinCAT 3.1. Now the floating point numbers are transmitted to the TwinCAT from my TI DSP. In my DSP I store these values as IQ24 format numbers. 

At first I tried to use the c2000 simulink function blocks but failed to generate code. Now I realise that these blocks can be generated only to be run on the DSP itself. Hence the code generation failing makes sense.

Now I am wondering how I can transmit float values to my TwinCAT3.1 environment from my TI DSP. I am open to converting them at the DSP side or at the TwinCAT side (Simulink).

I tried converting an IQ number to float value in the DSP but it does not seem to appear in the TwinCAT environment as a float value. Am I doing something wrong or by default I cannot transmit float values from a fixed point IQ DSP???
Or is there another method I could use in the Simulink model itself to convert IQ numbers to float AND still be able to generate that model into TwinCAT environment?? 

Any help in this direction is useful .

Thank you so much :) 

  • Raghu,

    Of your question, we can probably help with the below portion

    I tried converting an IQ number to float value in the DSP but it does not seem to appear in the TwinCAT environment as a float value. Am I doing something wrong or by default I cannot transmit float values from a fixed point IQ DSP??

    1. Can you post how you converted from IQ24 to Float?
    2. I am not sure how you tranmitt into TwinCAT environment ? I am assuming the DSP talks on SPI/SCI to a twincat capable MCU/ Beckhoff IP.. ?
  • Hi Manish,

    1. I used        float variable = _IQ24toF( _iq24 A);

    2. Yes through SPI to a twincat capable MCU which then transmits that register value to the PC through EtherCAT. That first part is more important - through SPI to the twincat capable MCU.

  • Raghu,

    the conversion looks ok to me,

    I would suggest you debug your system one step at a time, i.e. make sure comms link is working fine.. i.e. transmit a fixed float from the MCU to the twincat environment, etc..

    I have asked one of my colleague to look at it as well in case we can provide any more helpful information.