필터 지우기
필터 지우기

Code generation problem about discrete PID Block

조회 수: 3 (최근 30일)
Saygin
Saygin 2015년 4월 20일
답변: YANBIN ZHAO 2015년 7월 19일
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

답변 (2개)

Navaneeth Raman
Navaneeth Raman 2015년 4월 21일
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 2015년 7월 19일
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