Optocoupler in model rail block occupancy detector

Discussion in 'General Electronics Chat' started by ChrisPSR, Sep 20, 2012.

  1. ChrisPSR

    Thread Starter New Member

    Sep 20, 2012
    16
    0
    Hi, this is my first post so please forgive any misguided statements or questions. Thanks.

    Model rail as the real thing works on the track being split into sections always referred to as blocks. For many reasons it is handy to know electronically when stock is detected within a block. The most ideal to me seems to be in the use of an optocoupler, I am using 4N35's.

    I have built a circuit which I believe should work however the "opto" will only work when subjected to an unresisted Vcc 0f +13.84v DC.
    [​IMG]I sincerely hope that this circuit image shows; else: I'll add another listing all values. Or here is the Circuit link:
    http://s1108.beta.photobucket.com/u...g.html?&_suid=1348141711830048175529124140503
    I need it to work when the circuit is carrying virtually 0v through to it's 15v controlled maximum.

    Can any body offer advice to someone chewing their finger nails please?

    Thanks for reading me,
    Cheers,
    Chris
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Hello Chris,
    Welcome to the All About Circuits Forums.
    Your circuit:
    [​IMG]

    You're using the rectifier bridge in an attempt to get a voltage drop across it that's higher than the typical Vf of the IR emitter in the optocoupler. The IR emitter's typical Vf is 1.2v @ 10mA, but it could be as high as 1.5v.
    Your bridge rectifier will have ~1.1v to ~ 2.2v across it, depending upon the current flow in the block. You'll also reduce your maximum block voltage by whatever is dropped across the bridge rectifier, which will reduce your top speed/max tractive power of your engines. Also, your scheme depends upon current flowing through ANY piece of rolling stock, not just engines - and it will need to be at least 5mA. If you were only using passenger cars, that might not be a problem if the cars have lighting; however I don't see many freight cars with lighting.

    It seems like you need more like an optointerrupter; but it would basically need a straight diagonal view across the track. Corners could be messy.
     
  3. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    It looks to me as if this design is only workable with Digital Command Control, where there's voltage on the track all the time. With plain DC operation, it will obviously fail when the train isn't moving and the voltage on the track is zero. What good would that ever be?

    Consensus seems to be that DCC occupancy detectors should use current transformers:
    http://home.cogeco.ca/~rpaisley4/DccBODvt5.html
     
  4. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,993
    745
  5. ChrisPSR

    Thread Starter New Member

    Sep 20, 2012
    16
    0
    Many thanks to all including SgtWookie; JohnP & DodgyDave for the response.

    So: My principal desire is to get the circuit to work; at the moment my results = Zilch. Once I have got the box of tricks to run I will then go on to experiment with a trickle charge through the same recog., circuit in order to provide a consistent current for DC., recognition (any clues or adventures would be gratefully received). But first I have to get this one going. at the moment anything greater than a setting of 30 on my Gaugemaster 100 series controller provides a dead short.

    By the way SgtWookie just what is an optointerrupter please and do you have a makers ref., No. Or am I being just too naive?

    DodgyDave: I've downloade and printed your circuits, many thanks. Now I will digest and think on them.

    Cheers

    So gents what's wrong with my circuit which positively will not work
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    Hello Chris. First I have a huge number of questions for you. I do circuit design, and happen to have once modeled rail myself (HO traction, powered off the overhead). So I've actually thought of some of this before. And as a circuit designer I've learned well the lesson "specify first, design last." So let's figure out what you need to do, then make something do that.

    Now let's talk about a block. It's two pieces of rail, and at least one rail is isolated from all other rails to define the block. This raises these questions:

    Is it always powered as in a command control system, or is it a traditional system where the "power pack" is switched to the blocks it is powering?

    You say you wish to detect "stock" in a block. So these are cars and not locomotives? What are the wheels like, meaning do the wheels of a car insulate one rail from the other rail or do they conduct (somehow, as mine never did)?

    One brain cell keeps asking me "what about a car in between two blocks?" but unless it can short one block to the other it should just look like both blocks are occupied (and they really are, right?)

    Finally, what is this "device" the detector is driving? Lamp, LED, relay, computer input?

    And welcome to the forums!
     
  7. ChrisPSR

    Thread Starter New Member

    Sep 20, 2012
    16
    0
    Dear ErnieM,

    Thank you for your ideas; I think that the best thing I can do is reiterate below your questions and then for recognition sake, answer them in a different colour, so here goes with your origination in the colour; black:(I know that in the US you would use "an LDR", but I am English so to those in the US, please forgive my spellings and grammar if necessary).

    ErnieM asked:
    Now let's talk about a block. It's two pieces of rail, and at least one rail is isolated from all other rails to define the block. This raises these questions: The block can be any length but identification within that block shall mean the whole and not a spot position as would be accomplished with say a LDR of which I have in use. I will not use a carriage number greater than three for track size reasons and goods wagons therefore shall be no greater than say 180' in length.

    Is it always powered as in a command control system, or is it a traditional system where the "power pack" is switched to the blocks it is powering?
    I am attempting to construct all circuits to run as DC., & DCC., but at the moment the track is DC., and set on a board 9' x 5' in size. Therefore the circuits are to be at first designed to run as DC. This I would call a traditional system with blocks and desired road powered and isolated when nrcessary. The LDR., sensing being used for actually locating, stopping, controlling direction and isolating with the block recognition holding fast through the isolation period of the LDR, and informing the ghost contoller curcuit just where the loco is at this time.

    You say you wish to detect "stock" in a block. So these are cars and not locomotives? What are the wheels like, meaning do the wheels of a car insulate one rail from the other rail or do they conduct (somehow, as mine never did)? Although not currently resisted I am aiming to change a wheel pair or two (all following experimentation) per carriage with a steel axle shorted to the tyre by way of a resistor; the attachment method at this time is not fixed in stone.

    One brain cell keeps asking me "what about a car in between two blocks?" but unless it can short one block to the other it should just look like both blocks are occupied (and they really are, right?). This is something my mind has been toying with, but I am as yet really undecided which is why I have not shorted carriage axles as yet. may be the all important engine in section is going to be most useful on a small circuit. So for the moment lets agree that the engine is in fact the dominant piece of stock in order to simplify the business in hand.

    Finally, what is this "device" the detector is driving? Lamp, LED, relay, computer input? It could be anything but if we decide upon a relay then it's pretty much an easy operation to reduce the current for any other object that is in need, we should be able to adjust the IC., output from low to high and vice-verse. (Shouldn't we?) The probabilities in my mind are aspect lighting, semaphore boards, points and Isolation's.

    Gosh Earnie I sincerely hope that I haven't Given you too many headaches.

    Dodgy Dave:
    Ive looked at the link provided and find it fascinating: I am not seeming to identify a vendor here in England for that particular transformer and I am not totally understanding whether this VT-5 transformer is very special or not; so is there similar modern item that could be substituted; can you indicate the simple median performance figures of the transformer? Very many thanks for your input to date.

    Yours sincerely,
    Chris
    ChrisPSR
     
  8. Dyslexicbloke

    Active Member

    Sep 4, 2010
    420
    19
    If you sense current, whatever method you use, then unless you have voltage applied and something on the track that is providing a current path you will not get a block occupied indication.

    Might I suggest some concepts that will help.
    1. always supply some voltage, preferably a current limited AC supply that is not sufficient to move anything but will provide enough current to sense.

    2. utilise 2 op amps to sense the voltage drop a pair of Schottky diodes, one for each direction.

    3. add surface mount resistors between the axle and wheel of none motive stock, bridging the insulation ring, this will allow you to sense all stock.

    If I had a bigger house I would have model trains and will be happy to help you develop something if you would like me to.
    There are much clever people on this site than I but what you are trying to do isn't that difficult.

    Al
     
  9. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    I know of one club that implemented an automatic system to switch power from DC throttles to the track. It ended up fairly complicated; there was a trickle feed of current into each block for sensing, and each block also had a diode which allowed current from the throttle, but prevented current flow from one block to another even if both were connected to the same throttle. Reversing was done via a relay for each block, not by reversing the throttle voltage. For a complete system, I think you have to do all these things. Alternatively, you can implement a "one throttle per block" system. Or go to DCC; it's much easier.
     
  10. ChrisPSR

    Thread Starter New Member

    Sep 20, 2012
    16
    0
    Hi many thanks for y our reply.

    My circuit (such that it is) is published on this page but it doesn't work. It merely shorts out the speed controller (throttle) and nowt works.

    Can you be of any help. Your suggestions to date are exactly the way I want to go but first I have to take the first step in this scheme and get it working and then I can proceed into tripping up again.

    Cheers,
    Chris
     
  11. ChrisPSR

    Thread Starter New Member

    Sep 20, 2012
    16
    0
    Hi John,

    Can you get hold of a working drawing? That wouild be great.

    CHEERS,
    Chris.
     
  12. Dyslexicbloke

    Active Member

    Sep 4, 2010
    420
    19
    Yes sure I will be glad to help if I can.

    Firstly we need to collect some info.
    What kind of power supply, throttle, are you running?

    What equipment do you have, can you measure, resistance, voltage and current for example?

    Do you want to work with your existing throttle or build a new PWM one.
    I ask because using PWM would allow you to have a very short pulse when the throttle was closed as opposed to no current at all.
    This could be arranged so that you have plenty of current to measure your block occupation but a pulse so short that the motors would not run because the average power would be negligible.

    There are several options and picking the best one for you will depend on your specific requirements.

    Al
     
    Last edited: Sep 21, 2012
  13. ChrisPSR

    Thread Starter New Member

    Sep 20, 2012
    16
    0
    Chris[/QUOTE]
    Dyslexicbloke,

    Thanks once more for the offer of help and I feel quite certain that your pseudonym does not reflect your prowess. Today I have rebuilt the circuit on my project board but I ran out of time in which to test it.
    However if the problems a small as you say maybe I ought to listen and build something that you guys are telling me I should have. But what are op amps and how might they help? My adventure with IC's is new and I find it difficult to understand manufacturers data language. My arithmetic is uni., standard but this side of calculus.
    My kit is made up of three meters 1) an AVO., analogue 2) a BEHA multi ranger and 3) a UNI-T UT58 both modern digital Multimeter's. I have a soldering Iron, solder, gas and electricity, plenty of tools including a miniature anvil vice.
    I have always been handy with my hands; ask the wife.
    Power supply if a Gaugemaster 100 series with variable DC., which as I understand it is a PWM., complete with 5 pin remote hand held device output, this is used as controlling current (throttle) and has a separate 16vAC., output for incidentals.
    Hope I've supplied enough information for your dissertation.
    Cheers,
    Chris
     
    Last edited: Sep 21, 2012
  14. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    I see a few things with the detector circuit you show from Mr Spreckley.

    First off, I would assume it is intended to work with a motor in the block as it would "steal" about 1.4V from the motor's running voltage. That is what the bridge rectifier is doing: it just puts two diode drops in series with the motor.

    The 22 ohm resistor is there to limit the current driving the 4N35. 100 ohm resistor is there to let any excess current still pass thru.

    He has one mistake in how the 4N35 connects to the 555, I correct that below.

    Another problem is the 4N35 does not have two LEDs in the drive side, it only has one, so this circuit can only detect on one polarity, not both. A second 4N35 could be added to get that function: connect C and E the same way, but swap the diode side leads.

    So this should get this to work for you with a motor in the block, but it leaves open the question of detecting a wagon.

    [​IMG]
     
  15. Dyslexicbloke

    Active Member

    Sep 4, 2010
    420
    19
    OK that seems like a workable list of kit. A small scope would have been nice but I expect you will be able to manage.

    When you start playing with electronics it is a good idea to look at some basic principles.
    This site has some very good tutorials, right at the top of the page.
    The semiconductors section for example will explain about op amps.

    An op amp is an differential amplifier circuit on a single chip that needs very few external components to be useful.
    There are lots of different types that are good at different tasks but in this case you want to sense a small voltage and generate an output if it is prescent.
    For that you want something with a big input impedance, so the current is very low, and a huge gain. Fortunately there many opamps designed to work from a single supply and operate without feedback working as comparators.

    http://www.onsemi.com/pub_link/Collateral/LM393-D.PDF

    These are readily available, easy to use and will sense voltages of only a few mV making detecting a few mA very easy.

    How much current will the circuit need to handle when the loco is under load?
    How little current can you get your throttle to deliver and is this low enough to prevent the loco from moving?
     
  16. Dyslexicbloke

    Active Member

    Sep 4, 2010
    420
    19
    I did you a quick circuit, the values would have to be altered for a specific amp / comparator (I just used a generic one to try it out.)

    Current is fed to the track via a sense resistor, 0.1 Ohms in my sim but I suspect you would need circa 0.5 Ohms in practice.

    The two shotkey diodes limit the voltage drop to 0.5 volts whatever the current.

    Depending on the polarity of the supply one of the two comparators will be on when even a small current is flowing and if either is on then the LED will light up.

    Attached are circuit in 3 conditions.
    Block unoccupied > no current - no light
    Block occupied > high fwd motor current - indicator on
    Block occupied > low rev current - indicator on (resistor on axle)

    You could further mod the circuit to be supplied from the throttle and also the aux output of the controller.
    It could then supply a limited current when the throttle is off so that block sensing works when nothing is moving and when the throttle is on the motive power would do the same job.

    This is a simple mod requiring some diodes and a current source which is easily constructed from a voltage regulator and a resistor.
     
  17. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    OK, I sketched it out. It's really part of an automatic system, where the switching matrix and reverse relays don't need to be controlled by the user. It should be clear that all the components between the switching matrix and the rails are repeated on a "per block" basis.

    One issue with a setup like this is that you have to deal with any blocks controlled by the same throttle all being shorted together, which would prevent them from being sensed individually. The diode in series with the power takes care of that problem, and also prevents current from flowing out of the sense network back to the throttle, if it's capable of sinking current. Note that the sense network has to be powered by a voltage higher than the throttle can ever produce. I've drawn it with a plain resistor setting the current, but a constant-current circuit would probably be better there, and would be very easy to build--just one extra resistor I believe.

    http://files.myopera.com/John98wbr/albums/661338/blockocc.jpg
     
  18. ChrisPSR

    Thread Starter New Member

    Sep 20, 2012
    16
    0
    Dyslexicbloke,
    Thank you very much for the circuit drawings they look very interesting and comparatively simple. I shall try it just as soon as the waking hours arrive here.
    One thing though where is the connection going to to the LH., side of the sense adjust, is it to earth?
    I have LM337 & LM334 voltage regulators on hand but I have not used them to date. They were purchased to drive a rechargeable battery when incorporated as back up to engine/loco, front and back constant lighting running DC., but I haven't been able to figure out the circuitry for the polarity change brought about by the controller (throttle) in the charging circuit, perhaps I could use your method (?). Could I use LM339 comparators in place of those used in your drawing as I have them to hand and if so would I need to make any adjustment to resistance?
    Chris
     
  19. ChrisPSR

    Thread Starter New Member

    Sep 20, 2012
    16
    0
    JohnP

    Many thanks for your input. In general I see where your coming from and it all looks very simple. I'm not too sure just where the PNP emitter(?) leg and the resistors to the left are coming from, is it earth? Do I take it that the lines shown to the right and above the controller are track?, and that the track at the top from which the polarity is determined is that same track?
    Cheers,
    Chris
     
  20. ChrisPSR

    Thread Starter New Member

    Sep 20, 2012
    16
    0
    Dear Ernie M,

    Many thanks for your eMail. I think the error is in my drawing as I am perfectly aware that over here at least we are taught to place positive voltage at the top of the drawing and negative at the bottom and I think my working circuit is in fact correctly built at that juncture but I will check it tomorrow during the day and let you know the outcome.
    Cheers,
    Chris
     
Loading...