# Radioshack IR emitter/phototransistor



## s-4 (Jan 2, 2008)

Hi folks,


I'm interested in using some of these for my layout to control switches etc...  http://www.radioshack.com/product/index.jsp?productId=2049723&tab=summary


My problem:  Radioshack did not provide clear specs on the phototransistor.   
The rating for the emitter shows power consumption 2V 40ma.  
The phototransistor is rated 20V 25mA....is that its own consumption or its capacity as a switch?


I would like to control a small relay that draws 60mA at 12V.  
I was thinking about putting a resistor in series with the phototransistor to limit the current across it.  A second resistor would be used to bridge some of the current around both.  I would then use a 12V zenor diode in series between the transistor and the relay.  


Theory:
While the phototransistor is "off" the voltage would be below 12V.  In this condition, the zenor diode would not allow current to reach the relay.  Once the Phototransistor comes "on" the voltage would exceed 12V and would allow the relay to receive power.  


Too crazy to work?


----------



## Torby (Jan 2, 2008)

Slightly oversimplified.... 

IR Photodiodes are pulsed at high current to produce fairly bright flashes. I think this one is running like 150mA, but I'd have to dig for the real specs. You then watch for the flashes on the photo transistor. I used a tiny processor chip and a capacitor here. 










You probably could do this with a couple 555 timers. One pulses the LED and one you trigger with the photo transistor. 

Here's how I used the photo transistor: 










I think I used 10K for the resistors and .47uF for the cap. I connected the trigger signal to a comparator input. The idea of the capacitor is to filter out the ambient light and detect the flashes from the transistor. 

The photo diode is dark colored. There's a little transistor there to provide the high current pulses since the little chip is only good for like 20mA. 

A handy bit of info... You can barely see the IR from the diode, but your digital camera can see it clearly.


----------



## Torby (Jan 2, 2008)

When something passes in front of the circuit, the transistor sees the flashes reflected and the processor moves a servo and the boy peeks out of the outhouse. After he goes back in, he won't come out again for a few seconds. The trim pot adjusts the other side of the comparator for a sensitivity adjustment.


----------



## Les (Feb 11, 2008)

Torby,

