Evie Beer: Episode 8 – RTFM!


This time, we’re looking at the built-in analogue-to-digital convertor on the 68hc11. In principle, this should be quite easy, but in practice there turned out to be some caveats.

First problem was that I had assumed that the breakout connector on the evaluation board SBC had port E wired in the same sequence as ports B and C, so it might not be all that surprising that I was only able to get stable results from one ADC channel – the other was always a bit arbitrary… because I had connected one jumper to the wrong pin. I spent a couple of days testing with the ADC inputs shorted to ground, to +5V supply, swapped over; checked and rechecked the wiring and soldering on the breakout board; tested with a single-channel program and a multi-channel sampling program. It all seemed very mysterious and inexplicable!

Eventually, having exhausted all other possibilities, I was skipping through the EVBU manual just looking for *something*, *anything*, when I noticed that the CPU port E pins are not pinned-out on the connector in the same sequence as the other ports. Darn!!!

Rule two of electronic tinkering: RTFM!

Iffy Levels
Mind you, even when connected to the right pins, I was still unable to get meaningful ADC results for the X- and Y-axes of the external joystick. When the ADC inputs were connected directly to +5V or GND, I got solid repeatable 0xFF or 0x00 (sometime 0x01) results, on both channels and on each independantly.
20150728_080550
How about measuring an intermediate voltage? A 1.5V battery might be interesting…
20150728_082009
Even without a current-limiting resistor (EEK!), that actually works fine: a solid reliable 0x51 value. OK, so the ADC response is not perfectly linear with my circuit, but it’s darned close.

So why wasn’t the joystick output giving meaningful values? After all, it’s just a simple varistor between +5V and GND, should be no problem at all… was there something wrong with the very old joystick?

Desperation Will Tear Us Apart
Have you ever noticed that the amount of gratuitous hardware disassembly is directly proportional to the amount of project desperation? Thus:
20150728_101022

Although the small internal straight-through junction-board inside this joystick was mislabelled (Fr and Fr2 were not the button lines, “X” was not the X-axis output, and so on), the wiring inside was correct and sound – no solder breaks, the wires from the plug pins go where they really should do.

A digital meter showed that the Y-pot was fine: in centre-adjusted trim setting, resistance varies between 140K and 0, with a centre at roughly 65K – it’s one of those 150Kohm slightly-more-recent joysticks, not the original 100Kohm IBM one.

However, the X-pot was a bit of a mess: resistance varies between 110K and 174K with a centre at 164K. Holy Cow!!

As you may have noticed, this joystick has “trimmers” on it – to adjust the true centre-position. Analogue joysticks were notorious for requiring calibration, often painfully done in host software in the early days – in the latter half of the 80s, joysticks with trimming-sliders became more common, to handle calibration on the hardware side without needing the host software (every game, etc) to have its’ own calibration routines.

Careful inspection shows that the X trimmer on the joystick was centred, and had not “slipped” inside the case. In the process of testing response to the trim setting, I twisted the pot a bit too far and managed to break the spot of factory-melted plastic that held the pot body in a fixed rotational position on the trimmer-slider.
potspota
However, this allowed me to play even further with the trim setting, which comes into play later on.

Impy Dance
Somewhat naively, I had assumed I could read voltages directly off the joystick outputs:
axis_schematic
It turns out that the maximum source impedance for the 68hc11 ADC is (quote) 10Kohms, not the 100K or more that an analogue PC joystick uses. I could get correct and repeatable 0xFF,0xFF reading of X and Y when the stick was at top-right, but it would never read less than 0xFD,0xFD nomatter how the stick was positioned. Needless to say a swing count of 3 (at best, with a following wind) is a pretty poor resolution, compared to the 256-count swing I was hoping for.

A False Hope
I toyed with the idea of a fixed series 10K resistor input to the ADC, with the joystick varistor in parallel to ground (in turn with a series 1K current-limitor) – some of the current would go each way, right? Ah, but I’m measuring voltage, not current, so even that ain’t gonna work:
axis_schematic2
At this point it becomes clear that I am going to need an *active* external component: either a unity-gain op-amp impedance-reduction circuit (with caps and resistors et al et al), or revert to the PC-style 555-based capacitor-charge polled-timing circuit – which would be *way* more complex on the software-side.

And that’s after fixing the iffy X-axis potentiometer in the joystick.

Leftovers
A bit of extreme over-rotation of the X-axis pot body, as hinted at above, in an attempt to reduce the total resistance-swing, showed that wouldn’t do either: once past the factory default spotted position, the thing goes massively non-linear. From a centre-position 10K, minimum is 0K (good!) but maximum-displacement resistance is still 160K (bad, way to high!). Either this pot is compleletly stuffed, or an active external circuit would be needed.

Looks like this project may have reached its’ natural end, due mainly due to my lack of electronics experience and knowledge.

But with two days to go, the fat lady hasn’t sung the Wonder Woman theme-tune just yet. I am going to rummage in my box of old scavenged circuit-boards to see if there are a couple of low-range-resistance potentiometers in there somewhere…

And of course, there’s always the project summary to write.

Advertisements

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