LDR smaller than 5mm?

abenn

Senior Member
In an earlier thread I was looking for a way to monitor the on/off state of two separate pairs of LEDs using a completely independent circuit which will switch another set of LEDs when a particular two of the monitored ones are on.

My previous efforts have been frustrated by glitches that I'm not experienced enough to figure out -- first of all, all my monitored LEDs suffered a voltage/current overload when the monitoring circuits were connected to them, then today, after I'd replaced the damaged LEDs and added blocking diodes to the interface connections, other LEDs came on when they shouldn't.

So I'm thinking that my best approach is to avoid any electrical connection to the monitored LEDs: Someone in the earlier thread suggested opto-couplers in parallel with the monitored LEDs, to provide a signal for the monitoring circuits, but that would have drawn more current than the LEDs themselves, and potentially overload the 08M2s that are controlling them. What I'm now considering is perhaps using gluing LDRs to the rear of the monitored LEDs, but the size of the sensor ideally needs to be around 2mm diameter so it will fit between the "legs" of the LEDs (standard 2.54mm through-hole mounting).

All I can find with a Google search is several LDRs with a detector size about 5mm x 4mm. Can anyone point me in the direction of a budget-price light detecting device (doesn't have to be a resistor -- anything I can interface with an PICAXE will do) smaller than that, please?
 

AllyCat

Senior Member
Hi,

There are probably some SMD components, but for easy-to-use (through-hole) the best I can suggest is a phototransistor in a 3mm "LED" package, such as this from Rev Ed. It's described as Infra Red (where it does have peak sensitivity) but should be sensitive enough for most of the visible spectrum. It has only 2 wires (emitter and collector) because the photocurrent drives the base directly. Unlike a LDR it must be wired the correct way around, but the transistor gain should make it more sensitive than a similarly-sized LDR. You can usually file away the sides of a LED package if you want to make it a little narrower!

What I'm now considering is perhaps using gluing LDRs to the rear of the monitored LEDs,
Note that most LED packages are quite heavily "lensed" so you need to consider the "viewing angle" (spatial response) of both LED and sensor. I rather doubt if any significant light will come "out of the back" of a LED; the sensor and LED really need to face each other. You will need to look at the data sheets for the LED and phototransistor (or equivalent as Rev Ed don't appear to give a data sheet for theirs). LDRs generally do have a (less sharp) "Cosine Response", but this still means that their sensitivity drops away "off axis", falling to zero at 90 degrees and beyond.

Cheers, Alan.
 

premelec

Senior Member
There used to be very skinny phtotransistors to read holes in paper tape - may still exist. However what you describe seems like a hardware circuit problem... perhaps if you publish circuits tried and picture of LEDs to be detected we could be of more help.
 

abenn

Senior Member
Thanks for the info AllyCat. With that knowledge I've now found quite a few small phototransistors in the visible light range. To my eye there's quite a bit of light coming off the back of the LEDs, so I need to experiment to see if I can get a useful response.

premelec, you're probably right about there being a hardware problem. I'll draw up my circuits in the next couple of days and post them, to see if anyone can spot my issue, and suggest a more elegant solution.
 

Flenser

Senior Member
abenn,

LDRs are _very_ sensitive to light. I would be surprised if you could monitor a LED with an LDR during the daytime because the ambient light would cause the LDR resistance to vary so much that the effect of the LEDs light would be overwhelmed.

It would probably work if you sealed the LED and the LDR facing each in a paper tube facing each other so that all the ambient light was blocked out but as you describe wanting to monitor the LED it sounds like this might not be the sort of solution you are looking for.
 

abenn

Senior Member
Thank Flenser. The LEDs are in a panel, the back of which is sealed. So the backs of the LEDs, where I'm proposing to mount the detectors, will normally be in darkness. There may be an issue with stray light from the back of an adjacent LED, but I think I can manage that with suitable screening. I'll post a picture along with the circuit diagrams later -- probably no earlier than tomorrow.

It's becoming clear, though, that a purely electronic solution may probably be simpler! So wait until I can get the circuits drawn . . . . .
 

darb1972

Senior Member
Hello abenn

I'm also surprised that you are experiencing issues based on the circuit from your previous thread. Not sure how you can get any form of damage due to everything being current limited? As premelec suggested, maybe post your final circuit, and also maybe a photo of your setup?

Taking a large step backwards, are you trying to actually measure the light emitted from the LED or is it as I suspect that you simply need to know when the LED is being driven?

Breaking it down further, do you simply want to know when the LED is being driven via the 5V from the PICaxe or do you actually want to know more information such as if the LED has failed? (LEDs are very reliable these days).

If you only want to know if the LED is being driven, why not join each of the the driving (output) PICaxe pins to each of the input PICaxe pins via a resistor 1k resistor? You might also need a pulldown resistor (maybe 10k) on the input pin to ground. This would reduce the complication and issues surrounding the sensing of voltage levels and/or conversion to logic levels. Would that work for you?

For that matter, considering you know that each output is driving an LED (via code) do you actually need to sense the voltage level? Do you actually need two PICaxe chips? Could it all be done in the one chip and all via code???

Maybe more detail on extactly what you are trying to achieve will enable the forum to offer more detailed assistance.
 

erco

Senior Member
Connect the LEDs to a comparator (lm393 or 339) to sense high/low. High impedance, zero drain.
 

abenn

Senior Member
Thanks for your patience, and for all the suggestions. Voltage comparators (though I'm not exactly sure how they would be applied) and light pipes (but the cost!) both look promising, but I'm sure a large step back to basics is probably the best option.

So here's the full picture: The panel (pictured) holds the switches to change the directions of 27 sets of points on my model railway layout. The two LEDs adjacent to each switch (e.g. the pairs circled in the picture) are driven by the individual point-motor-controller circuits, which are located adjacent to their points up to 5 metres away from the panel, to indicate which way the points are set. This system has been working fine for over a year now, but to make things clearer for myself I want to illuminate a separate string of LEDs between the sets of points whenever both points are set in the appropriate direction. Hence the desire to detect the on/off state of the points LEDs. I could achieve it by using 2-pole switches instead of single-pole, but the points LEDs are off while the points are actually changing, and don't light up until the point-motor-controller has completed the change over, and I don't want the connecting LED string to illuminate until both the associated points LEDs have -- a sort of confirmation that action has happened, rather than just a reaction to a switch change.
 

Attachments

abenn

Senior Member
Here's the panel.

20170702_111053.jpg

The first circuit in my previous post is the point-motor-controller which has been working satisfactorily for over a year. There is one of these for each set of points.

The second circuit is what I was using to try and detect the on/off state of the points LEDs. There would be one of these for each pair of LEDs I wish to monitor (though I will probably condense it to fewer boards, using larger PICAXEs) mounted in the panel.

All the circuits are ultimately powered by a single 12v DC supply -- the point controller boards each have a 5v regulator on board, and the LED detector boards are fed by a single 5v regulator -- so have a common ground.

So, going back to basics, any ideas where I might be going wrong? Or suggestions for the most appropriate way to achieve my aim?
 

hippy

Technical Support
Staff member
As someone not familiar with model track circuitry; it's not clear what the servo and two relays control or how.

Are they two relay coils driven by high-side switching transistors, or are they actually relay contact switch inputs ?

Are you saying the LED illumination does not follow exactly the PICAXE output signal which drives the high-side transistors, leg 4 and leg 5 ?

It seems to me you are saying the the LED's are not on when the relay is powered until the points have switched or are on when the relays aren't powered. I may well be wrong because I cannot figure out its operation.

Also; where do the two In1 and In2 on your second (right hand) circuit come from on the other (left hand) ?

With blocking diodes one would normally also expect pull-downs on the PICAXE inputs or the inputs will be floating when the In1 and/or In2 were not powered or at 0V.

You should be able to connect another PICAXE to monitor the output on leg 4 and leg 5 and that should not cause any electrical or circuit damage. A simple 22K resistor should be enough to provide electrical safety.
 

abenn

Senior Member
The servo switches the points. There's one part of the points, called the "frog", where the two rails cross over, which has to have its polarity reversed when the points change, to avoid a short-circuit when a train passes over it. The two relays are solid-state devices which change the polarity, and two are needed to work together because the track power is AC. I haven't shown their output pins, which connect to the rails and the track power supply, and are opto-isolated from the rest of the circuit within the SSD1611 chips.

The program sequence when a switch is thrown on the panel is: 1. Switch off both LEDs and both relays, 2. Send the appropriate signal to the points servo to move it to the desired position, 3. Switch on the appropriate LED and relays contacts. The servo is programmed to move slowly, so there's maybe a 2-second delay before the LED comes on after a switch is thrown.

In1 and In2 in the second circuit (the "monitor circuit") are attached to the positive sides of the two LEDs in the first circuit (which are located remote from the circuit, in the switch panel). The ground of the monitor circuit is connected to the common -ve legs of the two LEDs. I'm wondering if this creates a problem, for those two LEDs are not connected directly to ground in the first circuit, due to the 10mA driver chip.

Ahh, floating inputs might explain one phenomenon I saw the other day. But pull-down resistors (10k or so?) on pins 5 and 6 in the monitor circuit would effectively be in parallel with the LEDs and the NS150010 LED driver. Perhaps not enough to cause an LED to glow faintly, but an issue?

As you say, monitoring legs 4 and 5 of the first circuit would be easy, but it would involve another pair of wires, up to 5m long, from the first circuit to the monitor circuit in the panel. That's why I'm trying to monitor the LEDs themselves. But maybe it's worth doing, rather than faffing around trying to fathom why what I'm doing is not working :)
 

techElder

Well-known member
I don't get it. You have indicators to remotely tell you that the switch has changed, but you want another indicator to tell you that the switch indicator is working?
 

abenn

Senior Member
I don't get it. You have indicators to remotely tell you that the switch has changed, but you want another indicator to tell you that the switch indicator is working?
No, not quite. Indicators on the panel tell me that the points ("switches" in US English?) have changed, but sometimes I miss the fact that the points are set in conflict with the route I'm trying to run the train on. So I've got strings of LEDs between each sets of points (they're off in the photo of the panel, but you can just see them if you look closely) which I want to switch on only if the two sets of points at either end of the section of track between them are both set the same way -- not to tell me that the point/switch indicators are working, but to clarify which route the train will take.
 

hippy

Technical Support
Staff member
I think I get it now. Activating the switch disconnects power to the track by de-energising the relays, then the points are moved with a servo, then, once that movement is completed, the appropriate relay is energised, re-powering the track. The LED's reflect which relay is set, which track is powered, rather than which way the points are set - though it's related.

I think the problem is in monitoring the positives of the LED's and particularly connecting the negatives of the LED's to the 0V of the monitoring PICAXE. Some other 'common 0V' connection probably shorted out or bypassed the 10mA LED driver leading to too much current through the LEDs and/or transistors causing them to burn out.

The best and appropriate solution is probably opto-isolators with their internal LED's paralleling the existing LED's if you need to take the feed from the LED's themselves.

It might work with a feed from the LED's positive, no connections to the LED negative, and just a connection to the controlling PICAXE's common 0V. Not sure how that 10mA LED driver will affect the voltage. It may not give a valid logic input voltage value.

First thing to do is to measure a voltage from a lit and unlit LED positive to 'common 0V'.
 
Last edited:

hippy

Technical Support
Staff member
@abenn: In your left hand diagram of the controller in post #10 I think you have "pin 4" and "pin 3" swapped over. You have "pin 4" which I presume is leg 4 (C.3) as an output when it is input only.
 

abenn

Senior Member
@abenn: In your left hand diagram of the controller in post #10 I think you have "pin 4" and "pin 3" swapped over. You have "pin 4" which I presume is leg 4 (C.3) as an output when it is input only.
Quite right, they should be the other way round -- they are in the actual circuits.

You've got the idea right about the operation. Sorry my words didn't make it easier to figure out!

I did measure voltages earlier, when I was having the problem with over-amped LEDs. But I measured across the LEDs themselves which, as you suggest, may be wrong because of the influence of the 10mA LED driver. Measuring against a true 0v ground my DVM shows 5.04v to 5.06v (the typical variation I see in the output from the nominal 5v LM323 voltage reducers feeding the circuits) when the LED is lit, and -0.4v or thereabouts when it's not lit.

So, it's sounding like connecting In1 and In2 in the monitoring circuit to the LED positives, and connecting the monitoring circuit's ground to the points-operating circuit's true 0v ground should give me a reliable differentiation between on and off. Presumably the blocking diode is still a good idea, but is a pull-down resistor necessary, given that I seem to be getting a slight -ve voltage when the LED is off?
 

hippy

Technical Support
Staff member
I would say forget the blocking diode and pull-down, any -0.4V should be safe via 22K. Connect one of the LED's positives via a 22K to your monitoring PICAXE input, connect it's 0V to the main 'common 0V'; check that tracks what the LED does.
 

abenn

Senior Member
hippy, it's just got through to me what you said in post #16 about effectively bypassing the 10mA LED driver when I connect to the LED's -ve and the 0v common ground. That explains why my LEDs were over-amped. Thank you, and sorry I took so long to get it! I'll connect as you suggest and I'm sure it will be fine.

Texasclodhopper, I can't use track power because it's 16v AC. Also, even if I did rectify it and bring it down to a suitable voltage, I'd rather not have any electric connection between my Lenz DCC train control system and my rather amateur electronics! Where I do have to have an interface, in switching the power to the frogs, there's an air-gap because of the opto-isolators within the SSD1611 digital relays.
 

abenn

Senior Member
Sorted!

I've already got 10k SMD resistors on In1 and In2 on my circuit boards, so today I've added a 10k or 12k (depending what was in my box) resistor in the +ve signal leads from the LEDs to the detector circuits, omitted the -ve connections from the LEDs to the detector circuits, and everything's working fine :D

Thank you to all those who helped talk me through this one.
 

hippy

Technical Support
Staff member
10K for In1 and In2 will likely be good enough. I only suggested 22K as it's 'big but not excessively big', the higher the value the greater the protection and less potential impact on the LED driver.

Glad to hear you have things working.
 

sages

Member
Use a camera to take pics of the panel and check if the relevant pixels are illuminated or not on a snapshot image.
Don't laugh, I've seen the technique in service for a large industrial organization to determine equipment status.
 

abenn

Senior Member
I'm not sure if we're on the same wavelength here sages. I've got no problem seeing the status of the LEDs which signify the position of the points: What I'm doing is lighting other LEDs to show the valid routes, for sometimes a single LED signifying an incorrect points setting will escape my notice. A string of LEDs between the points locations, if they're correctly set, will be more obvious.
 
Top