MATLAB Answers

Causing steady state error when conveting double (64 bit) data format to single (32 bit) format or run Simulink model on 32 bit processors such as Ti C2000.

1 view (last 30 days)
ebram smith
ebram smith on 14 Sep 2017
I use Matlab R2017a and Embedded Coder Support Package for Texas Instrument C2000 processors. I designed a validated Phase-Locked Loop (PLL) including a feed-back loop to estimate power grid frequency (50 Hz). The simulation results (the voltage frequency and amplitude) in double format and the results of implemented model on Raspberry Pi 3 including 64 bit processor are correct but when I changed data format to single (32 bit) the frequency and amplitude increased. This steady state error is also visible in the results of implemented model on Launchxl-F28377S that includes a 32 bit DSP, however we do not expect steady state errors in feed-back loops. I think this problem is resulted from numerical errors. The Simulation model and the results of double and single format simulations and implemented model on Launchpad have been attached as a zip file. Should I change the model design (For example using fixed-point design or code programming)? Is it require another (further) setting or special requirements? How can I modify the model to run on this DSP without such errors in the experimental results?
The double format simulation results:
The single format simulation results:
The results of implemented model on DSP:

  0 Comments

Sign in to comment.

Answers (1)

Venkatesh Chilapur
Venkatesh Chilapur on 2 Nov 2017
Hi,
Generate code for C2000, code runs on target with 32-bit floating point for the given double in the simulink model. Because double maps to 32-bit floating point for C2000 and "long double" maps to 64bit floating point. Through a workaround by using the "Data type replacement" pane of the configset we can remap "double" to an alias of "long double" to ensure the generated code runs on target with 64bit float. But, this will affect the execution performance badly, So use of double is not recommended unless it is really required.
type cast the my_Double to long double in one header file.
HTH,
Venkatesh C

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!