Evie Beer: Episode 9 – Doh! and Happy Ending

As we saw last time, I had been having trouble getting meaningful measurements of joystick position using the ADC. It only goes to show few many readers this blog has, because the circuit diagram showed exactly what the problem was, quite clearly, yet no-one commented!

And of course all that impedance-limit waffle I spouted last time was just that – waffle. Google to the rescue.

World Record?
Given that the X pot of the very old and battered joystick I had was iffy, I decided to call on eBay to get another PC analogue joystick.

I placed the order at 09:00am on the dot, and got a message from eBay at 09:02am stating that the item had shipped. Jeepers, that’s quick! Even though what it really means is “we’ve handed it off to a delivery agent, so it’s out of our hands now”, that speed is still darned impressive.

Even more amazingly, the joystick turned up at my front door on the Isle of Man the following day – now *that* is a world record, it usually takes 2 days minimum from UK for a courier delivery, with an overnight stop off in Liverpool…

Ground Dog
In a PC analogue-interface joystick, the axis potentiometers are wired as variable-resistors (ie: with one of the outer pins completely unconnected), rather than as a variable-voltage-divider, which would be the more traditional use of a potentiometer. You would have thought I might have noticed that only two of the three lugs were connected when I disassembled the old joystick, but no, I was just too slow on the uptake. Doh!

Thus there is a “missing” ground connection that I must provide myself on the external breakout board. This makes sense, as in the PC analogue joystick interface, the host is (effectively) an RC timer circuit used to trigger a 555 timer, for which a variable-resistor is exactly what is needed. For a hook-up to an ADC, that of course won’t do.

Note that most PC joysticks are wired with 5V power to the *center* pin of the pots, and output signal on an outer pin, which is exactly the reverse of what would be needed to wire it as a voltage-divider by adding a ground wire to the unused pin.

Convert to Voltage-Divider
Digital voltmeter showed the new joystick with a resistance-to-power-line of between zero and 80Kohms, on both axes. Thus to get the widest most-nearly-linear spread of voltages to measure, I added a 40Kohm (80/2) resistor to the breakout board from each axis-pin to ground. There are be a lot of resistors piling up on that little board!

Of course, using a fixed external resistor means the stick response is not going to be linear, you would have to take the joystick apart and wire the unconnected pot pins directly to ground to get a truly linear response (assuming linear pots of course). But with a *half-range* fixed resistor, its’ as close as we’re going to get without opening up the joystick.

So does the measurement-circuit/ADC work now?
It sure does! Let’s end with the usual gratuitous video to demonstrate how well it works.

Retrochallenge Project Conclusions
This “muck about with a 6811 SBC” project turned out to be both fun, illuminating and very frustrating – I learned quite a bit about electronics, after some stupid mistakes. But there are some important conclusions about working in such a constrained minimal environment:

Debugging with LEDs
…is way useful, I’ll be sure to add at least a couple of LEDs to my next electronic hardware.
Learning an Assembly-Code
…is not really much easier for having learned a different one a long time ago: each has its’ own idiosyncracies and cute op-code wierdnesses.
68hc11 Good
It is easy to see why the 68hc11 was so popular in its’ day, it is a very cleverly thought-out MCU. The shed-load of on-chip devices (SCI, SPI, 8-channel ADC, 8-bit parallel-I/O, 8 timer-I/Os, on-chip RAM, EEPROM, ROM and monitor, etc, etc), the fact that it can program its’ own EEPROM (even external EEPROM) without needed strange supply voltages, it all adds up. The other beauty is the on-chip ROM monitor (in bootstrap mode) – this means that you don’t need any special “Development Environment” package or kit: just an assembler, a C or BASIC compiler if you really have to, and a dumb-terminal emulator that can blindly “cat” a file via the serial-port. My development environment was Solaris “tip” on an old Sun workstation, together with the public-domain command-line 68hc11 assembler: pretty minimal, but no less effective for that. I suppose the most telling facet is that the official Motorola “universal” evaluation board contains *only* a 68hc11 MCU and a combined RTC/low-voltage-reset chip and a dozen or so resistors and capacitors: quite literally, nothing else is needed built-in, for smallish systems.

68hc11 Bad
As a small self-contained 8-bit MCU, there are of course some compromises: the lack of stack-indexed addressing can take some getting used-to, as can the lack of computed-offset indexed addressing and the very limited 16-bit arithmetic instructions. For larger programs, there is the I/O compromise: if your program is large enough to require external RAM or ROM then you lose two of the I/O ports. Finally, the fact that most 68hc11 chips are packaged PLCC-52, PLCC-68 or PLCC-84 rather than DIP makes amateur hand-construction of SBC boards somewhat harder.
Squeezing It In
I was surprised how much program functionality you can squeeze into 364 bytes of RAM and 512 bytes of EEPROM. Honestly, I just wasn’t expecting it.
Although the EVBU SBC is a great board for learning embedded system interfacing, my basic electronics knowledge was the limiting factor – but I’ve learned quite a bit doing the project, and will be in much better shape next time around.

I originally expected to use this SBC for the month of retrochallenge, than pass it on to someone else. But no, I have instead added the EVBU and documentaion to my “permanent collection” – there’s plenty more mucking about that can still be accomplished!

And finally, the most promising thing to come out of it all is that I have convinced myself that it *is* possible, in the far future, for a klutz like me to successfully build a “StickyMouse“…


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s