Translate

Friday 17 March 2023

PiCow - the Raspberry Pi Computer Originated World

There I was, minding my own business, when the lovely owner of Radios-TV.co.uk commented on my PiPatGen thread.....


Dammit! I was supposed to be tidying the workshop (in all fairness, some tidying occurred!)

A PiCow ... why not ?!?? (if you don't know what C.O.W. is ... look here.)

So I did a spot of research into video playback, and found a brilliant video playback program called hello_video designed for continuously looping video for use on advertising hoardings and art installations.

Excellent.

Some footage was conjured up, and exported from my video editing software (Kdenlive) as an .mp4

hello_video needs a .h264 fileformat to work, so I used ffmpeg to create a raw stream. 

ffmpeg -i input_file.avi -vcodec copy -an -bsf:v h264_mp4toannexb output_file.h264

Brilliant.

I created a COW directory and placed the .h264 file in the directory using scp from my main linux PC.

Issuing the command

hello_video.bin --loop  ~/COW/cow.h264

created a wonderful display! It looped seamlessly!

The command was written into the .bashrc file, so it would start up on boot.

The shutdown scripts were added, in a manner identical to the PiPatGen.

I wanted something a little better to shut down the Pi, rather than having to push a toggle button. 

A small timer was conjured up
5V comes into our circuit, and is used to power up a 4049 inverter IC. There's also a feed to a relay coil, and it's normally open contact. SW1 is a normal DPDT ON-ON toggle. On one switch, the normally closed switch is connected to pins 6 & 12 of the raspberry pi's IO's. The NO contacts on the other pole, are connected to +5V via D1 (actually, D1 is a throwback to an earlier iteration, you can just couple the switch straight to +5V!). This is the power switch. When it's operated, pins 6 & 12 are disconnected, and C1 is rapidly charged up to 5V, which switches on U1A, taking the output of U1A low, this in turn feeds U1B, inverting the signal again, and turns on Q1, which energises the relay and supplies power to the raspberry pi.

When the power switch is turned off, pins 6 & 12 are connected, which initiates the pi shutdown script. C1 is still charged up, and starts to slowly discharge through R2. When it gets to about 50% of it's voltage level, the logic does it's thing, and switches off Q1, removing power from the pi. 

R1 is made adjustable, as the time to shutdown a pi varies on which version of the pi you have and the speed of the SD card. When building the device, manually shut down the pi by shorting pins 6 & 12, and set a timer to see how long the pi takes to completely shut down (you can tell as the SD card access LED stops flashing), then set R1 to allow the relay to switch off in a little longer than the Pi takes to shut down, to allow for a bit of a safety margin. My Pi Zero W takes about 9 seconds to shut down, so I set my timer to keep power connected for ~15 seconds. I used a 10-turn pot to make setting a little easier. (Incidentally, the Pi model B takes about 15 seconds, with the same image)

The 4049 is there just as a buffer. I could have used a FET to switch the relay, as that has a very high impedance gate, and eliminated the logic all together, but I didn't!

If your Pi takes longer than the maximum time, make the value of C1 bigger. 

The circuit was built up on a piece of perf-board.
This hardware also works great on PiPatGen, which would eliminate the shutdown pushbutton.

I did try the image on my PiPatGen's hardware, and even on my resource-shy Pi B, the output was smooth. 

Onto making another case!

The PiPatGen's front panel was modified, and despite my Pi Zero having no audio output, I left the audio jack in place, as I can feed some audio into the front panel if required. 

Clearly no shutdown button is now required. 

Another PlayStation modulator was procured from eBay, another case from eBay seller seemoreitems, and a simplified 3D printed front panel was made.

If you're not using an earlier Pi with a video output socket, you'll need to add a couple of header pins, and connect to that... this is the location of the port on my Pi Zero W. The port is marked up "TV" on this Pi Zero W. Check your Pi is capable of a video output before buying, as the newest models seem to have lost this (certainly the 400) 
The image file for the project can be downloaded from 

Here's the obligatory YouTube video ...







No comments:

Post a Comment