help required for fixed point conversion
Afficher commentaires plus anciens
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 commentaires
Andy Bartlett
le 21 Juin 2022
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
Gary
le 22 Juin 2022
Andy Bartlett
le 22 Juin 2022
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.
Gary
le 24 Juin 2022
Gary
le 27 Juin 2022
Réponses (2)
Ayush Kumar Jaiswal
le 19 Juin 2022
Modifié(e) : Ayush Kumar Jaiswal
le 19 Juin 2022
0 votes
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 commentaires
Gary
le 19 Juin 2022
Ayush Kumar Jaiswal
le 19 Juin 2022
@Gary Let's increase it further to 32-64, if problem persists then if you could share your model here please do.
Gary
le 19 Juin 2022
Ayush Kumar Jaiswal
le 20 Juin 2022
Modifié(e) : Ayush Kumar Jaiswal
le 20 Juin 2022
I also require workspace variables, share .mat files too.
Gary
le 20 Juin 2022
Ayush Kumar Jaiswal
le 20 Juin 2022
Modifié(e) : Ayush Kumar Jaiswal
le 20 Juin 2022
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.
Gary
le 20 Juin 2022
Ayush Kumar Jaiswal
le 20 Juin 2022
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.
Gary
le 21 Juin 2022
Gary
le 17 Juil 2022
0 votes
Catégories
En savoir plus sur Array and Matrix Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!