Code generation problem about discrete PID Block

2 visualizaciones (últimos 30 días)
Saygin
Saygin el 20 de Abr. de 2015
Respondida: YANBIN ZHAO el 19 de Jul. de 2015
Hello,
I use the discrete PID block in my model. In simulation there's no problem, however when generating code some problems occurs.
Sample time of PID block is 100e-6. I must call the control block to hardware interrupt block (asyncronous) because of code generation. Therefore I change sample time to -1 and Integrator gain to IntegratorGain*SampleTime.
When analyzing generated code, Integrator gain is multiplied by elapsed time ('mode.block_ELAPS_T') variable which is calculated with Timing.clocTick value. I dont want to be added the elapsed time value because i use pid in pwm timer interrupt block (100e-6)
How to prohibit to generate elapsed time variable in c code. Thank you

Respuestas (2)

Navaneeth Raman
Navaneeth Raman el 21 de Abr. de 2015
Hello,
The integrator gain would remain a constant and not change with each timestep if you set its gain to be IntegratorGain*SampleTime where I assume SampleTime is a constant. Do you have a model that you can share so that I can take a look at it and figure out what is going on?
Thanks, Navaneeth

YANBIN ZHAO
YANBIN ZHAO el 19 de Jul. de 2015
Hi, SayGin:
Can not understand why in generated code, Integration Gain is not a constant. Can you share the model which is related with Integration Gain?
ZYB 2015.07.19

Community Treasure Hunt

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

Start Hunting!

Translated by