Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
User Journal

Journal Alioth's Journal: [Z80] Infra red 2


Now the world has gone to bed,
Darkness won't engulf my head,
I can see by infra-red,
How I hate the night

      -- Marvin the Paranoid Android

So, for the wind vane I want to make, I need some method of measuring the angular deflection of the vane within 10 degrees, so to turn it into a wind direction.

You can do it with a potentiometer. The trouble becomes finding a pot that has no mechanical stops and a continuous track with only a very very small break at the ends (so there's not a tremendous dead spot where you're not able to measure). Finding a pot with no mechanical stops is easy. But finding one with a dead spot less than 20 degrees is not! The potentiometer approach also brings a few other issues - you need an ADC (and all the issues that brings - careful PCB layout to eliminate noise on the analogue side just to start with).

But there's an easier way: optical sensing. An array of infrared LEDs and an array of infrared phototransistors. The basic approach is this. Six IR LEDs shine through a disc, to six infrared phototransistors below. The disc itself is Grey coded. The six phototransistors give you six bits of data, which is enough to encode 0 to 35. The disc itself is made from single sided PCB material. Print the pattern on the disc and etch like any other PCB. The PCB material is translucent, so the infrared will make it through the material where the copper is etched away.

Grey coding is used so moving from segment to the next only causes one bit to change - enormously reducing the probability of an ambiguous value being read. http://en.wikipedia.org/wiki/Grey_code

The good thing about this approach is that there's no analogue electronics involved. The scrapped cash registers I talked about a while ago all had touch screens. These touch screens weren't really touch sensitive at all - there's an array of IR LEDs and phototransistors surrounding the LCD, so when a finger breaks the beam it can figure out where the touch was. As a consequence, I have hundreds of IR LEDs and phototransistors.

I have no datasheet for these things. They are all surface mount types, so are rather small. They have no markings. You can't even tell which the anode and cathode is on the LEDs, or the collector/emitter on the transistors. So there was nothing for it, except to solder wires onto a couple of them and plug them into the breadboard! I presumed the transistors would be NPN, so I plugged one end into the 0v rail on the breadboard, and the other end to a resistor (and the other end of the resistor to Vcc). This basically forms an inverter (NOT gate) which is activated by light instead of electric current. Amazingly, I got the transistor the right way around right off.

Then I had to do the same with the IR LED. I guessed it'd have the same forward voltage drop as a typical LED so put the same current limiting resistor that I would use with a normal LED, this turned out to be wrong and I think I killed the first one. The second one I put a ridiculously big resistor in to start with (2.2K). It illuminated OK (I could tell because it set the photo transistor off). I reduced the resistance until the brightness was a bit higher.

First, I ran the output through a 74HCT125 (TTL compatible tristate buffer), driving a normal 5v green LED to see how well it worked. With some experimentation, I found it needed a fairly large resistor in the IR transistor/resistor network (100K) to make the circuit sensitive enough; actually, that made it a little bit too sensitive - with the LED pointed somewhat off the target, the photo transistor could pick up the IR from the room lighting. I also tried a 74HC368 tristate inverting buffer (a straight CMOS chip, so with different thresholds). After a bit of experimentation with putting a PCB between the LED and transistor, I found that a 47K resistor on the resistor/transistor network was about the sweet spot for sensitivity.

The LED/transistor seems pretty directional (which is good), and I'll need to fiddle some more because the disc is going to have to have reasonably small features to get at least 36 segments.

This discussion has been archived. No new comments can be posted.

[Z80] Infra red

Comments Filter:
  • Interesting approach, I really liked the PCB-as-disc idea; that's neat. And 47 kilo-ohms seems reasonable from what I've done with optical sensors.

    However, there is one caveat here which applies when feeding logic circuits from essentially non-two-state devices, such as phototransistors, that go gradually (though often quickly) from fully-on to fully-off. It is somewhat likely (from Murphy's law if nothing else) that the wind would be coming from such a direction that one of the 6 channels would be right

    • by Alioth ( 221270 )
      Duh. Why didn't I think of that? I had already observed that if I was really careful, I could get the output into a halfway state, and I did indeed think of the N and P channel conducting simultaneously in the buffer. And I have two different schmitt trigger buffers already kicking around. Hopefully, I won't forget this lesson :-) I'm at a loss as to why I thought of the current use then dismissed it when the obvious thing to do was to use a different chip! D'oh. (I think I have a 74HC14 and a 40105).

      Good p

The flow chart is a most thoroughly oversold piece of program documentation. -- Frederick Brooks, "The Mythical Man Month"

Working...