Newbee: Optocoupler to BasicStamp

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

Reply to
Sam
Loading thread data ...

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.

formatting link

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.

Reply to
John Popelish

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

Reply to
Sam

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:

formatting link

Reply to
John Popelish

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?

Reply to
John Popelish

Thanks again for your help.

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

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).

based

Reply to
Sam

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.

Reply to
John Popelish

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.

specs.

Reply to
Sam

to

state of

computer

use?

just

Reply to
Sam

Sad but true. Don't overlook

formatting link
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

>
Reply to
ehsjr

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.

specs.

Reply to
Sam

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
formatting link

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.

Reply to
John Popelish

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 :-)

thought I

get

photo

my

Reply to
Sam

MOC3010 is designed for switching AC power, use 4n28 instead.

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...

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

Reply to
Jasen Betts

I

get

photo

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 ?) .

Reply to
Ralph Mowery

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

thought I

get

photo

my

Reply to
Sam

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?

Reply to
John Popelish

Not even with a NYC yellow pages?

Just curious.

Thanks, Rich

Reply to
Rich Grise

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

Reply to
ehsjr

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.