PD Control of Ball and Plate System (Stewart Platform) via Python and Arduino Answered
I'm prototyping a 6-DOF Stewart Platform, i.e. a parallel mechanism also known as hexapod, with an embedded resistive touchscreen on its top plate that captures the current position of a ball moving on it. Coordinates are stored by Arduino Due and sent via serial to a Python script which elaborates data, computes inverse kinematics and outputs the 6 servo angles (again via serial port) to Arduino that, finally, moves the arms. As you can notice, velocity is obtained by a one-side differentiator and here it comes my first question: how much should be the sampling step? It takes 124 microseconds for Arduino to execute both the "AnalogRead" functions, but coordinates are stored in Python at a different clock (order of one millisecond). I picked sampling step h (see attachment 2) equal to the computational time of the Python script, with decent results, but still I'm not convinced.
My second issue regards tuning of the PD controller: I first described the system with a double-integrator transfer function (from assumptions and simplifications over ball&plate control) but the obtained controller parameters were far from the optimal ones. Therefore a simplified model of motor dynamics was added to the transfer function and new PD constants were implemented: simulation and real behaviors are far from being identical (high delay, not null steady-state error, higher rise time, etc.); however, inside small ranges of error and with reduced velocity, the ball reaches an equilibrium basin. The third attachment depicts the final transfer function where:
- K is K_m*K_ball*g (K_m:motor gain constant, K_ball: ball inertia, g: gravitational force)
- T is tau_m: motor time constant;
I set K_m and tau_m equals to torque (Kg*m) and velocity (rad/s) respectively, according to servomotors datasheet: is this the right choice?
Thanks to everyone for even reading and for any upcoming help.