Killer Serial

by Chuck November 2, 2010

adapter-smallThe Membership Card has a 25-pin connector on the standard front panel. The designer, Lee Hart, intended for this connector to be used to control the Membership Card using a standard PC parallel port.

The only problem is that most PCs, and all laptops, don’t have parallel ports any more. And even when they do, there aren’t any commonly available parallel port drivers for computers that run Windows Vista and Windows 7. It’s a dilemma, especially since even the one computer that I have at home with a parallel port runs Windows 7.

But we are not without our resources here at Brambly Hill, and one of the resources that we have is the Revolution Education PICAXE® microcontroller. Specifically, the PICAXE-20X2. The 20X2 has enough I/O to provide an 8-bit bi-directional data port and all the other control and data lines that I need to connect Membership Card to a PC via a USB serial port.

Terminal program communicating with Membership Card serial port adapterWindows Membership Card Control Panel programAll that it takes is a little software, and I know how to do software. I am, after all, a professional. A little software here, a little hardware here, and I had a serial port interface for my Membership Card. In the picture you can see it running on my large breadboard (along with a another bit of hardware that I’m experimenting with). I actually built this circuit up before I got the Membership Card from Lee – I wanted to bench test the software to make sure that it was working the way I expected. Having the Membership Card simulated by a set of LEDs let me work the kinks out of my PICAXE software, and do a lot of improvement to the code before I ever saw the actual hardware. Not only does the serial port adapter work with a standard terminal program, but I was also able to write a simple Windows application to act as a control panel for the Membership Card. Two for the price of one, and they both worked. At least with the simulated hardware. The next step was to test it with the actual Membership Card.

And that’s where the fun starts.

I started with the easiest control line, INP. Just toggle the control bit, and the Membership Card should write the data on the switches to the RAM. It’ll show up on the output LEDs, and I’ll be able to reset and run the program using the toggle switches. Piece of cake. And it was. I spent a happy few minutes toggling in programs and then pushing the INP button on the Windows control program to load them into memory. Even that was an improvement – that tiny little input switch on the front panel was starting to hurt my finger when I pressed it.

So far, so good.

I hooked up the Memory Protect line – and discovered that it worked opposite of how I originally thought. When I put the Membership Card in Read/Only mode, you could write to the RAM, and in Read/Write mode, you couldn’t. That was a simple change in the PICAXE code for the adapter. Now I can control whether you can read and write RAM from the Windows program. Cool.

I hooked up the LOAD and CLEAR lines. Nothing worked. I couldn’t get the Membership Card to load data, I couldn’t get it to run, nothing. I pulled all the control lines out. I put them all back. I checked the schematic, I swapped pins. I changed the high/low states of both lines. Nothing.

After the fourth time that I’d pulled all the wires out of the breadboard I noticed on the schematic that when the LOAD and CLEAR switches on the Membership Card are in the LOAD position (both down), they are connected to ground. When they are in the RUN position (both up), they are connected to +5V through a pull-up resistor – and to the 25-pin connector. I put the wires back in place, flipped both switches up, and was immediately able to put the Membership Card into RESET, LOAD, and RUN modes from the Windows control program

The last thing to do was connect the data lines and start sending data from the Windows control program to the serial adapter and then from there to the Membership Card. I busily attach jumpers from the control port to the breadboard to hook up the data bus. All eight. I turn everything on, and then try to send data. Nothing happens. Even the LEDs connected to the 20X2 port aren’t lighting up. I pull all the data bus jumpers. I send data. The LEDs flash in the appropriate pattern for the data that I send. I put the jumpers back in. No illumination on the LEDs. I pull ‘em again. The LEDs light up.

You’re probably ahead of me. I glanced up at the schematic. When the data switches are in the down position, they connect to ground. In the up position they connect to +5V through a pull-up resistor – and to the 25-pin connector. I put all the jumpers back in again. I switch all the data switches up. I load the RAM with the simple “Hello world” program (7B 30 00). I set the Membership Card into RUN mode. Nothing happens.

ARGH!

I reset. I step through memory. The pattern on the data LEDs change. They look – odd. They’re – backward? I look at the breadboard. I’ve connected D0 to D7, and so on. I’ve reversed the connections on the data bus. Pull ‘em out. Put ‘em back in the opposite order. Load the RAM. Reset. Run.

Q LED lights up.

More rainbows. More bluebirds. Or something.

I load a few programs. I’m happy. I try to use the Windows control program to load an Intel HEX file onto the Membership Card. It fails. I’m sad. I try putting a delay in between the PICAXE-20X2 “pressing” and “releasing” the INP switch. I load the HEX file again. It works.

I’m really happy. It’s also midnight, so I’m really tired.

Just for fun I load Herb Johnson’s version of Dennis' Boone’s implementation of Steve Gemeny’s program to blink the Arecibo message on the Q LED. I go to bed with a “70’s vintage interstellar communications system” blinking away on my desk. I go to bed.

Tags: ,

Electronics

Comments are closed
Log in