I have a need to build a spring mounted table, 12" square solid top in red, springs in blue and bottom in green, as in the diagram

Spring loaded table: solid top in red, springs in blue and bottom in green

I need to place a solid ball on the top board so it rolls around under its own weight. The top board has a raised edge so the ball will not fall off.

The final intent is to place some form of actuator near each corner to raise or lower the corner as allowed by the springs connecting the bottom and top boards. As an experiment the actuators will be controlled by a Raspberry Pi 4 using reinforcement learning to 'learn' how to balance the ball in the middle of table.

I can handle the machine learning side of things fine, but I'm struggling a bit with the actuators. My current thought is to use four electromagnets, one near each corner which would pull the corner down when activated. By activating each magnet in very short time steps, possibly microseconds, the amount by which the corner would fall would be controlled. I can only find one suitable electromagnet which uses the Grove system. Before I splash out any £s is it viable to control four such magnets from a single Pi? Or would I need to use the likes of four Picos to control each magnet under the control of a central Pi. Latency is a concern, which might rule out wireless connection between the Picos and the Pi. So how would I wire the four Picos to a single Pi? Other non-magnetic suggestions are welcome as well.

  • This is going to be pretty challenging unless your model has some kind of input WRT the state of the ball -- how to stop a ball rolling toward point X at speed Y could require a different set of responses than one heading for X at speed 2Y, but if the only inputs are to do with the position of the table you'll never train effectively for that...
    – goldilocks
    Oct 5, 2023 at 15:08
  • Since you've ask @goldilocks, position sensing is using a 60fps PixyCam which will provide position information. The machine learning aspect will use a learning classifier system XCS link. Deep learning reinforcement learning would require more processing than is available on a Pi. Similar has been achieved with beam balancing in one dimension. This extends the problem to two dimensions, which is as you say more challenging. Oct 6, 2023 at 11:35

1 Answer 1


Consider using four linear actuators, one on each corner. There are many available so you need to research to find the ones you want. I will take a SWAG and say you do not need a lot of motion on any of the corners so a shorter stroke would be easier to control.

One Pico should do what you want, using more than one complicates it dramatically, and adds an additional communication layer that will also add communication delay plus processor overhead and latency.

  • Great observation about the stroke length but while you can in theory run (eg.) tensorflow learning on a Pico I dunno if that is going to be so much fun (then again the physical side of that is going to be the learning bottleneck so perhaps how fast the numbers can be crunched won't matter).
    – goldilocks
    Oct 5, 2023 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.