Well, one never gets things right the first time. Looking at that first schematic, I can see it is not the best design. For a start, it uses three chips – way too many. I also ran out of I/O pins so I had none left for the stop button or the MIDI output. I’ve redesigned it using a 7 bit bus approach.
Instead of the 74HC05 buffer, I’ve used a 74HC174 which can latch the MIDI output and allow me to share the bus with the LED display. I’ve also gotten rid of the 74HC47 LED driver, I’m now driving them directly from the PIC.
I went parts shopping today. Jaycar had everything I needed, well, except the PIC. They were out of stock. They didn’t have 8MHz crystals either so I’ll have to use a 10MHz. They also had mysteriously run out of jiffy boxes. Anyway, I got enough stuff to start building the thing.
I did some MIDI research today. It turns out that the MIDI clock protocol is quite simple. All messages I’m interested in are a single byte only. These are the ones I will be using:
The ‘MIDI Clock’ message should be sent 24 times per beat. So at 120bpm, it will need to be sent 48 times per second.
I’ve decided to support ‘MIDI Stop’ as well as ‘MIDI Start’ so I’ve altered the design to include a smaller STOP button beneath the big fat START button.
I’ve also found a schematic for a really simple interface so I can program the PIC from the PC’s printer port (try to say that three times fast!).
I’ve sniffed around several other PIC and MIDI pages on the web today. I’ve found out how to interface the PIC to a MIDI connector and how to make an R/C ramp arrangement to let me read input from an analogue knob. I’ve incorporated these items into my first circuit design.
(click on the circuit to see a larger, more readable version)
Now it so happens that I stol^H^H uh, came across this large illuminated pushbutton recently. It has a large 25mm button illuminated by an incandescent lamp. The switch is a highly reliable microswitch. It was just begging to be used in this project. So I’m designing the thing around it.
To the left is my first conceptual design (scanned off the back of an envelope!). It has the big button at the left, an LED readout for the speed (in BPM) and a knob to set the speed. Underneath the knob is a slide switch to turn the power on and off.
After some research, I settled on the PIC16F84A microcontroller from Microchip. I like this part because it doesn’t need any expensive development kit. These development kits can cost hundreds of dollars, so this represents considerable saving. The PIC16F84A is also readily available and cheap at around AU$10.
- 8 bit RISC CPU core – single cycle per instruction
- On board oscillator (external crystal required)
- Runs at any speed up to 10MHz
- Built in timer-counter
- 13 bidirectional I/O pins
- 1k FLASH memory for program
- 68 bytes of CMOS RAM
- 64 bytes of FLASH for storing data
- In-circuit programming capability
The in-circuit programming combined with the flash program memory sold me on this part. I can develop the software and test it without needing an emulator and without having to constantly swap chips in and out of a programmer or mess about with UV erasers. This should make the software development cycle fast and cheap.
On the downside, it has no serial port. I’ll have to bit-bash the serial output. Still, I’ve done this sort of thing before so it should be no problem.
When performing on stage, we have a problem keeping all our MIDI instruments in time with each other. So I need to create a master sync source. This would be a box which can send a MIDI ‘Start’ command when a button is pushed. It would be nice if it could synchronise this start command with the first beat of the bar so the music never skips a beat.
I decided this would be a good project for me to get back into microcontrollers. It’s been about six years since I’ve done any microcontroller work so I’m a bit out of touch with the latest in that field.