DCC++ Hardware - Block Detection

HVT Jan 27, 2016

  1. Kim Olsen

    Kim Olsen TrainBoard Member

    34
    33
    6
    I think it's because of the forward voltage, on the mbs6 (made a typo before) it's way up at about 0.9V while on the 1n4148 it's a mere 0.55 if I recall correctly, suggesting that the internal resistance of the mbs6 is much higher, thereby killing the already weak signal. I haven't tested with other bridge rectifiers, as they were the only ones I had lying around. But if you could get your hands on some fast switching rectifier bridges, I'm sure they would do better, though probably not cheaper
     
    Scott Eric Catalano and TwinDad like this.
  2. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    OK, I built up my own copy of Kim Olsen's block detector circuit... After a bit of futzing around and fixing problems, I think I have it faithfully reproduced... 100:1 coil with 2 turns of bus wire through it, N scale locomotive as the test vehicle.

    1N4148 diodes for the bridge, 2n3904 transistor, a 10K trim pot for the emitter resistor, connected to my Arduino Mega.

    I'm not getting a good reliable signal... I wrote a simple sketch that would reflect the detector state in the onboard LED, and would post a message to the serial port each time the input changed. I'm seeing a string of messages which seems to imply that the voltage is hovering around the input's transition point. As I vary the emitter resistance, the voltage at the output is varying from abut 0.5 to about 1.25V with the loco on, and 0.6-1.35V with the track empty.

    I don't have a scope handy, though I can get access to one next week... meanwhile I only have a DMM for debug...

    Suggestions?
     
    Scott Eric Catalano likes this.
  3. Kim Olsen

    Kim Olsen TrainBoard Member

    34
    33
    6
    Hmm well it is not going to give a clear 5v to 0v bipolar signal, but the voltage difference you describe, is too small. On my devices it goes from about 4.3v to 1.4 which is well within the high, low parameters. Have you turned on the pull up resistors on the arduino pins? And what are the specs on the current sense coil?

    Kim
     
    Scott Eric Catalano likes this.
  4. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Yes, (I should have specified) the pullup is enabled on the Arduino.

    The coil is a Pulse PE-51687 100:10 coil I bought from rr-cirkits.com ... 100:1 ratio, 20mH inductance, 1.4ohm secondary resistance. It is connected to the circuit via an approximately 10' length of twisted pair I stripped out of a Cat-5 ethernet cable. There are two turns of the primary wire (e.g. it's wrapped once all the way around, so the wire passes through the core twice). If it matters, I have another one installed with only one turn (passes straight through, no wrapping) that I can test.

    Here it is, in context:
    [​IMG]CT coil by Mark, on Flickr
     
    Scott Eric Catalano likes this.
  5. Kim Olsen

    Kim Olsen TrainBoard Member

    34
    33
    6
    Hmm I think there might be a couple of causes to your troubles, the coil could work, but it might need a very different configuration than the one
    I used, the pe-51719 have 200 turns an value of 80mH, so perhaps you need even more resistance on r3? Secondly I soldered the coil directly to the circuitboard, I don't know if the short length of wire will have an capacitive effect. And finally; the coils I use are so sensitive that even a wire in close proximity to it, will influence them.
     
    Scott Eric Catalano and TwinDad like this.
  6. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Well, testing higher resistance on R3 is easy enough to test... I can replace the wire from the pot to ground with a 10K resistor, so I would be adjusting 10K-20K. I'd hate to have to replace all of my coils... I've already wired them in place and hot-glued them to the benchwork (as you can see). I expect the wire is having some effect, but it is rather necessary unless I make a bunch of very small boards with the circuit on it and use long wires to connect to the Arduino(s).

    Looks like CAT5 cable is about 52pF per meter, and my wire length is about 3m, for a total of 156pF, though those numbers are for the cable, not for individual pairs removed from the cable, so it might only be good as an order-of-magnitude estimate.

    I should understand this better than I do, but what is the "operating theory" of this circuit? Is the coil multiplying the voltage through the primary wire, eventually getting above the ~1.2V threshold of the diodes and allowing a small current to flow into the base of the transistor? And then R3 is setting the voltage at the emitter relative to ground, effectively adjusting the "trip point"? I'm not quite sure I understand why the "no load" output voltage isn't zero... unless the coil is picking up noise from adjacent wires...
     
    Scott Eric Catalano likes this.
  7. Kim Olsen

    Kim Olsen TrainBoard Member

    34
    33
    6
    The theory of the circuit is as follows:
    Current track=15v/10kohm=1.5mA
    Voltage coil = 15v*200=3000v
    Current coil = 1.5mA/200=7.5uA
    Ok so 3000V sounds like a lot, but because the current is so miniscule, the internal resistance of the diodes brings the level down to not even being able to open the transistor fully.
    Transistor = grounded emitter, collector to 5v i/o pin, meaning when the circuit is inactive, you should measure close to 5v collector-emitter, and as the transistor opens it brings the collector closer to ground, thereby lowering the voltage and triggering the arduino.
    As for the cable capacitance, I think that figure is for each pair, so it is applicable to this situation. As the signal from coil to diodes is ac the capacity acts as a resistance, Xc=1/2pi*f*C=1/2pi*8k*156p=127.53ohm
    As the current from the coil (the signal) is so small this resistance might be enough to kill it.
    I hope this helps. I have some time later today, so I will post some images of my setup.

    Kim
     
    Scott Eric Catalano and sboyer2 like this.
  8. Kim Olsen

    Kim Olsen TrainBoard Member

    34
    33
    6
    As promised, here are some photos of the devices installed: DSC_1178.JPG DSC_1175.JPG
    Have you had any luck yet, getting them to work twindad?
     
    Scott Eric Catalano and sboyer2 like this.
  9. Pepijn

    Pepijn TrainBoard Member

    18
    23
    4
    I've also build a copy of Kim's Block detector on a breadboard. I've tested it with loose bit of track with Small H0 cab, but it doesn't seem to work. The output voltage of the bridge rectifier is .3 when idle and .5 with the cab on. I have very limited knowledge of electronics, but I think this is not enough to activate the transistor. Perhaps the coil doesn't have enough windings? It doesn't say how much it has unfortunately.
     
    Scott Eric Catalano likes this.
  10. Kim Olsen

    Kim Olsen TrainBoard Member

    34
    33
    6
    I
    0.5v is actually pretty close, the 2n3904 starts opening at 0.55v. You could try to make one more winding with the track wire, an
    and make sure it is wound very tight!
     
    Scott Eric Catalano likes this.
  11. Pepijn

    Pepijn TrainBoard Member

    18
    23
    4
    I was very close then. I think the voltage was actually 0.53 :)
    I should mention it had several windings already (4 or so I think), but I'll try one more and and I'll tighten it a bit, as it was quite loose.
    Thanks!

    It got me thinking, would it make sense to connect the bridge rectifier straight to an analogue port and sample the output voltage there?
    It would need a bit more programming and wouldn't be a straightforward on/off sensor for DCC++ though.
     
    Scott Eric Catalano likes this.
  12. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    Watching you guys beating your heads against a proverbial electronic wall, I can't help but bring up my post & project on TrainBoard.....

    http://www.trainboard.com/highball/index.php?threads/different-way-to-do-detection.91951/

    Lots of positive input, everyone loves the idea (and it actually works, not a wish and hope for a functional system), but you're STILL playing with analog detection and playing with adjustments to sensivity.

    All this says to me that when you adjust for one layout and environment, it will probably need to re-adjust for every other layout/environment.

    My Arduino solution can be implemented for about $10/block, and supplies a low-active digital signal when a block is occupied.

    TRY IT. YOU'LL LIKE IT!!!!
     
    Scott Eric Catalano likes this.
  13. Pepijn

    Pepijn TrainBoard Member

    18
    23
    4
    Turned out the coil I was using was too big. I ordered some new ones and they work flawlessly. I can detect my smallest cab even when it's idle on the track.
    Thanks Kim!

    Now using these coils btw. And I've got some even cheaper ones on the way to try out as well. This way I can get the cost down to between 1-1.5 dollar/euro per sensor.
     
  14. Kim Olsen

    Kim Olsen TrainBoard Member

    34
    33
    6
    That is great to hear!
     
    Scott Eric Catalano likes this.
  15. Pepijn

    Pepijn TrainBoard Member

    18
    23
    4
    I couple of weeks ago I designed a PCB for Kim's circuit and had three boards made at OSH Park. I thought I'd share it with you.

    Attached is photo of the front and back, and one of the assembled kit. I tried to make it as small as possible. The result is 1.28x0.69 inch (32.54x17.55 mm). The cost for 3 boards was $4.40 incl. delivery from the US to The Netherlands. This kind of doubles the price of one sensor, but it was more for the fun/challenge of it, as I have never done this kind of thing before. I think they look kind of pretty though, and it really eases the construction.

    Although they work perfectly there are some minor issues. It only allows for one really tiny screw, making it difficult to screw to the underside of your layout. I also misjudged/miscalculated the spacing of the pins on the coil by a mm or so, which means they don't go all the way in. The transistor is also a bit short on space, although it does fit. Room enough for improvement, so I'll be designing an improved version and share the resulting files here when its finished.
     

    Attached Files:

  16. Kim Olsen

    Kim Olsen TrainBoard Member

    34
    33
    6
    Those boards looks really nice Pepijn! Great work! I have used OSH Park before, when building some accessory decoders, it's a great service and very reasonably priced. It might make each sensor more expensive, but it might be justified by the ease/speed of assembly
     
    Scott Eric Catalano and Pepijn like this.
  17. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    As I happen to have a surplus of Hall-effect sensors (A3144), I was wondering if they would work for train detection if I put magnets under the loco and last car?

    ~Travis
     
    Scott Eric Catalano likes this.
  18. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Hall sensors should work well - they are a bit more touchy to install with the proper orientation vs reed switches and they need three wires where reeds only need 2.

    That said, they can be more sensitive than reed switches and they don't break when you aren't careful bending their leads!

    dave
     
  19. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    thank you, I have just ordered some magnets to go with them. 1/16 inch thick neodymium. and they are axial polarity, so they should work well with the hall sensors, providing I lay the sensor on it's back.

    Things are coming together now, as I just received the test/development track I ordered, so I can fine tune everything, and actually drive my loco on some track. :)

    ~Travis
     
    Scott Eric Catalano likes this.
  20. 67vettefan

    67vettefan New Member

    4
    5
    1
    Hey guys, following crusaders lead, I've got something rigged up that avoids current detection for block occupation. I got some IR avoidance sensors from www.banggood.com (part #951031) - about $0.65 each. I'm mounting them under table and drilling a 5/8" hole through the roadbed and plywood and mount this right under the track. The receiver is just small enough to where code 80 track doesn't interfere with the sensor. When a train or cars passes over, it triggers the sensor and that's as simple as it gets. I've set these up with an Arduino and JMRI and it works just fine.

    While it's not as sophisticated as crusaders solution, as it doesn't tell you direction or count cars it provides enough to do some signaling, and is real cheap / simple. I haven't gotten as far as putting this on my 'production' layout, and since the sensor only triggers when a car is directly above it I figure I'll have to wire up several of these per block (roughly the length of the shortest train I plan to run) so the block stays lit while occupied. I also plan to have one at the junction of each block that will light up both adjacent blocks. Some photos below...

    IMG_1492.JPG IMG_1493.JPG IMG_1494.JPG IMG_1495.JPG IMG_1496.JPG
     
    Davey H and Scott Eric Catalano like this.

Share This Page