Stan, tried your approach and it works perfectly. Using a 5.1K resistor I get relay activation and very good sensor sensitivity.

As to a sensor approach on the TT. We currently have 9 different locations for the TT. We are using a stepper motor/Arduino for position control. The stepper controller provides selectable steps/rev (up to 6400) plus the stepper to TT is gear driven for further resolution. We use a limit switch for initial positioning and the spur/engine house track fixed locations are in a table generated with a calibration program. There are currently only 2 main line entry/exit points and I am just trying to add a safety feature to prevent an engine from going into the pit if I have not positioned the TT. The TT is very complex and adding even a single emitter would be a mess.

I think I will use a 2nd relay to disable the sensor function and will activate it from the control panel, where I only have 12VDC available (5V is provided from a regulator under the layout near the slip ring and is fed off a 12V bus. My relays are all 5V, so can I just add a larger resistor (like 12K) from 12V to the relay control input?

Ken

 

As I understand it, you want a control panel bypass/over-ride switch that prevents any of the relay modules from triggering.  But you only have 12V DC at the control panel.

Assuming the 5V and 12V DC share a common Ground, you could do something like this which does not require an additional relay.

kens trains IR 1

That's good thinking to extrapolate using a 12K (instead of 5K) resistor since you have 12V instead of 5V DC.  12K is kind of an unusual value for the weekend-DIY'er so you might find 10K, 15K, 20K work equally well.

So if the control panel switch is "open", then 12V DC is not supplied to any of the relay modules (only 3 shown above using the miracle of cut-and-paste).  So none of the relay modules can trigger whether their respective beams are broken or not.

Attachments

Images (1)

Stan that's a great suggestion, but one problem. As I said the TT is complex. Under the table is a set of electronics/relays to activate sound--(currently also trying to learn how to use DFPlayer module to replace that stuff). Power (~5.4VDC) to that audio setup and to the TT (via the slip ring) is supplied from a voltage regulator that receives 12VDC. I could add a 2nd voltage regulator to supply 5V to the detection/override functions. I guess it's a matter of what is most convenient and effective. Also, it doesn't seem reasonable to keep those components always powered even if not being used--so maybe that's best approach.

By the way I did keep increasing resistance values and am using 15K.

By the way, if I haven't been too much of a pest, I would really like to know why current level (if that's what is the controlling agent) through an IR sensor affects its' sensitivity (or at least that's what I observed). Maybe I need to check some spec.s.

Thanks again for all of the help & suggestions.

Ken

"~5.4vdc"?

"~5.4vAC?" " -5.4vdc?" or "....5.4vdc"

 I'm not up to speed on readingreadi thisthis thread, so the exact context is unknown to me;  but ~ is a symbol for AC; so "~5.4vdc" 

It stood out like a sore thumb to me in the paragraph.

(and not elaberating moremore bec of spellwreck).

ken's trains posted:

... I could add a 2nd voltage regulator to supply 5V to the detection/override functions. I guess it's a matter of what is most convenient and effective. Also, it doesn't seem reasonable to keep those components always powered even if not being used-- 

Many options.  My observation was you shouldn't need a 2nd relay.  That is, the control panel toggle switch could either (1) block triggers to the relay modules, or (2) as you suggest simply cut power to the IR relay modules themselves.  

If using method 2), DC-to-DC voltage regulator modules (to convert 12V DC to 5V DC) are about $1 on eBay with free shipping from Asia.

ken's trains posted:

...By the way I did keep increasing resistance values and am using 15K.

By the way, if I haven't been too much of a pest, I would really like to know why current level (if that's what is the controlling agent) through an IR sensor affects its' sensitivity (or at least that's what I observed).

If I understand your question, the IR sensor is not binary "on" or "off" like a toggle switch.  Instead, the electrical resistance between the 2 terminals varies depending on the amount of IR energy hitting it.  More IR energy lowers the effective resistance.  In your application the IR sensor (photo-transistor so actually a semiconductor) is effectively behaving as a garden variety photo-resistor where the resistance between the 2 terminals decreases as light increases.

photoresistor

Apparently you were having a sensitivity issue so that's why I suggested you increase the trigger resistor value from 1K to 5K or whatever.  Increasing the resistor value decreases the amount of current available to trigger the relay.  In your application, the IR sensor shunts or diverts the trigger current.  Increasing the resistor value means less current needs to be diverted to keep the relay off when the IR beam is present.  Thus this increases sensitivity since less IR energy is needed.

Attachments

Images (1)
Last edited by stan2004

Stan, thank you for the explanation.

As to sensor (safety) control, it turns out that going thru my many purchases from ebay, I bought a number of rotary switches (I have 2 ZW Transformers and used them to switch tracks & throttles). One of the switches is a 4-pole/5 pos. switch and is perfect for the job. I am not only turning safety functions on/off, I am also selecting a specific track section, illuminating a lamp on the selected track section, and changing ZW throttles based on where the engine is coming from/going to.

And Adriatic, I used the (~) symbol to indicate approximate. I need to fiddle with the regulator output to make sure I have enough 'juice' to drive the servos on the TT without overdriving the optics.

 

