EmbeddedRelated.com
Forums
Memfault Beyond the Launch

interfacing a H21A1,2,3 IR detector with a BX24

Started by carolkysela April 29, 2005
Hello, I have been attempting to interface an H21A2 ir detector to a
basicx BX24. I keep reading and re-reading everything I can search
out on this but I have not been successful in getting it done. I must
be missing something about getting this device to work with the BX24.
I am strictly a hobbiest and in no way an engineer so if you know how
to accomplish this would you mind describing it to me in plain
english? Thank you, Carol



> ... attempting to interface an H21A2...

http://www.fairchildsemi.com/ds/H2/H21A2.pdf

To demonstrate the function of this photointerrupter, you can connect
its LED anode (pin 1) through a 220-ohm resistor to +5v, connect the
cathode (pin 2) to ground; this will supply ~16mA and illuminate the
LED, invisibly to humans. The phototransistor sensor collector (pin 4)
can be connected to any BX-24 I/O pin, like pin 5, while its emitter
(pin 4) is connected to ground.

In code, or in the IDE Project/Chip pulldown menu, configure pin 5 for
Pullup; this will supply a weak current to the phototransitor, providing
a logic high to the input pin when the phototransistor is dark (slot
blocked) or a logic low when the phototransistor is illuminated (slot
clear). Tom
Tom Becker
--... ...--
GTBecker@GTBe... www.RighTime.com
The RighTime Clock Company, Inc., Cape Coral, Florida USA
+1239 540 5700



carolkysela wrote:

> Hello, I have been attempting to interface an H21A2 ir detector to a
> basicx BX24. I keep reading and re-reading everything I can search
> out on this but I have not been successful in getting it done. I must
> be missing something about getting this device to work with the BX24.
> I am strictly a hobbiest and in no way an engineer so if you know how
> to accomplish this would you mind describing it to me in plain
> english? Thank you, Carol
Here are some things to try Carol:

1. Make sure the cathode of the diode and the emitter of the transistor
are both connected to ground.

2. Use a 220 Ohm resistor or similar value to connect the anode of the
diode to +5V.

3. Use a 10K pullup resistor to connect the collector of the transistor
to +5V

4. Use a voltmeter to check the voltage between the collector of the
transistor and ground. You won't see exactly 0V and 5V but you should
see a low voltage (approx 1V) and a high voltage (approx 3.5 to 4.5V) as
you either block or don't block the light path between the diode and
transistor. If it works as described then you can connect it to the
BX-24. It is usually a good idea to use a inverter as a buffer and you
can then also drive a LED from the inverter to see the result. The LED
should blink as you alternately block and unblock the light path.

5. If it doesn't work, double check all of your connections. If you can
try a different device just in case this one is not working. Also try
dimming the ambient light. If that it what makes it work then you may
need a more sophisticated hookup for it to work in daylight.

Mike



I said:

