24Views2Replies

Author Options:

PD Control of Ball and Plate System (Stewart Platform) via Python and Arduino Answered

Hi community,

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.

Discussions

None
BushBond

12 days ago

So long story short last year I switched into EE, and honestly really dig it so far! Due to my actual electrical course work requiring a different set of math classes than I originally had taken I haven’t been able to take any electrical engineering classes yet... I ended up purchasing some breadboards and parts to go with it, along with a raspberry pi to learn about https://getappvalley.com/ building circuits and work on some coding as well. The goal is to mess around and learn what I can before I can take an actual circuits course, but from your experience what’re some of the best things I can do to build my knowledge in the field, or any advice on what I SHOULD be doing as well?https://tweakbox.mobi/

None
Downunder35m

17 days ago

I might be missing something here but going the serial route with computing is a IMHO the real culprit here.
With a 32bit CPU it would make sense to do the computing directly on the Arduino and to use the serial connection only for ball placement.
E.G.: All cooridination and computing is done on the Due.
Means the ball is kept stable in whatever position it is supposed to be.
Over serial you send the data where the ball should go as coordinates.
The Due take the coordinates and computes the positioning.

I think like this you will eliminate the timing issues and get far more stability into the platform.
If you still want to go the full python route then still start with a stable platform first.
Once the Due can do this start with the serial communication to actually change the position of the ball.
Trying to sort both problems in one go leaves you with too many influencing variables ;)