Hi all. Well had a little health issues, but back to work.

At this time, the Turntable is done. It is fully functional and ready to demo. However, we have also been working on a drawbridge and the control logic is still in work. When that is done, we will back a video of both in operation and post on youtube (since it will be a long-and too large-video). At that time I will post a link.

In the mean time to use my existing parts, I need some help (probably from Stan). I am using the optical sensor approach to stop trains from running off the table if the bridge is not down. However, the 2-channel relays I have require a LOW to trigger. The circuit I used (Stan's design) incorporated a transistor to provide the additional drive to trigger the 1-channel relays I was using. They required a HIGH to trigger. What I need is a simple inverter or circuit change to get a LOW trigger when the beam is broken. I have enclosed a schematic of the circuit I use with the 1-channel, HIGH trigger relays.

IR Circuit001

Attachments

Images (1)

Hi Ken, why not make it simple and power the bridge and when its down it completes the circuit and when its up it kills the power to all approaching track?

Mike I cannot seem to do anything simple. I have 2 outside lines that run around my 26 x 14 room. I have a large inside section that is industrial. I have a narrow walkway between outside & inside. Also, the outside lines cross by 2 doorways for other rooms (cannot block), so that portion of outside lines is moved toward inside. Bridge is to connect outside lines. When up, I can walk through. So, 2 lines must be joined to cross single lane bridge(can't make 2 lane--too heavy). I wish to automate whole process of handling 2 trains waiting to cross bridge without using manual controls.

IR%2520Circuit001

Another option to "invert" the logic is to use the COM-NC relay contacts instead of COM-NO relay contacts.  This may or may not apply to your application.  For example, one school of thought with fail-safe type circuits is to ask what happens if the fail-safe circuit itself "fails"; for example what happens if the 5V power supply drops out?  The relay would then connect COM-NC so one would argue this should be the relay position that disconnects power to the trains … i.e., dead-man switch.

Attachments

Images (1)
Last edited by stan2004

Stan, so happy you are still here. I may not need the circuit you provided for this application because I think the logic is complex enough that I will be using an Arduino for control. My 2-channel relays can be operated with the Arduino. But your suggestion about using the proper relay contacts makes perfect sense. When beam is detected, relay will be triggered and contacts will be closed. Broken beam or power loss and relay default state is contacts open.

Only question; is it ok to keep relay energized for lengthy period??

What he said.

Of course with any scheme that involves a continuously active relay, the relay coil is consuming power.  The relays used in the eBay modules consume about 1/3 Watt... or about 70 mA at 5V. 

Note that if you end up using an Arduino or similar microcontroller to drive the relay module, you can use a PWM-able (if that's a word?!) digital output to drop the effective voltage.  That is, while you turn on the relay with 5V, once on it will remain closed with only ~2V.  This is a commonly used technique to reduce power...not that you're constrained by power.

Thank you both for the input. And Stan by the way I have used the PWM output to dim LEDs and it's a great suggestion. One more question. If I did not use an Arduino, I would need a circuit to generate a LOW when the beam is detected (for the dead-man-sw approach). The 2 circuits I have produce a H or L when the beam is broken. I found that when using the circuit that triggers with a HIGH and connected to the relay that triggers with a LOW it does not trigger when the beam is detected. So I would need a circuit that toggles H and L.

Stan, again can't thank you enough. You understood what I wanted, I tried it (w/o the Arduino) and it worked just great. I will use this circuit in places where I don't have the additional complexity requiring an Arduino.

Ken

It never seems to end. I am lost again. I used the circuit with the transistor that produces a high when the beam is broken. I use that output as an input to an arduino. I wrote a simple program that tests the state of the beam (HIGH is broken) and sends a HIGH or LOW (when the beam is unbroken) to the relay trigger. The relay is triggered by a LOW (and I have tested that the arduino will cycle the relay by just outputting H's & L's). My operational code is very simple, but when I run it and the beam is unbroken, the relay just chatters. When I break the beam, the relay opens and stays. My program design keeps the trigger output LOW if the input DOES NOT = HIGH (!=). I have tried many different approaches, but I believe the problem is that the output when the beam is unbroken is floating and causing random H & L. If that is the cause, is there a design solution that will give me a solid GRD output when the beam is unbroken and a solid HIGH (~5v) when beam is broken?

If you want to keep the input low when the transistor is off, I think you should tie the input to ground with a 10k resistor to stop the input from floating.  (a pulldown resistor).

 

 

 

If driving an Arduino digital input pin, you need a resistor to define or pull up (to 5V or hi level) the "floating" node when the beam is broken.  The eBay relay modules effectively have such a resistor on its input trigger pins.

LO%20trigger%20when%20beam%20detected

Presumably somewhere in your Arduino sketch you define the digital pin connected to the IR sensor to be an input.  If using pin number X, look for something like:

pinMode (x, INPUT)

Instead, try:

pinMode (x, INPUT_PULLUP)

and, lo and behold, you get: 

pullup

Since your transistor-based circuit is already hooked up, just change the pinMode instruction and you should be off to the races. 

Attachments

Images (2)
Last edited by stan2004

Thanks all of you for your help. However, my circuit board has been made like the schematic above for "HI trigger when beam broken". Therefore, I tried Stan's suggestion, but probably didn't make the correct change to the circuit and it did not produce a LOW to operate the relay when beam detected. I tried Stan's simpler approach (w/o transistor) and worked fine. I can remove (unsolder) all the extra parts and go simple, but would like to know what to do to make existing circuit work--and I did change the input as you suggested on the Arduino. That was all I did to the above 'HI trigger' circuit.

This question may verify my ignorance but may help me understand why the circuit isn't behaving as I thought it should. When the beam is detected, does the transistor turn ON--that is what I may have incorrectly assumed? Been a very, very long time since I took a course--back when they were 1st coming into use.

Don't want to be lazy so looked up NPN operation. If I understand, when beam is detected, most current flows to GRD through sensor. Therefore, transistor is off and emitter would be floating. So maybe a resistor from E to GRD would solve problem?

Please forgive me, don't mean to turn forum into electronics course, but if I get better understanding, I can stop bothering you all and show you Turntable and Drawbridge results.

Last edited by ken's trains
ken's trains posted:

Don't want to be lazy so looked up NPN operation. If I understand, when beam is detected, most current flows to GRD through sensor. Therefore, transistor is off and emitter would be floating. So maybe a resistor from E to GRD would solve problem?

Correct.  When beam is detected, NPN is off, emitter is "floating" so a resistor from E to GRD would solve the problem  In this case you should use the regular pinMode (x, INPUT) instead of INPUT_PULLUP.  Someone correct me if I'm wrong, but there is no Arduino that supports pinMode (x, INPUT_PULLDOWN).

HI when beam broken

I realize the NPN circuit is all wired up, but couldn't you just run a jumper wire as shown in purple above?  It's OK to leave the NPN as-is with the E disconnected.

 

Attachments

Images (1)
Last edited by stan2004

Stan, I need to add a little more to your above simple circuit (the circuit where 'HI when beam broken and no transistor'). Since one of my uses will be to assure that the train has cleared my isolated track section, and since the detector output is an arduino input, I don't want a momentary beam detection to open the relay under control (like between cars--and I know I could place detectors on diagonal but complexity is more fun). So I would like to put an adjustable delay in "beam detection". So when beam is broken, output's at approx. 5V, and then is detected, it slowly falls to it's lowest value. I would then use AC inputs on arduino to define input levels for relay trigger/no trigger (range is 0-255). And yes I could do sw debounce, but this should be easier--except for me.

Stan, I did a more playing. Used your above 'top' circuit with the transistor and also stuff you provided from earlier IR detection circuits. I put a diode between the (2) 10K resistors and a 4.7 uf cap from the diode output to ground. This kinda worked, in that when beam is made, trigger output (only connected to meter--won't trigger relay) very slowly (20-30 sec.) drops close to zero. When broken, fairly quickly rises to almost 5V. That's a pretty small cap and a very long decay time. How best to adjust to something like 2-3 sec. to decay to close to zero? The relay not triggering not an issue since that output will be an arduino input--again using the AC input pins.

ken's trains posted:

.. So I would like to put an adjustable delay in "beam detection". So when beam is broken, output's at approx. 5V, and then is detected, it slowly falls to it's lowest value. 

HI%2520when%2520beam%2520broken

Add a capacitor across the 10K resistor at the output.  When the beam is broken the output quickly rises to approx. 5V.  When beam is detected the output will slowly fall to its lowest value.  The voltage decay will be exponential rather than straight-linear.  But in round-numbers, it will take about 3 x R x C.  For example, if R=10K and C=100uF, it will drop to near 0 in about 3 x 10K x 100uF = 3 seconds.  If you only have, say, 10uF then use R=100K and you'll get about the same decay (3 x 100K x 10uF = 3 seconds).

The output quickly rises because the NPN transistor turns ON when the beam is broken.  The transistor rapidly charges up the new capacitor.  When the beam is detected, the IR sensor turns ON which turns OFF the transistor.  With the transistor turned OFF, the capacitor discharges thru the resistor in parallel with it.  You might get slightly different timing on a voltmeter bench test vs. with the Arduino actually connected because the Arduino pin itself is a load that discharges the capacitor.  OTOH you may not see any practical difference for the matter at hand.

 

Attachments

Images (1)
Last edited by stan2004

I will give it a try this afternoon, and as always, thank you so much. And by the way, stay safe. It's great to have this hobby during these crazy times.

Also to all of you fellow members, please take care, stay safe and thanks for all of your help and indulgence in my problems over the years.

Ken

Yes Leo you are correct. That's the problem with composing msg.s late at night.

I tried Stan's circuit using just the digital pin (for input), and there is no delay on the decay as observed on the arduino output to the relay. When I measure just w-meter at the trigger output of the circuit , the decay to almost zero takes several sec--which is what I want. I guess maybe the digital pins toggle on transition? So now I will use my meter measurements & analog pin to toggle on levels and see how that works.

Add Reply

Post
OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
330-757-3020

www.ogaugerr.com
×
×
×
×
Link copied to your clipboard.
×
×