help required for fixed point conversion

I am using R14A and I have modelled angle tracking observer algoirthm in simulink. I have simulated model wih floating point and it works well. I used fixed point advisor. Although there are no errors, but the output is zero. Can anybody help us withthis.

5 Comments

Hi Gary,
Please check that the correct parameter values have been supplied.
For example, in the comments below, you mentioned that
Ts=10000
wn=42 rad/s
The sample time Ts is unusually large, especially given that the model stop time is 0.5 seconds.
Given those values the two discrete integrators never execute except at time 0,
but I'm seeing sample times for other blocks being much shorter, so they execute a lot in the 0.5 seconds sim time.
To reduce confusion over reproduction steps, allow me to suppest you define the parameters in a MATLAB script with some name like
init_data_Algo.m
Ts=10000;
wn=42;
then automatically run that script from the model by doing a one time set_param
set_param(bdroot,'PreLoadFcn','init_data_Algo')
set_param(bdroot,'InitFcn','init_data_Algo')
followed by resaving the model.
Then, check the reproduction
% CAUTION: Save all your open models first!!!
% Next command will close them all without saving.
bdclose all
clear all
mdl = 'Algo'
open_system(mdl)
sim(mdl)
Whatever you are seeing from that simulation is what others should see when then attempt to reproduce the results.
Finally, upload both the edited Algo.slx and the data initialization MATLAB script, here.
Regards,
Andy
Hmm. When I apply the settings you proposed. I get float output as zero. Can you explain me the reason and fix.
I would guess that previously when you saw an non-zero value for the floating-point output something was defined differently in your workspace.
Gary on 20 Jun 2022 at 11:33 wrote >> I have not stored in *.mat file. Ts=10000 and wn=42 rad/s
My first guess would be that the value of Ts previously used was not 10000.
Try to recreate the setup you had, and get back to the expected floating-point output.
Then determine the values Ts and wn. Could be defined in MATLAB base workspace or your model's workspace or ...
Once you are able to reproced the
If you are not really sure where these are defined, drop two constant blocks in your model and feed them to display blocks with format set to "long". Enter the text 'Ts' and 'wn' as the values for the two constants. When you simulate, the constant blocks will show the values of those two variables. Enter those values into the script init_data_Algo.m (or whatever you've named it.)
Then try to do a "clean" reproduction with "clear all" etc.
Hi Andy
Please see the file with all modifications suggested. I entered the desired values in the simulink model without creating a seperate script file. Tried to run fixed point advisor. But it gave lot of errors. Please suggest fix or method to fix it
Could anybody help me to fix the overflow wraps in the model?

Sign in to comment.

Answers (2)

Ayush Kumar Jaiswal
Ayush Kumar Jaiswal on 19 Jun 2022
Edited: Ayush Kumar Jaiswal on 19 Jun 2022
The problem of getting all the output as zeros could potentially be related to the proposed data type settings which results in overflows. You could verfiy that in the histograms produced after simulation.
Try increasing the word length in the Settings section of the fixed point tool, allowing more room for calculation and hence avoiding overflows.
Thanks

9 Comments

I tried to increase word length- fixdt(1,24,12). but still output is zero.
@Gary Let's increase it further to 32-64, if problem persists then if you could share your model here please do.
Model is attached in the earlier post
I also require workspace variables, share .mat files too.
I have not stored in *.mat file. Ts=10000 and wn=42 rad/s
I think you have mistakenly changed the data type of sine and cosine block within the float subsystem. see the figure attached.
That sine and cosine block are producing zeros.
float works very well. By converting to fixed point, I am getting into trouble. Please try simulating float subsystem. I did not quite understand how to find the cause and troubleshoot the same. fixed point advisor highlights the vulnerable points in red.
Float subsystem also gives zeros as an output. You mean to say that after converting to fixed point both subsystems are giving zeros? Then please share the un-converted model.
No. Float system gives perfect output. Fixed point model gives output zero. As I said earlier, I wanted to know the method of troubleshooting the problem. I am unable to find proper tutorials in this regard. All I could find is usage of fixed point advisor and not how to fix the problem when it occurs

Sign in to comment.

Gary
Gary on 17 Jul 2022
Finally, I got this model working in fixed point. I have learnt two lessons. First increase the size (16,32,48 etc) and secondly reduce the input range. By iterating between these two factors, I could finally get the result. Thank you all for all the help provided

Products

Release

R2014a

Asked:

on 19 Jun 2022

Answered:

on 17 Jul 2022

Community Treasure Hunt

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

Start Hunting!