Maker Pro
Maker Pro

Newbee: Optocoupler to BasicStamp

S

Sam

I am new to all this stuff an could use a little help.


I am trying to determine the state of a MOC3010 Optocoupler using a
BasicStamp.

I have tried both reading the pin state as well as using the POT command to
read the resistance of the 3010.
I have tried pullup and pulldown (10K) resistors.

Could someone help me design a simple interface circuit to read the state of
the 3010?

Also, I want to power the LED portion of the optocoupler from the computer
USB port. I have been using a 100ohm resistor. Is this a good value to use?

Thanks for your help
 
J

John Popelish

Sam said:
I am new to all this stuff an could use a little help.


I am trying to determine the state of a MOC3010 Optocoupler using a
BasicStamp.

I have tried both reading the pin state as well as using the POT command to
read the resistance of the 3010.
I have tried pullup and pulldown (10K) resistors.

Could someone help me design a simple interface circuit to read the state of
the 3010?

Also, I want to power the LED portion of the optocoupler from the computer
USB port. I have been using a 100ohm resistor. Is this a good value to use?

Thanks for your help
Driving the IRLED (about 1.2 volts drop) in the coupler with 5 volts
through 100 ohms will allow a current of about (5-1.2)/100=.038A which
is lower than the maximum rating of .06A (60mA) and above the maximum
trigger current of 10mA, so it is reasonable.
http://www.fairchildsemi.com/ds/MO/MOC3010-M.pdf

But why are you using a TRIAC output coupler to communicate anything
to a microprocessor? It is designed to control line voltage, AC
loads. Once the TRIAC is triggered, it will stay on as long as its
current stays above the holding current (100uA, typical), regardless
of the input current.
 
S

Sam

Thanks for your reply.
I did not realize some of the things that you said regarding the triac.

Is there a optocoupler that I can use that will just act like a switch based
on the LED status (preferably available at RS). What would the interface
circuit look like.

Thanks
 
J

John Popelish

Sam said:
Thanks for your reply.
I did not realize some of the things that you said regarding the triac.

Is there a optocoupler that I can use that will just act like a switch based
on the LED status (preferably available at RS). What would the interface
circuit look like.

You need a coupler that has a photo transistor as the output device.
Adding a 10k pull up resistor to that output should give you a nice
digital output. Radio Shack is a very limited source of such things,
but you should be looking for something like 4N25:
http://www.fairchildsemi.com/ds/4N/4N25.pdf
 
J

John Popelish

Sam said:
Thanks for your reply.
I did not realize some of the things that you said regarding the triac.

Is there a optocoupler that I can use that will just act like a switch based
on the LED status (preferably available at RS). What would the interface
circuit look like.

Lets start a couple steps back form here. What are you trying to
accomplish with the optocoupler? Is the Basic Stamp powered from the
same source as that driving the LED in the coupler?
 
S

Sam

Thanks again for your help.

The Fairchild site has 12 optocouplers. I dont really understand the specs.
Anyone specifically I should be looking for?


Lets start a couple steps back form here. What are you trying to
accomplish with the optocoupler? Is the Basic Stamp powered from the
same source as that driving the LED in the coupler?

The Stamp will NOT be powered by the same source as the LED.
The Stamp needs to detect when several computers are turned on or off (each
computer will be on its own input pin).
 
J

John Popelish

Sam said:
Thanks again for your help.

The Fairchild site has 12 optocouplers. I dont really understand the specs.
Anyone specifically I should be looking for?

