I am making a 2 wheeled inverted pendulum.
In order to do so, I did the modelling of the system. I have the state-space model where input is the torque of the 2 motors (I drive the 2 motors simultaneously), the output is the angle of the inverted pendulum. See WIP photo attached.
I then use a PID controller (Simulink as well), and tuning for Kp, Ki, Kd. However, the output signal from the PID controller that I simulated yield the output range much greater than the maximum torque of the motors.
I am quite sure that the modelling is correct, I am following this article: http://publications.lib.chalmers.se/records/fulltext/99385.pdf
My question is: I intend to do the map(pidout,fromlow,fromhigh,tolow,tohigh) to map the output range from the PID to range (0-255). And in order to do so:
- I simulink to get the Ki, Kp, Kd.
- I view the output signal from the PID controller after the simulate. Check for the maximum and minimum range.
- Use the map() function to map.
I have a concern that would it affect the system? Because now I scale the signal, I am pretty sure it will affect the outcome of my system.
Besides, other suggestions on how I can apply from simulink mathlab result to the programming would be appreciate.