Op-Amp Challenge: Virtual Ball-in-a-Box Responds To Your Motions

A set of solderless breadboards with op amps and their functions annotated

With the incredible variety of projects submitted to our Op-Amp Contest, you’d almost forget that operational amplifiers were originally invented to perform mathematical operations, specifically inside analog computers. One popular “Hello World” kind of program for these computers is the “ball-in-a-box”, in which the computer simulates what happens when you drop a bouncy ball into a rigid box. [wlf647] has recreated this program using a handful of op amps and a classic display, and added a twist by making the system sensitive to gravity.

All the physics simulation work is performed by a set of TL072 JFET input op amps. Four are configured as integrators that simulate the motion of the ball in the X and Y directions, while four others serve as comparators that detect the ball’s collisions with the edges of the box and give it a push in the opposite direction. Three more op amps are connected to form a quadrature oscillator, which makes a set of sine and cosine waves that draw a circle representing the ball.

A miniature CRT viewfinder showing a small circleThe simulator’s output signals are connected to a tiny viewfinder CRT as well as a speaker that makes a sound whenever the ball hits one of the screen’s edges. This makes for a great ball-in-box display already, but what really makes this build special is the addition of an analog MEMS accelerometer that modifies the gravity vector in the simulation.

If you tilt or shake the sensor, the virtual box experiences a similar motion, which gives the simulation a beautiful live connection to the real world. You can see the result in a demo video [wlf647] recently posted.

The whole setup is currently sitting on a solderless breadboard, but [wlf647] is planning to integrate everything onto a PCB small enough to mount on the viewfinder, turning it into a self-contained motion simulator. Analog computers are perfect for this kind of work, and while they may seem old-fashioned, new ones are still being developed.

5 thoughts on “Op-Amp Challenge: Virtual Ball-in-a-Box Responds To Your Motions

  1. I have wondered before if some digital systems wouldn’t be a hell of a lot simpler if the differentiation and integration modes of analog computing were remembered and op amps used for sensor pre-processing so the FPUless micro doesn’t choke on it.

    1. External analog arithmetic was very plausible in the 80’s and 90’s, but ever since commodity 8 bit MCUs with integrated ALUs became available (and ADCs), fixed point arithmetic has been good/fast enough. Many cheap toy drones only use an 8 bit MCU to do all the stabilisation/control loop magic fed via accelerometer. Not to mention 32 bit MCUs are available for under a dollar nowadays.

      The other thing is that analog arithmetic is not perfect unlike digital arithmetic. You have a bunch of noise, offsets and non-linearities to consider, which only grows with system complexity and speed. Analog arithmetic/preprocessors definitely do exist inside accelerometer/radar/wireless ICs themselves, and it’s precisely to stop the user dealing with potentially GHz level samples rates, and instead only MHz level sample rates.

      1. “analog arithmetic is not perfect unlike digital arithmetic”
        Neither is perfect.
        Digital processing uses limited precision ADCs, DACs and floating point numbers which causes quantization/discretization errors that can be seen as equivalent to noise.
        It also is discrete in time (sampled), which results in distortion for frequencies about nyquist limit. Though with adequate filtering this just limits the bandwidth just like analog has bandwidth limitation.

    2. The problem is noise. Even in applications where you could design an analog front end (like a mems accelerometer) you really wouldn’t want to. You usually have a very simple analog filter before the ADC. The more op amps you cascade the more 1/f noise you have. its far easier to have a single adc and then do the digital filtering on the asic after.

  2. In the early days of machine vision ( 80s ), we did a lot of analog ( and digital hardware ) image preprocessing to reduce the workload on the very expensive , relatively under powered computers available at the time. It wasn’t until several million digital transistors became cheaper than 20 ” analog” transistors that we stopped thinking about tasks at hand.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.