Breadboard Bits - Pic16F84, V2

Introduction

This was a later attempt at doing things with the PIC16F84. It includes several common things, including RS232 and motor control, and a few more challenging things, including LCD control.

This board has again been left behind in the move to newer and newer things.

The Board

My PROG84 in action.
Since most of my previous PIC setup is still missing (probably still buried in boxes with the stuff I haven't moved in yet), I decided to build a new setup. My new PIC programmer board arrived, but everything else had to be redone. My old power supply vanished (so I built a nice one). My prototyping board vanished, so I set up a new one.

Worse yet, my old computer vanished! I took a crash-course in Linux-hosted microcontroller programming as I put my old laptop to service in place of it. I managed to get a very complete set of tools running, including a C compiler.

The current setup will flash an LED. The neat part is that, this time around, it's written in C.

At this point, I had a problem, since my ICSP (In Circuit Serial Programming) cable ALSO vanished. I had to keep swapping the chip off the breadboard and into the programmer.

Driving an LCD

A Hitachi HD44780-based character LCD connected to my PIC setup.
My next project, once I got everything up and running and sdcc (the C compiler) started to cooperate with me, was to start building a library of common code modules for future development.

The first module was a set of general-purpose timing functions. They depend on a 4MHz crystal, but should be easily adaptable to other crystals (I hope). After that, it was time to interface some real hardware.

The first (and most satisfying) hardware to do this with was a Hitachi HD44780-based LCD module. I whipped up some code, and the LCD turned on, blank. The code was SUPPOSED to print "Hello World". I tried many times, resorting to 'scope debugging (and fixing my scope when I had an unexpected mechanical failure in the main dial).

I eventually realized that the LCD was working just fine, but I was setting it to initialize in "Display Blank" mode. Swapping that bit, the LCD came on just fine, and there was text!

I then tried to make the functions somewhat generic, but sdcc still has bugs with string table handling, so that didn't really get very far. Currently I still have to write the characters out one at a time.

The code for this, which was never great to begin with and had a nasty habit of not compiling, has since been forgotten. If you wanted it, too bad. I do, however, have another LCD library that I actually wrote in assembly.

Another shot of my new setup with LCD.
The very satisfying words that let me know that the project was a success.

Pic LCD and Max203E

The LCD board, after adding a Max203E and a serial cable.
Right about the same time that I finished my LCD board, Maxim sent me a bunch of free samples of various types of chips. Among these was the Max203E, which is essentially a modern version of their popular MAX232, with internal capacitors and ESD hardening. How could I possibly resist?

Quickly I assembled a little serial cable and attached it to the board. With some tweaking to the time constants, I managed to get it reliably receiving data, which I then displayed to the LCD.

After adding a few simple formatting commands (mostly "clear screen" and "next line" on the CR and TAB keys), I had a simple serial-line LCD!

A picture of the board with wiring completed.
The test data, being entered in minicom.
The same data that's on the computer screen, displayed on the LCD.

Another Stepper Driver

The LCD board, after attaching a unipolar, 4-coil stepper motor. Again, I was lacking the proper headers for this job as well, so I used a bunch of minigrabbers instead. Minigrabbers are handy. I have since picked up a lot more.
I decided it was time to start moving towards designing a control board for my robot, so I took my spare stepper (which is exactly the same kind used on my robot, 12V unipolar 4-coil) and started wiring it up. I had ordered a pack of 2N3055's to do the power driving, only to realize that not only would I need a pre-drive transistor to get enough current from the 2N3055's, the pre-drive transistors could source enough current for the stepper by themselves. Oh well, at least now I have a pile of power transistors on hand for the future.

And now time for another lesson in embedded software development... it's always the software's fault! I got the motor attached right basically from the start, wired to use a 74LS273 octal buffer chip across the 4-bit data bus used by the LCD with an extra enable pin to drive the 4 control wires, each of which drives a general-purpose, high-current transistor through a 470Ohm resistor. Very simple, and it should have worked. Of course, a 4-coil motor has quite a few permutations to find the correct step sequence.

And although you might have the best designed hardware in the world, it doesn't help if you accidentally try using 0x to represent a binary mask instead of the hex field it should. Anyway, after hours of painstaking oscilloscope debugging, I added in some LED's to display the current state of each driver, and tracked it down to the abovementioned coding error in minutes. Software sucks.