Code generation problem about discrete PID Block

2 views (last 30 days)
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

Answers (2)

Navaneeth Raman
Navaneeth Raman on 21 Apr 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 on 19 Jul 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!