Your reply re the circuitry was very interesting, as I want to do this sort of thing in many places on my layout. (When I get there, I'll ask.)

How did you interface the mechical movement with the electronics? A relay? A solenoid-type arrangement? Magnetic? I don't want any diagrams or anything complicated, just a one-sentence explanation of how you did it.

Thanks,
Les


----------



## Torby (Jan 2, 2008)

I used a servo.


You can find these starting at about $10. They run on 5v or so and a digital circuit can control the position with a pulse. They're good for a few oz of torque. They'll pinch a finger, but you can easily overpower them. Of course, there are $60 "Sail Winch" servos that will make you say, "Ow! Get it off me!" They're also easily modified into little motors with forward/reverse speed control. Inexpensive, durable (they were designed for model airplanes), strong. Fun for animations.











http://www.mylargescale.com/Communi...www.acroname.com/robotics/pa...SERVO.html</a>http://www.acroname.com/robotics/pa...SERVO.html


The little processor is an AVR 2313 and costs about $1.25 in quanties of 10 or more. Generating the servo pulse is trivial for it. It's getting to where I use these processors for about anything. In fact, given that I just spent a dollar buying 5 resistors for LED classification lights in my Mallet, a processor generating like a 60% duty cycle pulse would almost make sense. There are cheaper ones with fewer pins, or expensive ones with lots of stuff. I use a $30 programmer to load the program, and a free downloaded assembler and C++ compiler to write the programs.


----------



## dbodnar (Jan 2, 2008)

Les - you may want to look over the information on my web page that deals with sensors and animation.

Have a look here:

TrainElectronics.com Articles 


Please let me know if you have any questions

dave


----------



## Les (Feb 11, 2008)

Well, of all the things I thought of, a servo motor wouldn't be on the list. 

Aahhh.... I was with you until you got to the C++ & 'program' & gizmo to the computer... I don't know sh*t from applesauce about any of that. I don't know if I can even learn how. Sticking plugs into my computer causes a mild sweat to break out. 

The concept sounds first-rate. Will servos from the steering mech of R/C cars work? They're more or less 'all left' or 'all right'. They've got a number of wires, I think four, so they might be programmable? No wait, that's the D/A interface thingy that does that, right?

There's nothing wrong with the price of the servos. Can I buy the cards cheap, or do I have to wire 'em up? I can wire and read electronics schematics okay, but there's the ol' eyesight bit again. I can suffer thru that if it's a money-saver, howsumever.

Are you old enough to remember the "Vector Boards", the tan phenolic boards with rows of holes in them? There was a little terminal, a bifurcated thing, that you staked into the holes with a tool very much like a C press (or arbor press). Then you soldereded the parts to the terminals, and wires as needed. I did that for awhile. Do they still use those? I think most guys just stick the parts in the holes and bend wires as needed, but I'm curious if those terminals and dies are still around and how much they cost nowadays.

I'm gonna go to your site and look, all my questions might be explained there. Then I'm going to save the addr so I can come back later, because I'm not at that point yet.

Thanks for the explanation & link.

Les


----------



## Gary Lantz (Feb 20, 2008)

I tried your theory once for crossing gates. It did not work outdoors during sunlit hours but was OK at night. The dallee electronics web site has a lot of these circuit diagrams you can download or at least did at one time. If your inside you can purchase the controller all ready to use from MTH, Lionel and Z-Stuff. MTH is MTH451028, Lionel is LIO14111 and Z-Stuff is DZ1011. Dalle has some pre packaged units as well. As for using a servo the problem is to make the servo work proportionally you need to find a way to supply the third wire with data or use a manual servo driver such as JR Matchmaker (JRPA915) wich would kinda defeat the purpose. I used a tortoise machine for most applications. You can adjust the throw to whatever the application.


----------



## Torby (Jan 2, 2008)

Oh yes. The outhouse is designed for indoor use. Outdoors, I think I'd rely more on magnets or maybe ultrasonic transducers.


Nice to see you on the forum, Gary.


----------



## dbodnar (Jan 2, 2008)

Posted By Gary Lantz on 12 Aug 2009 10:08 PM 
I tried your theory once for crossing gates. It did not work outdoors during sunlit hours but was OK at night. The dallee electronics web site has a lot of these circuit diagrams you can download or at least did at one time. If your inside you can purchase the controller all ready to use from MTH, Lionel and Z-Stuff. MTH is MTH451028, Lionel is LIO14111 and Z-Stuff is DZ1011. Dalle has some pre packaged units as well. As for using a servo the problem is to make the servo work proportionally you need to find a way to supply the third wire with data or use a manual servo driver such as JR Matchmaker (JRPA915) wich would kinda defeat the purpose. I used a tortoise machine for most applications. You can adjust the throw to whatever the application. 
Gary - the pulsed IR sensors that are described here: Pulsed IR Sensors work rather well out-of-doors. The IR LED is pulsed at a frequency of 38 KHz and the IR detector is designed so that it only responds to IR at that frequency - the only thing you have to do is to position the detector so that it is not in direct sunlight. Placing it so that it faces north takes care of that issue. If that is not practical it can be placed in a black tube that puts it in shadow.


dave


----------



## Les (Feb 11, 2008)

Gary, Torby, & Dave:

Gary, welcome to the board.









I am wide open to any solution. I am indoors. I'd never heard of ultrasonics (ultrasound) being used. I can see where different frequencies might be necessary, or shielded to line-of-sight (and no reflections) might be necessary for 'sound.


----------



## Greg Elmassian (Jan 3, 2008)

Uhh... Les... Gary doesn't not post much on mls, but he owns Wholesale Trains... he is definitely not a newbie...









Regards, Greg


----------



## Les (Feb 11, 2008)

Gregg,

I knew that. Just wanted to see if you'd catch it.


----------



## Greg Elmassian (Jan 3, 2008)

Yep, I am awake, contrary to popular opinion! 

Ha ha ha! 

Greg


----------



## Torby (Jan 2, 2008)

There are emitters and detectors with the 38KHz circuitry built in. I'd have used them if I had one, but the one from RS isn't, so I had to pulse it myself.


----------



## Les (Feb 11, 2008)

Gregg,

I was mildly concerned my response didn't come off humorous, as I'd meant. I'm glad you found it so, that's how it was meant. I am always glad for a 'hedzup'.


----------



## Les (Feb 11, 2008)

Posted By Torby on 14 Aug 2009 06:12 AM 
There are emitters and detectors with the 38KHz circuitry built in. I'd have used them if I had one, but the one from RS isn't, so I had to pulse it myself. 
Torb: Is there a big price jump in IR emitter/detector sets that do have the pulsed circuitry built in? 

I went to Dave's site, only to find it roosting in my 'Favorites' file. What a boon to the hobby, having circuits like that available. I only scanned the site, being tired at that point, but I want to go back and look more closely.

Any way, thanks again for bringing this whole topic to the front of my mind again.

Les


----------



## dbodnar (Jan 2, 2008)

Les - The IR detectors that I use (and that are described in the article) are $1.28 each in single quantities from Digikey. I am not aware of any IR emitters that are sold with the 38 KHz pulsing circuitry included. I use a PICAXE or PIC processor to pulse them - not a big deal and I would be happy to program a 12F683 for you that puts out 38KHz pulses - those chips are less than $2.00 each so it adds little to the cost.

You can also use an old TV remote control as a pulse source - just tie one of the buttons down and you will get a continuous string of pulses. Most TV remotes use 38KHz - Sony ones for sure.

dave


----------



## Torby (Jan 2, 2008)

Careful. I use AVR not PIC. Dave and I tend to fight if left together too long


----------



## Les (Feb 11, 2008)

Dave,

Thanks for the kind offer. It'll be a bit before I'm that far, as I'm still trying to get tracks down. Before that, I find it handy to have some benchwork. After that, look out. I've been playing catch-up for more than two years and the other day I woke up feeling more fragile than usual and decided, 'Next week, I start, and the **** with everything else." I had the lumber for the benchwork last May, and now it's been used on other things.

I've sorta got a grip on basic electronics, wiring up and whatnot, and what I don't know in detail I can grasp in general terms well enough--save for these little micros. I remember when the 4-bit processor was the coolest thing. The intro of LED's. But someone with a site like yours is a God send. Circuitry aimed at the model RR'r. I just need simple little circuits that turns something on, waits a time, and turns it off. (Not including my pacemaker). (Kidding on that last). 

Les


----------



## Les (Feb 11, 2008)

Torby,

I've been told by a couple of different engineers that Picaxe is the most versatile chip out there. Not that I would know. Then they proceed to tell me many examples of which I care not a whit, because most of my apps require a solid-state spst switch.


----------



## Torby (Jan 2, 2008)

hehe









I just let the black smoke out of one of my $1.25 AVRs.










One of my classification lights on Mr. Mallet burned out, so I was going to replace both with LEDs. 'Stead of using a resistors, I thought I'd put one of these chips in and run them at about 60% duty cycle. I wrote my program. Just for grins, I had it ramp the brightness up on startup. I programmed my chip. Put a transistor and LED's, played with it on my desk...


"How cute!" I was feeling very proud of myself. I opened up Mr. Mallet. I see the bulbs (now both are out) wired to a little PC board with red and black wires. "Hmm, check the assumptions." So I stuck my meter in there. Yep. 5v. Red is +. Cool!


I put my LED's in, wired it all up. Turned it on. No leds? Hmm. Eek? Oh, I left the smoke unit on. Poking around with my meter, "How's come I have -1.5 v on the chip?" Oh THIS red wire goes to -. 


Now there's a resistor in there and my lights are on.


----------



## Semper Vaporo (Jan 2, 2008)

Posted By Les on 15 Aug 2009 03:19 PM 
Torby,

I've been told by a couple of different engineers that Picaxe is the most versatile chip out there. Not that I would know. Then they proceed to tell me many examples of which I care not a whit, because most of my apps require a solid-state spst switch.












I have been told the same thing and that it is inexpensive to make a circuit. BUT!

What are the "start up" costs?

Suppose you walk into the typical dungeon... errrrr... basement workshop, you know, various pliers and screwdrivers laying about and some power hand tools (drill, sabersaw, etc.) and some halfway clear bench space that could be swept clean of sawdust and metal swarf if needs be. There is also typical house power available to power whatever is needed to get started with this stuff.

What else do you have to have to build "a" circuit? I assume one needs a soldering iron and electrical solder if the circuit is to be permanant as opposed to just held together with clipleads or chewing gum.

I see these web sites that will give a parts list of what is needed to blink some LEDs and say it will be cheap ($30), but they always end with, "Of course, you will need the programming board ($90-$100) and a program cable ($35) and the software on your PC to compile the program which you can get free but the good ones you will have to pay for ($120 to $300) and a good editor (Notepad will work but you can buy better ones). Books are available that will tell you the commands the processor can execute... check Amazon or watch ebay for bargains."

Now that implies that one also needs a computer, which I can assume that since you are reading this, that both of us have one, but is the one I am using to access the web powerful enough to perform the task? What interface do I need on that computer? Serial (com) port? USB? Parallel (printer) port? PCMCIA? Something special? Can I do it on a laptop PC or does it require hardware that will only plug into a desktop PC?

I am not particularly interested in just blinking a half dozen LEDs in some random sequence, I want to animate some objects by detecting some analog or digital (on/off) signal and then produce a different analog or digital signal that due to a high current requirement ma cause that small chip to burst into flame if I connect them directly together. And I want to do all this in "real time", like controlling a large turntable to position it to specific roundhouse stalls, or controlling gradecrossing gates and lights upon detecting a train approaching/in/leaving it. 

All this will cost more than the "cheap" description belies, but I can find no lists of what is compatible with the basic circuitry to interface it with the "real world".


----------



## Les (Feb 11, 2008)

Posted By Semper Vaporo on 15 Aug 2009 04:41 PM 
Posted By Les on 15 Aug 2009 03:19 PM 
Torby,

I've been told by a couple of different engineers that Picaxe is the most versatile chip out there. Not that I would know. Then they proceed to tell me many examples of which I care not a whit, because most of my apps require a solid-state spst switch.












I have been told the same thing and that it is inexpensive to make a circuit. BUT!

What are the "start up" costs?

/// This is why I shy away from this stuff.

Suppose you walk into the typical dungeon... errrrr... basement workshop, you know, various pliers and screwdrivers laying about and some power hand tools (drill, sabersaw, etc.) and some halfway clear bench space that could be swept clean of sawdust and metal swarf if needs be. There is also typical house power available to power whatever is needed to get started with this stuff.

What else do you have to have to build "a" circuit? I assume one needs a soldering iron and electrical solder if the circuit is to be permanant as opposed to just held together with clipleads or chewing gum.

/// Got all that covered. Plus the experience to use it.

I see these web sites that will give a parts list of what is needed to blink some LEDs and say it will be cheap ($30), but they always end with, "Of course, you will need the programming board ($90-$100) and a program cable ($35) and the software on your PC to compile the program which you can get free but the good ones you will have to pay for ($120 to $300) and a good editor (Notepad will work but you can buy better ones). Books are available that will tell you the commands the processor can execute... check Amazon or watch ebay for bargains."

/// Now, this I didn't know, because I'll be dratted if I pay $30 bucks for 5 LED's 5 resistors and some kind of chip. But as soon as one gets past 555's, one needs to know much more about the 'rest of the story' as you've said.

Now that implies that one also needs a computer, which I can assume that since you are reading this, that both of us have one, but is the one I am using to access the web powerful enough to perform the task? What interface do I need on that computer? Serial (com) port? USB? Parallel (printer) port? PCMCIA? Something special? Can I do it on a laptop PC or does it require hardware that will only plug into a desktop PC?

/// Ouch! All those things make my head hurt and cause anxiety attacks. My computer is pretty poweful, and I think it'll do all those things, but those different ports put me off. The bottom line with me is, I don't want to learn C++ or ButtMunch XP to program. I have a semi-fossilized brain, and I sorta like it like that: fewer worrisome things can crowd out the important stuff, like, 'where did I put my coffee this time?'

I am not particularly interested in just blinking a half dozen LEDs in some random sequence,

/// I am. I have visions of 'lighting' the fireboxes on my locos-to-be. Flicker lights. I want running lights, and I am not at all ashamed to mount a 9V battery or whatever in the boiler for running lights, even though I have track power. Or will have.

I want to animate some objects by detecting some analog or digital (on/off) signal and then produce a different analog or digital signal that due to a high current requirement ma cause that small chip to burst into flame if I connect them directly together. And I want to do all this in "real time", like controlling a large turntable to position it to specific roundhouse stalls, or controlling gradecrossing gates and lights upon detecting a train approaching/in/leaving it.

/// Well, I'm close to that--my era doesn't support crossing gates--but I want eventually a cable lift for a mine, such stuff as that, so the motor controller (A/D converter) will have to be addressed when the time comes. 

All this will cost more than the "cheap" description belies, but I can find no lists of what is compatible with the basic circuitry to interface it with the "real world".

/// Neither can I, and I spent an entire year trying to decide if building my own R/C setup was the way to go. It isn't. I have to admit that what one pays for a fairly simple R/C setup is worth the cost, if frustration is to be avoided. The engineer from MAC, an old friend, now has some illness that makes him barely able to work, so I lost that source of information. Then there's the terminology problem: motor controllers--the high current circuits that are controlled in turn by other circuitry, all of which is called D/A (digital/analog) in the avionics industry and something else in the train R/C world. All of these circuits are out there (almost) but interfacing is a huge problem for a non-electronics person. It's because so many different possiblilities exist. I don't know why some bright spark doesn't offer a motor controller and a compatible D/A interface and a compatible input A/D circuit. Or sell the schematics for same. I have no objection to paying for information like that--provided it works as advertised.

My R/C of choice would be IR, because I'm inside, run one engine at a time, slowly, and don't need MU and 100 different channels for 50 different engines. Bell ringing, chuff, etc, all of which can be cut out when annoying would be good, too. That gets more complicated for an amateur.

I'm sure that I am not going to buy any programming boards, books, or cables. I just don't want it that badly.


----------



## Torby (Jan 2, 2008)

One reason I settled on AVR. The programmer was only $25 (30 now) and the assembler and compiler are free downloads. Of course, the "JTAG" programmer is nicer at $99, but the little "ISP" one does great. Some used to build them to plug into the parallel port, but most just get the little ISP programmer. Mine is an old one and I wonder how long it will be before the free downloaded program no longer supports it.


Of course, you can blink leds with a 555 with no programmer and no downloads







In fact, with a little cleverness, you can do all sorts of things with a 555, including letting the smoke out.


So, since I like playing with electronics and programs and gadgets, these AVR's are cool and cheap. They also have some expensive ones that are very impressive computers. This $1.25 chip is bigger and faster than the computer I learned programming on.


----------



## Semper Vaporo (Jan 2, 2008)

Hey Les... go to the "Party goods" aisle in Wally*World and look for the little girl's "Tiara". It is in a celophane bag and comes in three pieces that you have to snap together to make the semicircular tiara. The front of it has some plastic "jewels" and has 5 LEDS behind them and a small pokerchip sized circuit board that holds the LEDS out in a star pattern to put them behind the "jewels". There is one or two of the button cells in the thing and a small pushbutton on the back that will turn it on/off. Throw away most of the cheap plastic parts but keep the little circuit card and LEDs. (Maybe the jewels if you want to "salt a mine" someplace.)

I bent the LEDS in toward the center of the device so that they aim at each other and are closer together so that as they flicker in sequence the circular flashing is not os apparent. Buried deep in a firebox or under a pile of "logs" where the LEDs are not themselves visible the reflected flashing is a fairly good simulation of a flickering fire. 

Contrarary to the printed instructions on the package, the batteries are replaceable, with a VERY small screwdriver, if needed, but they will last for a long time if used infrequently... and since the whole thing was only about $1.00 to begin with it would be cheaper to just buy a new one when the batteries run down.

The biggest problem is attaching something to replace the on/off switch (it is one of those momentary types where one press switches the circuitry on and the second contact switches it off... it is not a complete power circuit break type of thing) or to mount the thing such that the switch is where it can be reached to turn it on and off.


Torby: Is letting the smoke out of that chip a kind of one time only "Smoke Unit"... ya gits one chuff per chip?


----------



## Les (Feb 11, 2008)

Semper,

Yeah, I remember you telling about that tiara maybe a year ago. I believe I'll go down to our Wally World and see what's available. I'm not overly fussy about anything that costs a buck and works.


----------



## Torby (Jan 2, 2008)

Imagine a VERY short lived smoke unit. Of course, guys are always asking how to get black smoke.


The most exciting explosion I ever did was years ago working at Honeywell. A guy in another plant called describing a problem with a piece of equipment we'd built for him. Sounded like an op-amp wasn't working. So I stopped by the lab, got a block of foam and a couple of these little 8 pin packs, hopped on the shuttle and went across town.


Sure enough, it was an opamp. I pulled it out of the socket, put one that I'd brought in, put the board back on the extender. The guy came it to see what was up just as I was ready to turn the machine back on. I hit the switch and the thing shot sparks 3ft! He went away shaking his head. (He had been against us building this machine from the start.)


I looked at my little block and instead of 741 44v opamps, I'd grabbed 1536 5v buffers. Fortunately I knew a guy who might have a 741, and bummed one. When I got back to the lab, I rearranged the parts drawers so the 741s and the 1536s were no longer in the same 2 bin parts drawer.


(We're talking 25 cent parts here, even in 1981.)


----------



## sheepdog (Jan 2, 2008)

In 30 years of Manufacturing Engineering and Industrial Automation, I never had any luck with any kind of photo sensor and sunlight.

Built a vision inspection system for Dana Axle. Because of the cameras, we enclosed the inspection area with doors that you could tilt up to work on the station. It was over a conveyor and we had to stop the used photo sensors to locate and stop the trays. The system was enclosed so we had no issues with the sensors...... Did I mention this assembly area had a clerestory roof?


Every spring and every fall, I would get a call that the system was not working. By the time I would get there, it would be working again. And since it was working, I could not figure it out. We stored the inspection images on the PC and uploaded them once a day to Dana's network. I was looking through them when I noticed a shaft of bright sunshine on the conveyor. Yup, maintenance had left a door in the up position. Every spring and fall, the morning the low sun would start triggering the sensor.


They never learned... Got the call twice a year. I would tell them to shut the damn door. Should I have charged them a service call?


My rule of thumb, if sunlight is involved, don't use a photo sensor.

Craig


----------



## astrayelmgod (Jan 2, 2008)

"My problem: Radioshack did not provide clear specs on the phototransistor. 
The rating for the emitter shows power consumption 2V 40ma. 
The phototransistor is rated 20V 25mA....is that its own consumption or its capacity as a switch? 

I would like to control a small relay that draws 60mA at 12V. 
I was thinking about putting a resistor in series with the phototransistor to limit the current across it. A second resistor would be used to bridge some of the current around both. I would then use a 12V zenor diode in series between the transistor and the relay. " 

Don't take this personally, but I get the impression that electronics isn't your best subject. If that is the case, then I don't think any of the suggestions are going to work for you. Not because they don't work, but because the explanations assume a high level of expertise. 

Fiirst, the current rating of a transistor refer to the load, not to its own consumption. The voltage rating refers to the transistor itself. 

Second, without getting too technical, transistors that drive relays need voltage ratings that are several times the voltage on the relay unless you use specialized circuits that you haven't mentioned. I would suggest at least 30V, and 40 would be even better. The phototransistor drives the bigger one.


----------