All 12 are slight variations on a theme, any of which would do what
you want. They just have slightly different current transfer transfer
ratios (amount of output current relative to the LED input current.
If you find a source for any of these or anything similar, they will
work for your application.
 
S

Sam

Thanks again.

It's not as easy as you would think to find small quantity electronic
components in NYC. Once a store wanted to charge me $12 for a 7400 logic
chip! Probably will go mail order but have to place a minimum order.
 
J

Jasen Betts

I am new to all this stuff an could use a little help.


I am trying to determine the state of a MOC3010 Optocoupler using a
BasicStamp.

MOC3010 is designed for switching AC power, use 4n28 instead.
I have tried both reading the pin state as well as using the POT command to
read the resistance of the 3010.
I have tried pullup and pulldown (10K) resistors.
Could someone help me design a simple interface circuit to read the state of
the 3010?

it can be done, you need a way to control the current flowing through it.
(or supply it with AC) and also you need to accept a 3v drop across
the device while it's on...
Also, I want to power the LED portion of the optocoupler from the computer
USB port. I have been using a 100ohm resistor. Is this a good value to use?

no.. usb has 5v, the LED wants 1.5V@15ma max, so you need a resistor for just
over 3.5V 3.5V / .015A = 233 ohms, so use 270 Ohms.

+-------------0V
....|.... USB
. 2 1--[270R]--+5V
. .
.MOC3010.
. .
+---------4 6------[10K]------------+---> to pic input pin
| ......... |
| | |
| optional power section -----
9VAC---+--->|-+----[7805]-+--> power to pic |/ \ 4.7V
| | | | zener
----- | --- |
----- | --- |
| | | |
Ov -------------------------------------------+--> to pic ground pin


it's way easier to just use a 4n28, you only need a pull-up resistor.
(and the LED resistor)

Bye.
Jasen
 
S

Sam

Thanks :)

Jasen Betts said:
I am new to all this stuff an could use a little help.


I am trying to determine the state of a MOC3010 Optocoupler using a
BasicStamp.

MOC3010 is designed for switching AC power, use 4n28 instead.
I have tried both reading the pin state as well as using the POT command to
read the resistance of the 3010.
I have tried pullup and pulldown (10K) resistors.
Could someone help me design a simple interface circuit to read the state of
the 3010?

it can be done, you need a way to control the current flowing through it.
(or supply it with AC) and also you need to accept a 3v drop across
the device while it's on...
Also, I want to power the LED portion of the optocoupler from the computer
USB port. I have been using a 100ohm resistor. Is this a good value to
use?

no.. usb has 5v, the LED wants 1.5V@15ma max, so you need a resistor for just
over 3.5V 3.5V / .015A = 233 ohms, so use 270 Ohms.

+-------------0V
....|.... USB
. 2 1--[270R]--+5V
. .
.MOC3010.
. .
+---------4 6------[10K]------------+---> to pic input pin
| ......... |
| | |
| optional power section -----
9VAC---+--->|-+----[7805]-+--> power to pic |/ \ 4.7V
| | | | zener
----- | --- |
----- | --- |
| | | |
Ov -------------------------------------------+--> to pic ground pin


it's way easier to just use a 4n28, you only need a pull-up resistor.
(and the LED resistor)

Bye.
Jasen
 
E

ehsjr

Sam said:
Thanks again.

It's not as easy as you would think to find small quantity electronic
components in NYC. Once a store wanted to charge me $12 for a 7400 logic
chip! Probably will go mail order but have to place a minimum order.

Sad but true. Don't overlook http://www.allelectronics.com/
It's usually cheaper than others, but they are not a supply house.

You can make a list of parts you need and keep adding. When it gets
big enough, use Mouser, Digikey, Newark, whoever and the s/h
charge doesn't irritate as much single orders with 6 dollars shipping
for one 29 cent part.

Also, don't overlook investment in learning. For example, you
indicated that you are unsure about optos. You could buy 5 different
optos from Allelectronics for under 3 bucks plus s/h, and experiment
with them to learn a bit more.

Ed
 
S

Sam

I just ordered some 4N28s. While I am waiting for them to arrive I thought I
would play around a bit.
I just cracked open a mouse and removed the photo transistors, but cant get
the circuit to work.

I have the center leg (base?) going to the input on my Stamp it is also
pulled up by a 10K resistor.
I have tried grounding both (not at the same time) other legs of the photo
transistor, straight to ground and also through various resistors.

I cant get the Stamp to detect on/off states. Any suggestions on where my
circuit went wrong?

Thanks all again.
 
J

John Popelish

Sam said:
I just ordered some 4N28s. While I am waiting for them to arrive I thought I
would play around a bit.
I just cracked open a mouse and removed the photo transistors, but cant get
the circuit to work.

I have the center leg (base?) going to the input on my Stamp it is also
pulled up by a 10K resistor.
I have tried grounding both (not at the same time) other legs of the photo
transistor, straight to ground and also through various resistors.

