MATLAB Answers

Running Simulink PID model with external reset and output saturation on Arduino target hardware.

27 views (last 30 days)
Daniel Gelman
Daniel Gelman on 23 Oct 2020
Edited: Daniel Gelman on 23 Oct 2020
On an Arduino, I've implemented an s-function to receive variables from a 2nd microcontroller via Serial.
The model, which can be deployed on the Arduino or run in external mode, is simply processing a PID block. The PID block seems to be outputing the correct control signal.
I want to Limit Output (under the Output Saturation tab) and use External Reset (under the Initialization tab) functions built in to the Simulink PID block.
However, neither of these functions work. I have verified the that these functions do work in the standard Simulink environment, but when I run it on the hardware, the outputs are not limited and the PID is not being reset.
Picture of model. S-function is top-right, PID block is bottom-left. GREEN is the set reference level, RED is the feedback, BLUE is the control signal, and YELLOW is a switch to toggle on/off the controller. As you can see I enabled the reset to be on the rising edge (0 -> 1). But the output never goes to the intiial condition. Also, the limit is set to 20,000; as you can see the control signal contionues to grow past the limit.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!