This is my personal blog. I also have a professional blog at http://siliconsparrow.com/

22 September 2001

Learning to Program the PIC

Filed under: Homemade Creations,MIDI Sync Box — adam @ 3:55 pm

The finished circuit boardNow it’s time to move back into the software domain. Microchip supply a development environment called MPLAB. You can download it for free off their website. Only problem is, it doesn’t work, it kept giving me these errors “Could not initialise dialog box” and would refuse to compile anything. I suspect that there is a DLL missing in the installer, but I have little time to debug other people’s software.

Fortunately, there is another little utility that comes with MPLAB called MPASM for Windows. This program is a little irritating since it dies after every compile but having to reload it every time is a minor inconvenience compared to MPLAB.

So, finally I managed to compile some of the example code. The next step was to learn the PIC’s programming language and write some stuff of my own.

I haven’t done any microcontroller programming for six years, and even then it was on a Motorola 6805, a totally different architecture; so I expected a bit of a learning curve here. But to my surprise, I managed to learn the new instruction set and write some code that worked within an hour. Writing firmware must be like riding a bicycle.

The time had come to do some more electronics. I put together my LED display and wired it up to the PIC. A little bit of soldering, a little bit of coding and in hardly any time, I had a fully functional 3 digit LED counter tumbling away through the numbers.


20 September 2001

Building the PIC Programmer

Filed under: Homemade Creations,MIDI Sync Box — adam @ 3:49 pm

Front panel, you can see the LEDsThe programmer with modificationsI’ve built the little NoPPP programmer. The only problem with the thing is it has no flashing lights of any kind! So I put in two LEDs, one to indicate power and the other to indicate programming voltage.

You’ll also notice that there is no PIC socket in my programmer. That’s because I am going to be doing in-circuit programming.

The NoPPP test mode was very handy in finding a couple of problems with my setup. The biggest problem was the LED I added to indicate programming voltage was draining too much current and the programming voltage dropped to about 8 volts. That was too low so I added another transistor specifically to drive the LED and all is fine.

Then I wired my PIC onto a board and tried to program it. No luck. The verify failed although chip erase seemed to work.

I tested all the voltages again with my voltmeter. Everything seemed fine. Perhaps my PIC was bad. It was brand new so that would be unlikely. I decided it was time for more analysis. I got out my dusty old rusty old CRO and had a poke around. All the data signals looked fine so I kept looking. Finally I found it, the programming voltage would drop to 6V when the chip was being programmed. This only happened for about a quarter of a second which is why I didn’t see it on my voltmeter. When the programmer was in test mode, the voltage was OK. The only difference I could spot was that in test mode, the PIC was not switched into the circuit. It sounded like my PIC might be internally shorted.

I still wasn’t ready to believe that the PIC was faulty. I checked my wiring again. Found it! There was an almost invisibly tiny solder bridge between the programming voltage pin and an I/O pin. So, once fixed, the program could be downloaded just fine.

Next I attached a LED to a random I/O pin and ran the test program that comes with NoPPP. The LED started flashing furiously. It’s a wonderful feeling when something works!


25 August 2001

Second Circuit Design

Filed under: Homemade Creations,MIDI Sync Box — adam @ 3:40 pm

Click to see larger version 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.


23 August 2001

How Does MIDI Work Anyway ?

Filed under: Homemade Creations,MIDI Sync Box — adam @ 3:18 pm

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:

NAME HEX BINARY
Start 0xFA 11111010
Stop 0xFC 11111100
MIDI Clock 0xF8 11111000

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!).


22 August 2001

First Circuit Design

Filed under: Homemade Creations,MIDI Sync Box — adam @ 2:55 pm

Click to see larger versionI’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)


19 August 2001

First Concept

Filed under: Homemade Creations,MIDI Sync Box — adam @ 2:34 pm

It's big and red! 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.

Shows how this project had such crappy beginningsTo 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.


16 August 2001

The PIC Microcontroller

Filed under: Homemade Creations,MIDI Sync Box — adam @ 2:23 pm

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.

The PIC

  • 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.


12 August 2001

I Need a MIDI Sync Box

Filed under: Homemade Creations,MIDI Sync Box — adam @ 2:17 pm

Out of Sync again. Bugger.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.


« Previous Page

Powered by WordPress