Saturday, 1 April 2017

DivMMC Programmer

Since it's Arduino day, here's a recent project where the Arduino came in very useful.
I posted that picture on twitter and had many suggestions as to what it could be, including:

  • Arcade button controller of some sort?
  • Electric shock russian roulette version of the popular Simon memory game
  • Some sort of video mux 
  • CBM serial port network?
  • For testing cables?
  • Quiz buzzer system?
  • Bespoke Track and Field controller?
  • Three-player controller for Flappy Bird!
  • RGB pattern generator?
  • MIDI? Is it a MIDI thing?

And several people who had presumably been watching the IT Crowd, suggested that it was 'The Internet'. Well, no, as much as I would like to announce that this is 'The Internet - Mark 2", where you can safely type google into google without destroying the universe, it is not.
With the labels on, it may make more sense. This is a programmer and tester.
And that is what it programs and tests, the new DivMMC Future from The Future Was 8 Bit. With lots of orders for this coming it, programming each one individually takes a long time, so this will automate this process and program 4 units in parallel. Not directly, but via a number of remote controlled ZX Spectrums.
The Spectrums are connected via the 4 cables on the bottom. The cable on the side controls an ATX power supply to power the Spectrums and monitors.
That worked out very nicely, the 5V standby supply powers the programmer, and power to the main 5V and 12V can be controlled by the Arduino to turn them on or off. The Spectrums are powered by 5V and 12V from the accessory power connectors (normally used for disk drives etc.). These adapter plug into the 3 pin connector where the 7805 regulator would have connected and feed both 5V and 12V into the board.
The programmer needed to automate the process of powering on the units, loading the programming software, programming the units and then power cycling them and testing them out. The power control was already sorted. Next was loading the programming software. This is a one off project, so I went for an Arduino as a base for the project to get something up and running quickly without a custom PCB or too much handwired prototyping.
I did think about loading the .tap or .tzx file from SD card and getting the Arduino to generate the appropriate tones, but I went for a simpler option and used a Sparkfun MP3 player shield to play an MP3 into the tape port of the Spectrum.
The Spectrums we were using for this were Grey 128K +2 units, which have a built in cassette drive, which includes some signal processing, and feeds the Spectrum with a TTL level signal. I built a simple transistor buffer to generate a TTL level signal from the MP3 player output.
The signal goes through some RC filtering inside the Spectrum, so to avoid any interaction between multiple inputs in parallel, I buffered this signal via a gate in a 74LC04 inverter and then inverted it again via one inverter gate per output.
The system is controller via three large, friendly, illuminated arcade buttons on the top, all wired up to headers on the middle board. These light up to indicate which mode it is in. The software is a state machine which progresses through the steps required for 'Program' and 'Test. The blue and green buttons light up to show the current mode, and turn off when complete. The red buttons always shows if the power status, and pressing it turns the power on or off in any mode.
At the bottom of the board stack is the Arduino. I tried various different boards here. The one on the left is an Atmel ATmega328PB Xplained Mini. This has 'Ardunio compatible' headers on the board, and some extra pads where I planned to attach the cables for the buttons and the connectors.
I was hoping it would be possible to flash this with an Arduino compatible boot loader, but didn't get that working. Instead I use Arduino to build the code, and then programmed the board with the hex file via Atmel Studo. Unfortunately, I couldn't get that to work with the Sparkfun MP3 shield, I think due to an issue with the SPI bus.
I looked around an dug out an old 'Arduino compatible' Lenoardo clone. That also had extra pads for headers. That also didn't work - the SPI pins are in different locations on the Leonardo. Finally, I went back to the Arduino UNO I had been using for development, since that was working.
So we have power and audio, the next was controlling the Spectrum. To do that, I had 4 spare outputs from the Arduino, wired in parallel and fed to each Spectrum. Each one of these would attach to a gate of a 4066 quad analogue switch which would be wired into the keyboard matrix to mimic pressing a key. This is designed to be reversible, so the 4066 is only tacked onto the chip below to steal 0V and 5V. The rest is just pushed into the membrane connectors.
I wired up 4 control lines in case the requirements changed. There needed to be the enter key to start the tape loader (easier on the +2 than J symbol shift+P symbol shift+P on a 48K), space to start the programmer, then arrow keys to navigate the DivMMC menu to load a test program.
During the testing, I found I could narrow this down to enter and 6. 6 was both the down arrow for navigation, and 'any key' to start the programmer.
I'll add some photos of the programmer in use and the 4 Spectrums, once they have been assembled in their new home.

UPDATE

The 4 Spectrum boards have been repaired and assembled and the programmer is now running 4 way.

If you want to support this blog, you can donate via Patreon or Paypal, or buy something from my store.