ADAM'S WEB PRESENCE

30 September 2001

Writing the Code

Filed under: Homemade Creations, MIDI Sync Box — adam @ 4:02 pm

I’m steadily building the firmware for this thing. Something that sounds simple is turning out to be a little more complex than I thought, still, that’s pretty normal in the software world. My program is around 600 lines and I’ve still got a lot of stuff left to do.

Another problem I’ve come across is the Potentiometer voltage ramp arrangement has turned out to be not very accurate, the reading varies wildly depending on voltage, temperature, current and just about any other variable you can think of. After wasting a lot of time with it, I’ve decided it’s just not a suitable method for setting the speed.

Rotary EncoderSo instead, I’ve got myself a rotary encoder. This looks like a potentiometer but it’s actually a binary counter which increments as you turn it. It has detents so it won’t drift once you turn it to a specific position and is generally much more suitable for this role.

Of course, I now have to modify the software to read it.


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!


Powered by WordPress