I cant get the Stamp to detect on/off states. Any suggestions on where my
circuit went wrong?


For most sensitivity, you leave the base unconnected, so the charges
generated by light build up the maximum base voltage to turn the
transistor on. But every photo transistor I have seen in a mouse
doesn't even have the base connection brought out to a pin. They are
usually two pin devices, just collector and emitter, NPN devices.

I would connect the emitter to ground and use a 10k pull up resistor
to the positive supply. Then when you shine light on the transistor,
it should pull down the resistor voltage to within about a half volt
of zero. When kept in the dark, the resistor voltage should approach
the positive supply voltage. Something like this:

+5V
|
.-.
| |
| |
'-'
+--output
|
|/
-|
|>
|

0V
(created by AACircuit v1.28.4 beta 13/12/04 www.tech-chat.de)

Once you get that to work, you can make an opto coupler out of that by
sticking the infrared LED part of the mouse, lens to lens, against the
photo transistor, with a drop of 5 minute epoxy.

drive the LED through a 470 ohm resistor from the 5 volt supply, and
you should be able to swing the photo transistor on and off via that
light source. Then paint the whole thing black, to keep out stray light.
 
R

Ralph Mowery

Sam said:
I just ordered some 4N28s. While I am waiting for them to arrive I thought I
would play around a bit.
I just cracked open a mouse and removed the photo transistors, but cant get
the circuit to work.

I have the center leg (base?) going to the input on my Stamp it is also
pulled up by a 10K resistor.
I have tried grounding both (not at the same time) other legs of the photo
transistor, straight to ground and also through various resistors.

I cant get the Stamp to detect on/off states. Any suggestions on where my
circuit went wrong?

Offhand I would say you leave the base open and connect the other two leads
to the Stamp. The collector (probably need a pullup resistor) goes to an
input and the emitter goes to the ground or common of the circuit.

The input to the base of a transistor is what normally turns it on. In the
case of a phototransistor the base is left open (in most cases) and its
input is the light (photons ?) .
 
S

Sam

This photo transistor does have 3 legs.
I will try your circuit tomorrow, so tired cant focus to even write this
post.

I will report back after trying it.

Thanks :)
 
S

Sam

Just a quick report back...

I think your circuit works, but the photo transistor is so sensitive that it
is picking up ambient light an triggering. I could not get a stable reading
even with the lights turned out and the circuit covered by foam, I don't
want to start gluing and painting until everything is stable.

Anyway, I am going to wait for the optocoupler in the sealed package and try
again in a few days.

Thanks again
 
J

John Popelish

Sam said:
Just a quick report back...

I think your circuit works, but the photo transistor is so sensitive that it
is picking up ambient light an triggering. I could not get a stable reading
even with the lights turned out and the circuit covered by foam, I don't
want to start gluing and painting until everything is stable.

Anyway, I am going to wait for the optocoupler in the sealed package and try
again in a few days.

Thanks again

You can also lower the sensitivity by using a lower value collector
resistor, like 4.7k or 2.2k. But I suspect you have something else
connected wrong. Were you testing the output with a meter or with the
Stamp?
 
R

Rich Grise

Thanks again.

It's not as easy as you would think to find small quantity electronic
components in NYC.

Not even with a NYC yellow pages?

Just curious.

Thanks,
Rich
 
E

ehsjr

Sam said:
Just a quick report back...

I think your circuit works, but the photo transistor is so sensitive that it
is picking up ambient light an triggering. I could not get a stable reading
even with the lights turned out and the circuit covered by foam, I don't
want to start gluing and painting until everything is stable.

Anyway, I am going to wait for the optocoupler in the sealed package and try
again in a few days.

Thanks again

The chances of one of John's circuits not working right are extremely
close to 0. Suspect bad part/wiring error/noisy supply/poltergeist/etc.
before thinking the circuit is wrong.

Ed
 

Similar threads

D
Replies
4
Views
3K
David O'Daniel
D
C
Replies
3
Views
1K
Crash Gordon®
C
A
Replies
19
Views
1K
Kevin Aylward
K
N
Replies
2
Views
906
Niels Damsgaard-Sørensen
N
Top