Pi Zero POV
Get you Pi Zero out for a spin with Persistence Of Vision – Pi Zero POV
Persistence Of Vision is an interesting subject that is fairly easy to achieve and from which there is plenty to learn.
In this article we are going to show you how to build a Raspberry Pi Zero POV setup to display text from a file using an LED bar. The fun part is that the Pi and all the rest of the hardware are spinning glued onto a PC fan to deliver a fantastic POV effect whilst remaining wirelessly connected to your network!
What is POV
You can experience persistence of vision in many ways and forms. Have you ever seen car wheels suddenly spinning in the other direction? Have you ever had fun with flip books? You certainly went to the cinema or watched a carton animation. The principle is very similar in all of these examples and revolves around how does the combination of the eye and brain interprets motion. What we perceive as motion in the examples above is given by the succeeding of discrete images shown to us at a specific rate. If the number of images per second is too low we perceive them as just pictures, get the right frame rate and you see motion!
Persistence of vision with LEDs has been a thing for a while and has been perfected over time to extremely sophisticated levels.
Our example works with eight LED arranged in an LED bar and installed on a rotating platform. When the platform, our CD, starts sniping, an LED which is ON will give the illusion of a bright disk. This is very similar to what would happen if a friend of yours would wave rapidly a flash light in your back garden at night giving you the impression of a magical ribbon.
Imagine that your friend is able to control the flash light very precisely and that he/she is also able to switch it on and off at very precise moments in its motion. In such conditions you could be able to see something that would remind you of Morse code.
In the same way, as the CD rotates, we will be controlling our LED bar with very precise timings and these will give you the impression of very complicated light patterns which eventually we have used to display characters.
Building the Pi Zero POV
The most important part of getting the Pi Zero POV to run smoothly is given by how do you fix the payload of this spinning rocket onto the CD. Placing the Pi Zero in the right place will make so that when turning, the whole setup will have as little as possible vibrations. The rule of thumb we followed was to drill two 3 mm holes on opposite sides of the central hole of the CD and so that they would sit on one of the disk diameters.
The two holes correspond to the ones on the Pi Zero’s PCB diagonally opposed to each other.
Fix the Pi with the spacers and install the rest of the components as shown in the picture.
The LiPo gets tucked in under the Pi.
Be creative about how you fix things and use the right amount of blue tack and cable ties.
We modified the LiPo battery terminals so that we could easily plug it into the charger without needing to take anything apart.
Use a spacer between the fan and the CD to keep things away from the fan frame
and lastly put together the LED bar as shown in the picture following the corresponding colour and GPIO pin numbers.
Tuning the rotation speed
Getting the timing right works better as a dark art than by making very complicated calculations and that’s how we approached the problem. We needed to make so that the frequency at which the PC fan is spinning and the frequency with which we are switching the LEDs on and off somehow converged to a point in which the illusion of floating text was acceptable. We started by choosing about 5-6V with a bench power supply to power our 12V PC fan. That meant the fan was turning slower or faster depending on the voltage selection of the power supply. In the meantime we started by blinking one of the LEDs with some regular timing and went off to see if a dotted line was appearing instead of the bright disc.
Changing the timing between flashes helped us tuning the dotted line so that it looked like a succession of bright and dark lines which appeared about the same length. (i.e. something like – – – – -)
Once we got there it was just a question of putting together the right code to show the characters we wanted.
In your own setup you will only need to adjust the voltage provided to the fan once the script is running until you see something floating in the air.
Going for a spin
We provided the demo code PiZeroPOV.py available via GitHub which will display the contents of pov.txt. The script will check the contents of the text file every 10 seconds and display them on the POV. As the Pi Zero is connected to your network via its wireless adaptor, you can change what’s being displayed at any time without needing to shutdown or alter the spinning system in any way. The only limitations of this demo script are that it only accepts lower-case characters and spaces anything else will brake it miserably but, hey, anybody can easily improve it given a bit of time and dedication.
So as you log into your rotating Pi Zero simply type
sudo python PiZeroPOV/PiZeroPOV.py &
and start editing the pov.txt by using nano
to get your messages in the air!
Contain the vibrations:
Even the cable connected to the LED bar will introduce substantial imbalance if not properly anchored. Pull all the slack of the cable to the centre of the CD and fix it tightly so that it won’t move once the disk is spinning. You might to experiment drilling a few holes to find the sweet spot where to place the LED bar but after a bit of trial and error you should have a stable enough setup
Get the demo script:
To get the script from GitHub run the following command form your home folder i.e. /home/pi