Pi Bakery:In a spin

Enhance your Raspberry Pi by adding a VGA output and a retro 8-bit sound chip emulator using the eight-core Propeller chip.Ever wanted an extra display on your Raspberry Pi, maybe for a two-player game or to log extra information? Then dust off that old VGA monitor and put it to good use to make a text and graphics display. Ever wanted to recreate those authentic 8-bit sounds of yesteryear without trying to buy long obsolete chips? Well now you can, easily and cheaply, by using the remarkable but much neglected Propeller chip. We will show you how to do it, as well as making a Propeller development board for even more projects.

The spin processor
The Propeller spin processor has been around for some time now and, in many ways, it was ahead of its time. It has eight processors that are called ‘cogs’; they all operate in parallel and can run at speeds in excess of 96MHz. Each one has a turn at controlling the output pins, hence the name ‘spin’. This is summarised in Figure 1. In addition to the cogs, there is memory: both RAM and ROM, which are shared resources for all the cogs. On bootup, code can be loaded automatically from an external EEPROM, so in effect the processor can run any code without specifically loading it.

The block diagram of our system
The block diagram of our system

Spin language
Built into the processor is an interpreter for a language called Spin, which has a simple syntax and is quite easy to learn. You can also run machine code, for those tasks that require it. In a similar way to the Arduino, preprogrammed cog codes can easily be dropped in, just like libraries, and there is a cog exchange website where you can download over a hundred cogs. In effect, you can think of cogs as programmable peripherals, and that is what we want to do with them here.

Our project
What we are going to do is to build a development board for this processor and make a VDU display, and a retro sound chip emulator with it, and show you how to drive these new peripherals with Python. Figure 2 (previous page) shows the block diagram of our project. With the introduction of the Raspberry Pi 3, there has been a change to the serial port on the GPIO pins; so to allow our project to seamlessly work with any model, we have chosen the USB route to access it, but taking its power from the Pi itself.

The schematic of our spin board
The schematic of our spin board

Our board
Figure 3 shows the block diagram of the board. A block diagram is useful for getting the overall structure of what we are going to make, without delving into all the detail we need to add to make a schematic. Connections between blocks that consist of more than one wire are often shown, as here, by a thick line with a slash and number above it, to indicate the number of wires involved. As well as the video and audio outputs, we have included an LED to flash, and there are 15 unused I/O pins on the processor for further expansion.

The full schematic
Figure 4 shows the full schematic of the board. By reference to the block diagram, you can identify the main functional units. The three video components – R, G, and B – are made using two pins, each joined together through resistors, to form a simple DAC (digital-to-analogue converter). For best results, these resistors should be accurate to 1%. The audio circuits consist of a 10 kΩ resistor and 10 nF capacitor to form a restoration filter, which will remove a lot of the PWM noise. Then a capacitor provides AC coupling, and a final trim pot allows you to adjust the output.

The physical layout of our spin board
The physical layout of our spin board

Preparing the board
The project is constructed on a piece of 32-strip, 37-hole stripboard – see Figure 5. The grey squares indicate where the track has been cut around a hole. Each hole has a coordinate, given by a strip and hole number; strip numbers go from top to bottom and, on the underside, hole numbers go from right to left. Drill four 3 mm board mounting holes at S2 H36 (Strip 2 Hole 36), S2 H2, S31 H2, and S31 H36. Add the VGA socket mounting at S6 H34 and S19 H34, and fit the audio jack. Make all the cuts in the tracks.

Fitting wire anchors to the USB module
Fitting wire anchors to the USB module

Building the board
Figure 6 (previous page) shows the components – on this side, hole numbers go from left to right. The ‘hidden detail’ of the track breaks and the strip outlines can be seen through the board. Start by soldering the 40-pin socket with pin 1 at S3 H19. Then add a 0.1 μF capacitor at S11 H21 and S11 H23, and another at S14 H21 and S14 H23. As these will be inside the socket, push them flat against the board so they don’t foul the chip. Next, add the 8-pin socket with pin 1 at S6 H3.

Pre-wiring the VGA socket
Pre-wiring the VGA socket

Adding the components
Now, add all the wire links; these are the vertical black lines. Then add all the resistors and the push-button. Next, add the LED – note the flat on the lower side, indicating the LED’s cathode or negative end. Add the capacitors, pots, crystal, and transistor. The USB module is soldered to the board (Figure 7) using six thick wires in the positions indicated by the black holes in the diagram. Only two are used as signals – the others are for mechanical support only. Make sure you make the link on the module so that you get 3V3 (3.3 V) signals out of it.

Fitting the VGA socket
Fitting the VGA socket

The VGA socket
The socket is mounted on a bracket made from a 46 mm length of 15×15 mm angle aluminium (Figure 8). This requires a trapezoidal slot to be cut out of it using a saw and file. Th e saw cuts you could make are shown in Figure 9; finish off by filing so the socket slots in neatly. Slot in the socket and mark its mounting holes through the socket’s holes. Do the same with the bracket’s mounting holes on the board. Drill out with a 3 mm drill and fix the bracket to the board.

Tapping the power from the Pi
Tapping the power from the Pi

Wiring the VGA socket
It is best if you add wires into the socket (Figure 10) before mounting it on the board. Add 40 mm wires to pin numbers 1, 2, 3, 9, 13, and 14. Use different colours of wires for each one so they can easily identified once mounted. For the pin numbers 5, 6, 7, 8, and 10, you have to chain these together. Do this by stripping the ends off two wires and twisting them together, and then tinning them – that is, adding a bit of solder. Then trim off the exposed wire to about 4 mm and insert in the hole of the pin, then solder it up.

The finished spin board
The finished spin board

Adding the connection wires
Screw the VGA socket to the bracket and wire up the flying leads to the points shown (Figure 11), trimming them to be only the length they need to be. Make the rest of the wires linking up the circuit. The 3V3, 5 V, and ground on the top of the layout go to the Raspberry Pi. We used three wires of 300 mm connected to an 8-pin header socket pushed into the GPIO pins (Figure 12). Some VGA monitors don’t require the 5 V signal, so that could be omitted if that is the case with yours. With the hardware built, next month we will see how to program our spin board, test it, and get some funky sounds from it.