> ... The phototransistor sensor collector (pin ...

.. Should be its pin 3. Tom
Tom Becker
--... ...--
GTBecker@GTBe... www.RighTime.com
The RighTime Clock Company, Inc., Cape Coral, Florida USA
+1239 540 5700


Hi Tom,

Doesn't pin 3 need to be connected to ground also? I have been
attempting this but using a 330-ohm resistor and simply attempting to
read the voltage with a meter but to no avail. Shouldn't the voltage be
readable?

Carol Tom Becker wrote:

> > ... attempting to interface an H21A2...
>
> http://www.fairchildsemi.com/ds/H2/H21A2.pdf
>
> To demonstrate the function of this photointerrupter, you can connect
> its LED anode (pin 1) through a 220-ohm resistor to +5v, connect the
> cathode (pin 2) to ground; this will supply ~16mA and illuminate the
> LED, invisibly to humans. The phototransistor sensor collector (pin 4)
> can be connected to any BX-24 I/O pin, like pin 5, while its emitter
> (pin 4) is connected to ground.
>
> In code, or in the IDE Project/Chip pulldown menu, configure pin 5 for
> Pullup; this will supply a weak current to the phototransitor, providing
> a logic high to the input pin when the phototransistor is dark (slot
> blocked) or a logic low when the phototransistor is illuminated (slot
> clear). > Tom >
> Tom Becker
> --... ...--
> GTBecker@GTBe... www.RighTime.com
> The RighTime Clock Company, Inc., Cape Coral, Florida USA
> +1239 540 5700 >
>
> *>. >
>
>No virus found in this incoming message.
>Checked by AVG Anti-Virus.
>Version: 7.0.308 / Virus Database: 266.11.0 - Release Date: 4/29/2005




Carol, I don't know your application nor budget but have you considered
Sharp modules that are fairly low cost, do most of the Analog
processing, and are packaged with IR filters? Here is a general link
about their sensors:

http://www.acroname.com/robotics/info/articles/sharp/sharp.html

- Tom

--- In basicx@basi..., "carolkysela" <carolkysela@y...> wrote:
> Hello, I have been attempting to interface an H21A2 ir detector to a
> basicx BX24. I keep reading and re-reading everything I can search
> out on this but I have not been successful in getting it done. I must
> be missing something about getting this device to work with the BX24.
> I am strictly a hobbiest and in no way an engineer so if you know how
> to accomplish this would you mind describing it to me in plain
> english? Thank you, Carol



> ... Doesn't pin 3 need to be connected to ground also? I have been
attempting this but using a 330-ohm resistor...

No, pin 4, the phototransistor emitter, must be grounded in the
configuration I described. Pin 3, the collector, is where you'll see a
voltage change when illumination on the phototransistor changes - but
not through a 330-ohm resistance, which is far too small for this
sensor. Try connecting the collector to +5v through a 10k or 100k
resistor and then test the voltage change on the collector as you block
and unblock the slot - with the LED powered (through the 220-ohm
resistor), of course. Tom
Tom Becker
--... ...--
GTBecker@GTBe... www.RighTime.com
The RighTime Clock Company, Inc., Cape Coral, Florida USA
+1239 540 5700


Hello again Tom,

I received a number of replys to my plea for help with the H21A2/BX24
connections and the one below seemed to work best as far as the voltage
differential displayed on the meter.

So, your connections should be:
>Pin 1 to 330 ohm resistor tied to +5V (+) Anode
>Pin 2 GND (E) Cathode
>Pin 3 to 3.3K ohm resistor tied to +5V (+) Collector
>Pin 4 GND (D)Emitter

It is about .5v at the bottom and 4.5v at the top of the range depending on whether the light path is blocked or not.

However, the BX24 doesn't seem to see the difference at all. I declared the pin as tristate (most recently) but the reading of the pin seems to randomly flip from 1 to 0 and back without regard to the state of the H21A2 situation. All of the connections seem to be solid.

I hate to trouble you yet again but would you have any thoughts about the above situation.

Carol Tom Becker wrote:

> I said:
>
> > ... The phototransistor sensor collector (pin ...
>
> .. Should be its pin 3. > Tom >
> Tom Becker
> --... ...--
> GTBecker@GTBe... www.RighTime.com
> The RighTime Clock Company, Inc., Cape Coral, Florida USA
> +1239 540 5700 >
> *>. >
>
>No virus found in this incoming message.
>Checked by AVG Anti-Virus.
>Version: 7.0.308 / Virus Database: 266.11.0 - Release Date: 4/29/2005




Hello again Mike,

I received a number of replys to my plea for help with the H21A2/BX24
connections and the one below seemed to work best as far as the voltage
differential displayed on the meter.

>Pin 1 to 330 ohm resistor tied to +5V (+) Anode
>Pin 2 GND (E) Cathode
>Pin 3 to 3.3K ohm resistor tied to +5V (+) Collector
>Pin 4 GND (D)Emitter

It is about .5v at the bottom and 4.5v at the top of the range depending on whether the light path is blocked or not.

However, the BX24 doesn't seem to see the difference at all. I declared the pin as tristate (most recently) but the reading of the pin seems to randomly flip from 1 to 0 and back without regard to the state of the H21A2 situation. All of the connections seem to be solid.

I hate to trouble you yet again but would you have any thoughts about the above situation.

Carol

Mike Perks wrote:

> carolkysela wrote:
>
> > Hello, I have been attempting to interface an H21A2 ir detector to a
> > basicx BX24. I keep reading and re-reading everything I can search
> > out on this but I have not been successful in getting it done. I must
> > be missing something about getting this device to work with the BX24.
> > I am strictly a hobbiest and in no way an engineer so if you know how
> > to accomplish this would you mind describing it to me in plain
> > english? Thank you, Carol
> >
> >
> Here are some things to try Carol:
>
> 1. Make sure the cathode of the diode and the emitter of the transistor
> are both connected to ground.
>
> 2. Use a 220 Ohm resistor or similar value to connect the anode of the
> diode to +5V.
>
> 3. Use a 10K pullup resistor to connect the collector of the transistor
> to +5V
>
> 4. Use a voltmeter to check the voltage between the collector of the
> transistor and ground. You won't see exactly 0V and 5V but you should
> see a low voltage (approx 1V) and a high voltage (approx 3.5 to 4.5V) as
> you either block or don't block the light path between the diode and
> transistor. If it works as described then you can connect it to the
> BX-24. It is usually a good idea to use a inverter as a buffer and you
> can then also drive a LED from the inverter to see the result. The LED
> should blink as you alternately block and unblock the light path.
>
> 5. If it doesn't work, double check all of your connections. If you can
> try a different device just in case this one is not working. Also try
> dimming the ambient light. If that it what makes it work then you may
> need a more sophisticated hookup for it to work in daylight.
>
> Mike
>
> *>. >
>
>No virus found in this incoming message.
>Checked by AVG Anti-Virus.
>Version: 7.0.308 / Virus Database: 266.11.0 - Release Date: 4/29/2005




Hi Tom,

I have previously used a part HOA7730-M22. This thing has TTL output
and works perfectly right out of the box. The completed HOA... unit
(connectors etc.) goes for a bit over $10 or a little under 10 times
what an H21A2 goes for. I don't know about it but the Sharp stuff
probably would work also. It's just that I don't see any reason why
the H21A2 wouldn't work and if I discover do discover a reason that it
won't then I will have learned something new.

Carol --- In basicx@basi..., "tombhandley" <gr13tbs@c...> wrote:
> Carol, I don't know your application nor budget but have you considered
> Sharp modules that are fairly low cost, do most of the Analog
> processing, and are packaged with IR filters? Here is a general link
> about their sensors:
>
> http://www.acroname.com/robotics/info/articles/sharp/sharp.html
>
> - Tom
>
> --- In basicx@basi..., "carolkysela" <carolkysela@y...> wrote:
> > Hello, I have been attempting to interface an H21A2 ir detector to a
> > basicx BX24. I keep reading and re-reading everything I can search
> > out on this but I have not been successful in getting it done. I must
> > be missing something about getting this device to work with the BX24.
> > I am strictly a hobbiest and in no way an engineer so if you know how
> > to accomplish this would you mind describing it to me in plain
> > english? Thank you, Carol




Memfault Beyond the Launch