Recently I came by an old Model B Raspberry Pi, whilst once the cutting edge of single board computing, is now showing it's age a bit.
So what projects can we create today with it?
How about a pattern generator for our vintage analogue TV sets?
It's got suitable composite video output (I *think* even the current Pi's (although sadly not the 400) have this (if you can find one)), so this project *may* work fine on something newer.
Here's the plan:
Have a set of test patterns available, that we can select, say Test Card F, Test Card C, a PM5544 type, maybe the "Native American" pattern, a grey scale, colour bars, SMPTE, cross hatch for setting up convergence... all running straight at boot, selected by switches on the front panel, and a button to safely shut it down.
The latest version of Raspberry Pi OS lite is downloaded and written to an SD card, we don't want (or need) the additional hassle of running a resource hungry desktop GUI.
The system is booted, with a keyboard and monitor attached.
Using raspi-config, the system was set up with SSH enabled, auto-login at boot, composite output enabled etc etc ...
I installed the FBI (Frame buffer imageviewer), and wrote a bit of python to act conditionally on the position of a 10-way rotary switch in an attempt to display 10 different pictures.
Whilst FBI does a wonderful job of displaying the images in the console, no way could I persuade it to act on the position of my switch, unless I issued an ESC or CTRL-C between changes on the keyboard. Even using the signals library and attempting to send a killall would work. Once FBI is running, it grabs hold of the keyboard interface and refuses to allow any changes until ESC or CTRL-C is issued on the physical keyboard. Googling the problem shows I'm not alone in my quest.
So, what else can I do? I tried a package called FIM (FBI improved), which performed no differently.
I could get FBI to scroll through all the images one at a time, by pressing J to step back and K to step forward in the image sequence. This would work, except I didn't want a keyboard attached. I needed a method of generating a "J" and a "K" and getting it into the USB interface as if it were a keyboard. I did contemplate using an Arduino as an HDI (human device interface, that's a keyboard (or mouse) to you and I!) , there's code that I could implement to do this freely available.
Instead I asked on our street's whatsapp group to see if anyone had an old USB keyboard that they were going to get rid of, and someone did!
Excellent. A Dell keyboard duly showed up at the front door, an ideal candidate. The keyboard was quickly disassembled and the keyboard driver PCB extracted...
Keyboards are generally wired in a matrix, each key connecting an X and a Y (or rows and columns if you like) , and each switch closes one of the X and one of the Y, giving a unique coordinate for each switch, a bit like this...
In this fictitious example above, we can see that J (SW15) puts a short between X7 and Y2, and K (SW16) puts a short between X8 and Y2. All we need to do if discover what connections are made for J and K on our scrap keyboard, and make connections to the encoder board to a couple of push buttons, to make a keyboard with just J & K on it... simple...
The keyboard matrix consists of three layers of plastic film, the top one contains all our "Y" traces, there's an insulating layer with no traces (just some holes that allow the keys to press through and complete the circuit) and a third bottom layer that contains the "X" traces.
Identifying the two J & K keys, and their contacts is easy enough, and the traces are discovered by testing with a multimeter for continuity.
Once these are discovered, it's just a matter if wiring up out two push buttons to the appropriate contacts on the USB encoder PCB. My PCB had a layer of black conductive material deposited on the contacts, to facilitate a reliable connection with the plastic traces on the original matrix. This was removed with a fibreglass abrasive pencil, to reveal the copper traces underneath, so they would take solder.
Now I had a method of skipping forward and backwards through patterns as required.
Next a shutdown button was implemented using a python script in an identical manner to the hospital radio streaming codec and monitor. Thankfully FBI didn't interfere with the operation of this. The shutdown button connects between pins 6 & 12 on the Pi's GPIO header.
Now, what about some audio. I created a stereo 44.1KHz wav file in audacity and placed some music on one channel (left), and a continuous 1KHz tone on the other (right), this is set to play using the aplay function on boot. I tried using an MP3 player, but it's glitchy with this resource-shy pi.
As most of my TVs don't have a video input, I'll need to create a UHF output. This is achieved using a redundant PlayStation modulator, purchased for little money on eBay. The modulator case is opened up to save space, and the small RF metal enclosure mounted inside a clamshell case, along with the Pi. Note the european modulator has a setting for I & G, this is for 6 MHz (I) or 5.5 MHz (G) sound carrier settings. Sadly the PI won't output SECAM. American users wishing NTSC output may wish to use a VHF modulator.
Note on PlayStation modulator wiring:-
White is video in
Yellow is +5V
Red is audio in
Black is Ground.
The audio is switched between left and right channels of the Pi's 3.5mm audio jack to select tone or music with a simple SPDT toggle switch.
A front panel was 3D Printed with the holes in it to accommodate all the required functions. The RF is leaving on the rear of the case, via the coax already attached to the modulator. Power is supplied from a USB lead, via a switch, to the Pi and the modulator. Audio from the Pi is switched between L & R channels, and sent to the modulator, and a front panel RCA socket. Composite video is also made available to the front panel.
A front panel legend is created in inkscape, and printed out and laminated. This is then stuck to the front panel.
I've made an image of the OS etc, which you're free to download and modify here:
Write the image to a card using Raspberry Pi Imager or Belena Etcher etc ..
It will run straight out of the box in PAL, if you need to modify any settings, see below...
CTRL-C or escape will quit FBI (although the music will still be playing in the background!) ...
It may be wise to change the default password (DTW) at this stage, if you're connecting your Pi to the outside world.
sudo raspi-config
whilst you're in there , press 1 , and expand the filesystem to make use of all the space on your card.
sudo reboot
If you need to change the overscan settings or change to NTSC, you'll need to edit the boot config file
sudo nano /boot/config.txt
and edit the overscan lines. Note this is in pixels.
overscan_left=10
overscan_right=10
overscan_top=15
overscan_bottom=15
and then reboot
sudo reboot
For NTSC change:
sdtv_mode=2
to
sdtv_mode=0
There's 3 images and a 1K/ Music file loaded, you can change these to suit. Images are found in ~/doz/TestPatterns/ and images should be PNG or JPG format. These are cycled through in alphabetical order. To display correctly, images should be 720*576 for PAL, or 720*480 for NTSC.
The music file can be found in ~/doz/Music/ and must be called TCM.wav
You can use WinSCP on windows to change these via the network, or copy them straight to the card if you run a linux distro (or use the SCP command in a terminal)
No comments:
Post a Comment