DCC Block Occupancy Detection in JMRI for £3 per sensor!!! 😮
HTML-код
- Опубликовано: 5 сен 2024
- Possibly the cheapest way to add block occupancy detection to your DCC layout and integrate it with JMRI, it could save you hundreds!
You may want to watch my first two videos on building the Arduino sensor hub and adding sensors first as this builds on those.
Model Railway Sensors & Detection Part 1 - • Model Railway Sensors ...
Model Railway Sensors & Detection Part 2 - • Model Railway Sensors ...
I experimented a lot to find a cheap and reliable way of detecting locos and resistor wheel sets on stretches of track and I think this is possibly the best soluition if you don't mind a bit of soldering. It works out at around £3 for each sensor after paying to join MERG.
The final block detection kit was designed and supplied by MERG (www.merg.org.uk), amazing community of very helpful people.
Credit to the N Scaler blog (www.thenscaler.com) for providing inspiration and motivation to keep exploring current sensors.
Great video. I've built all my controls recently with MERG kits and have been planning on retro fitting block detection....just because I can.
It's the retrofitting I'm still not sure I'm going to do. Still a bit nervous about chopping through all my rails. Might save it for Little Wicket II.
Let me know how you get on.
Hi Rob, just watched your video as at some stage i want to go with block detection and also DCC District cutout and been think about the MERG 8 channel which is only £24.42 and the cutout boards are £10.38, so as my layout develops I will definitely go with these ... sorted the LDR's and LM393 and that works fine ... You and Charlie at CMR have great videos ...
Thanks John. I'll be using the new version of the MERG 8 channel for my next layout. Also, £10.38 is a bargain for the district cut outs, when I first started I paid £28.50 for an NCE EB-1 Electronic Breaker.
Another really informative video Rob,
Thanks Andrew 👍
thank you
Love your channel - I discovered this video by chance after looking at your SCAM warning. I suppose it was only time that some scammers realized that there is money to be made by cheating model railway enthusiasts.
Your block detection videos are very motivating, I think I'll be joining MERG pronto.
Cheers for now, Angus.
Hi Rob, I love the videos you make. They helped me a lot in getting my old Fleischman n scale sets to work again and making more and more parts computer programmable.
I was watching this video on block detection and wondered wether you had looked at the ina219 adafruit board before or after this video. Would love to get your thoughts on it, as it seems a digital current sensor suitable for block detection and pretty small size wise. Keep it up! Greetings, Ruud
Or maybe even the INA3221 module that seems to be able to check 3 blocks on one module up to 26V current with 0.8mA accuracy.
Found the answer to this. The INA219 is a digital sensor but works over I2C, limiting the number of blocks that can be detected, I would guess. As the PCB itself only has 2 addresss patches to come to max 4 INA219 per SCL/SDA pin.
Hi Ruud! I haven't heard of the ina219, but I've just had a Google. My two concerns with this board would be 1) can it sense small currents and 2) it says it's DC, but a DCC signal is like a square AC signal. I did quite a bit of messing about with current sensors before this video and couldn't find anything that would detect low currents on a DCC layout reliably. This website (thenscaler.com/?p=514) basically documents all the issues I was having.
@@LittleWicketRailway I have done a test on my analog layout and it was able to detect small currency differences. Really small ones. Like 0.0x Amps. About the same time I realised that they use I²C for communication and thus ended my research, thinking that I²C devices are not easily added to the sensor-servo hun sketch. Or are they..... I will first check the dcc compatibility though.
Rob talks about building a circuit to log in and out of a block as complicated, which it is NOT!!!
I can do it with 2 chips and under $7, and that cost includes the IR sensors for a block as long as you want.
Hi Rob, great video to show the setup for the block detection using the sensor hub with Arduino and th interaction with JMRI. I have set up the 2 channel detector and wired up the first one which works, the second channel is also working, in your video you show the connections form the MERG detecor board, which are the +ve teminal, ground and two signal terminals for blocks 1 and 2. did you split the +ve and ground leads onto the sensor hub?
Regards
COlin
I have just plugged the 2nd detector straight into the sensor hub on its own and it worked!
Hi Rob, your channel is so inspiring. With regards to block occupancy, I'd like to ask you how it is done with double line running into a station. For example, all points ( turnouts ) will be counted as a single block?
I really appreciate your money saving tips, especially MERG! I recently joined MERG because of them, in spite of being in the US. In looking at their occupancy detection options, I see both the DTC8 (current sensor based) @ about 2.45 per block and the even cheaper PMK7 (diode drop based) at 1.41 per block. I'm wondering why you chose the DTC8 over the PMK7? Is it reliability? I want to be sure I follow a wise path. Thank again!
Thanks
Thanks Roger, really generous and very much appreciated! 😀
Hi! I have been loving all your videos and especially these to do with dcc++. Are you able to do a new version of this block detection video with a little bit more in depth ideally around the wiring up as I’m struggling getting mine working and your the only one who makes it simple enough to get right. Thank you
same here
How would this work if you have a train with a rake of coaches that have pickups for coach lighting. The train would be shown as occupying both sections as the loco would be detected by the second section, and the current draw from all the coaches still tripping the first section (as would a train with a rake of wagons all fitted with resistor). Before all these computerised system, the same principle was used, but a small 30mm isolated section was used at the start of a "section" which was locked to the previous section. This way when the current was drawn through the small isolated section it cleared the previous section indicator /signal. Granted this was before the days of DCC, and was uni-directional... but worked well on my father-in-laws OO garden layout back in the '80 :)
MERG are a fantastic organisation and well worth the £21 annual membership
In general you wouldn't want the section to show as being clear if it still had coaches or wagons travelling through it. The block would eventually clear when the full train had exited. Should something odd happen like some wagons become detached then your block wouldn't clear and by looking at JMRI you'd see there was a problem.
Also, depending on the size of your train and the length of the blocks it could be possible to occupy a few blocks simultaneously. I've heard that some people like to make each set of points a separate block, so in that case you're likely to have three blocks (section before point, the point and the section after the point) active all at once.
If you did want it to show as clear immediately then you can program your own logic in JMRI. You could override the sensor and put in something like "if block 2 is occupied then set block 1 to unoccupied".
I'd love a 00 garden layout! Although I struggle to keep the track clean indoors.
@@LittleWicketRailway Having the ability inthe software to program logic so that no two adjacent blocks can be shown occupied would make things a lot simpler. I often wonder what my late father-in-law would make of all this technology if it were around 40 years ago !
great information brother, thank you
Very good. Thanks
What is your opinion regarding Gikfun AC current transformer? Does JMRI detect it without need to change the sketch?
Nice video - but as for the MERG detectors being cheap at £3/block, have you looked at the Digikeijs DR4088 family of detectors? They give you 16 detectors for just over £3/block, and they're well-made units too.
Thanks John. I wasn't aware of these and I like the idea of avoiding soldering. Is the output only compatible with Digikeijs products or can they be used with other systems do you know?
@@LittleWicketRailway there is certainly a loconet version for digitrax and an S88N version, but I don't know which systems that talks to. There are a couple of other options too, but I've not looked at those, sorry.
Thanks for this. I like many others I guess am just starting out. I'm wanting to model my local railway in OO and scratching around to find some info on DCC and block detection. Do you use any power distribution circuits to provide the supply to the blocks?
Hi,
Thanks for sharing this video. Very informative.
I'm considering to go for these current detectors. However, I'm not using JMRI. Instead I'm using Arduino Uno digital inputs, that then connect with a Märklin CS2 via the S888 bus.
Can you please elaborate a bit more on what is the output of these boards? Is it a digital signal, like a NO contact, or a voltage signal, and can we adjust the sensitivity of the current detection?
Thanks.
Best regards,
Antonio
Hi! Could you set the current detector for block/track section detection and still setup the InfraRed sensors to stop locos at specific places?
For example I’d like to have current detection across all different isolated sections. But at specific “interest” points (station,water tower, etc) I’d like the option to choice that sensor to trigger a train automation to stop.
Thanks :) and Great work, really enjoying it!
Definitely. A combination of both types of sensors is ideal. The block occupancy current sensors will confirm is a train is in the block, but the position sensors (IR, hall effect, photo, etc.) can then be used for things like stopping a train in the correct place. If you're going to use JMRI then you can sensors to blocks in this way with a train in section/block sensor and stopping sensors at either end.
Fantastic to hear! Even more functionality!
Thank you.
This approach means you measure if and how much current is consumed from this block. It means you have to cut the rail into blocks just for this ability. It also means you detect only objects that consume power. You don't really detect objects. So if a wagon without resistors will be left on trails,, it will not be detected. Also, you consume more power than really needed. I think this is not a good solution.
you wont regret joining Merg built a few kits and working on the ezybus which i might use on a N scale layout, I know nothing about electronics (learning) but i am enjoying the vids. Quick ? you use a power supply for each block, on the OO gauge I'm building i use droppers on each piece of track so would i still need power supplies or will just the 1 do..
Hi Alex! I'm loving MERG so far. However, I built Little Wicket before I found the MERG kits, so the blocks aren't actually isolated on the layout at the moment, I do block detection using IR sensors.
It'll depend on the size of your layout and how you want the power divided up and, disclaimer, I'm not really an expert on the subject, probably best to jump on a forum and ask the pros.
I'm planning a new layout and I'll be putting droppers on every section of track. The droppers will all come off a supply to the block which passes through the current sensor. That then connects to the main DCC bus. I'm going to split it into power districts so that if I have a short in one area, the whole layout doesn't go down and it'll spead the load between the power supplies.
@@LittleWicketRailway 12'×8' shed end to end L oo gauge with one circular track so locos can have a leg stretch, thanks for the reply &info rob will read the forum and see what I can find
With the complete success of installing the Arduino / servo turnouts / JMRI project I have decided to work on block detection and signals next. I currently have 23 servo / turnouts running perfectly off an Arduino Uno because of your excellent help. I do have a question, can you run the servo / turnout, block detection and signals together off one Arduino Mega or would I need separate Arduinos for each system?
Congratulations! Sounds like it's all working really well. A few people have asked this and I'm stil ashamed to say that I don't have a definitive answer for this. My gut feel is yes, I think it should be possible to combine servos and detection off a single board. I'm sure I read a blog where someone had combined the servo control and sensors stuff.
Currently I run things off separate boards because I keep them in different locations and if anything goes wrong then I know which bit of kit I need to look at. However, when Little Wicket gets a rebuild I'm going to try and cut down on wiring by using wireless modules that could be placed around the layout to do servo control and detection in their immediate area. So combining code is something that I'll need to look at in the next couple of months, I've got a bit of time off between now and new year so I might get round to it sooner, but the list of projects is piling up.
@@LittleWicketRailway I'd be interested to know whether you found a solution to this over the last couple years as you progressed with the rebuild
Great videos Rob - Thank you. Did you do one on using a ESP8266 wireless shield & mobile phone?
Hi Arthur! I didn't, but I did have a brief play with an ESP32 the other day and manage to connect to my wifi network. More to explore here as I want to use them on my new layout for sensor and servos to reduce wiring.
Hi Rob. Just built one of these current sensor hubs. It's not clear how you wire the 4 pin DIL socket to the sensor shield. It has 4 wires:-
0v (gnd Brown - thats OK), +V (5v Red - that's OK) and then pins marked 1 & 2. I presume that pins marked 1 & 2 yellow goes to 2 different sets of pins on the shield, but you only need one set of brown and red to the shield. Is that correct? Thanks for some great videos
That's right. You only need 1 set of GND and +5V for the sensor and then each output from the sensor goes to a signal pin on the sensor hub/Arduino.
Rob,
Will the MERG detectors work on an analogue system with reversible current? I'm using PWM from an Arduino (with a motor shield) to power my locos in either direction. I was a member of MERG about 40 years ago.
EDIT:- I've just realised that they won't work when there's no current applied to the track!
I was going to say, I don't think those will work with DC, but I'm sure MERG will have something that will.
Would wrapping the wire around the current transformer a couple more times make it more sensitive?
I believe more turns will make them more sensitive and MERG recommends experimenting to achieve the right level of sensitivity. You are a bit limited by the size of the hole and the thickness of the wire though. I think you'd struggle to get more than four times round.
Block detection versus point detection.
Both ideally. Generally I find block detection is more useful unless you need to stop in a specific position.
Hi, where could I buy this blocks detection without being a member of Merg?
You would have to be a MERG member to buy MERG kits. I should say that they don't really encourage people to join MERG just to access the kits, they would like you to become part of the community. They do offer a lot more than just the kits.
I made this video quite some time ago when there wasn't really a cost effect Block Occupancy Current Sensor on the market. The situation has changed slightly and there are cheaper solutions. The decision you'll need to make is which communication protocol you want to use. CMRI, LocoNet, XpressNet, etc. That will probably dictate which sensor systems are available to you.
@@LittleWicketRailway I use DCC command ex + JMRI software. Do you know if I could use Digitrax Block occupancy with it? Maybe if I become a Merg member to buy hardware and send it to the USA it’s better go for Digitrax option in USA. I would like your opinion. Thanks.
Here's a video of my experimentation - ruclips.net/video/BviPcd8-Vt0/видео.html using full MERG for the input as well.
Hi Rob
Is this still available from MERG?
Rob, what’s going on with the connections from the Molex header on the 2 channel sensor to the sensor shield? I saw that you have peeled off one of the conductors from another 3 conductor ribbon cable. Can you show more specifically how you completed the connection from the sensor to the sensor shield? TIA, Ryan
Ah, never mind, I see what you’ve done
Glad you sorted it 👍
Hi Ryan (CC Rob) I've tried to do the same but can't quite catch it. I am guessing that the sensor is being powered 5V from the sensor board. Is that correct?
Hi @@56NeilWatson correct, the sensors are getting 5V from the from sensor board which has its own 5V power supply.
On the block sensors there are only 4 pins because the two sensors share the 5V and GND connections, then the other two pins are for the respective outputs. So when you connect it up to the sensor hub rather than using 2 x (GND, 5V, signal) you only need to use a single GND and 5V then connect the two outputs to two of the signal pins.
Hope that helps.
@@LittleWicketRailway finally sussed it all out Rob. I made the mistake of putting the first 1k resistor in R14 then read the instructions and took it out and populated R15/R25. Phew. Next did the software bit and nothing showed up on the Sensor table. Scratches head. Opened the Output monitor and kept getting "Sensor X unavailable" and one of the LEDs on the uno flashing when I operated the sensor, so they were seeing each other. Then I listened to you again and bingo .... you did tell us about the updated version. Doh. Now works a treat.
You have inspired me to do a YT on soldering up my second DCT2. Won't be as good as your presentations but ....
Hi, I am using a DCC++ command station for my controller and I use JMRI for control, but at this stage I have no block detection. I like the idea of your sensor board system and would like to implement that as part of my layout. On the MERG site it says that the single sensors are 2 channel version, does this mean that each single sensor board is able to provide detection for 2 blocks. If this is the case this would this mean the 8 channel board would handle 8 blocks. I am asking this because I have 28 blocks I want to setup and need a really cheap solution, and yours is the one I like the most so far. Thanks.
Hi Geoff! Yes, on MERG the 2 channel version can do two blocks and the 8 channel version can do 8 blocks. In fact I think the 2 channel version is just part of a chopped up 8 channel board.
If you're going to be ordering lots of the same kit then MERG then they prefer you to order all the parts separately from an electronics component supplier and just get the PCBs from them. Saves them some effort of packaging it all up and it's probably cheaper for you. The component lists and instructions should be available on the website. Although, you might be ok if you're just ordering 4 of the 8 channel kits.
Sounds like you'll be soldering for most of Christmas!
hi,good video, If I replace the MERG sensor with acs712, do I need to change the code?
Is the MERG project of the occupancy detector the one they call BOD1 on their site?
Hi! In the kit locker the MERG reference is DTC2 (Kit 50) or DTC8 (kit 56) under the DCC section. I believe they've just redesigned them, but I don't know what the difference is..
Hi there. I was wondering could you help me. I have been inspired to add block detection on my layout. I have joined MERG and bougth several kits DTC2 kits. I think ihave followed your videos to the letter, but still cant get it to work.
Do you have a close up photo of your competed DTC2? There is quite the discussion on the MERG forums as to what resistors to use....if any!
Hope you can help.
Good luck with your channel.
Hi Stephen,
Sorry to hear you can't get them working.
Firstly, are you using these on a digital layout as I think these will only work with DCC?
Secondly, have you checked that the sensor hub and JMRI works with a simpler sensor such as an IR sensor? If that's all working that it confirms that the issue is with the DTC2.
It was a while ago that I built these, but I recall that there were some options when it came to resistors depending on what voltage the power supply the sensor was. It was the 2nd option for 5Vs that I used for the arduino sensor hub.
Afraid I don't have any close up shots. I think that MERG is the best place to get help on this, I'm sure that someone with more knowledge than me will be able to help on the forum.
If I didn't want to use JMRI but just turn on / off LEDs when occupancy was detected is that possible via the sensor shield with the DTC2? I'm not into automation but would like a quick indication of if something is on the tracks for some hidden sidings
Hi Martin! That's definitely doable with a bit of coding. A few people have requested mimic/display panels and turnout controls that work without JMRI, so I'll try to cover that in a future video. It's not really my thing because I'm doing this with the aim of automation, but (famous last words) I don't think it would be very difficult.
It should just be case of reading the sensors and then a series of IF statements:
IF ... block 1 sensor is active ... THEN ... turn LED 1 on
IF ... block 2 sensor is active ... THEN ... turn LED 2 on
etc.
@@LittleWicketRailway A basic mimic panel is exactly what I'm planning - a very large multiple IF...THEN would not be the worst programming I've ever done. Will give it a go.
@@LittleWicketRailway turns out the DTC2 actually supports native LED illumination if you don't want to go down the Arduino route. Having watched more of your videos I'm going to give JMRI a try.
@@martinrandall3735 Thanks for sharing that, good to know for mimic panels. Nothing to lose with JMRI, it's free, see what you think.
Rob, are you using JMRI OBLOCKS for occupancy detection with your signalling. It appears this feature was built to be used with Signaling. Bob S - Cleveland OH
Good video, but that complex system you described at the start of your video that logs trains in and out of a block, that is actually quite easy to do and you can detect missing rolling stock without needing the hassle of resistor wheel sets. I'm using a single ESP32 (£6) and a few sensors (less than £10), to cover over a dozen blocks, that is less than a MERG membership. MERG kits work but the technology is really outdated and overpriced.
Thanks. I suppose it depends on the layout, some would be easier than others and presumably you needed to write code or make use of JMRIs logic to get it working?
Little Wicket was just far too complex for me to code as it includes multiple bidirectional blocks and I'd have needed a lot more sensors on each entry/exit.
Also, what happens when you turn on for the first time? How does it know if anything is in a block?
Apart from the soldering this is a "plug and play" system which was the goal. There is a pocket money project that costs around £1 that can also detect current, but causes a small voltage drop.
I've not tried any of their other kits, but an Arduino group has just started up so I'm following that with interest.
@@LittleWicketRailway The code is already written for you, all you do is configure the WiFi and off you go. There is an initialization process in the code that determines the current state of the block. Arduino really isn't the best choice, the modules are expensive compared to ESP32/ESP8266 and are drastically under powered. I occasionally use Arduino to extend ADC and GPIO on the ESP32, for example, with the Arduino Mega. You might be interested in checking out oorail.co.uk/computer-controlled-trains/
Sounds interesting, will check it out 👍
Arthur GWR
DCC is aimed at the toy train set, as it was designed by a High Street Electrical Engineer NOT a Railway Engineer, and therefore does NOT comply with even the most rudimentry rules of any real railways operating methods. Except possibly American, Central Traffic Control (CTC) which is suited to freight only operation, as basically it has done away with signalling !
So if you are planning to construct a realistic Model Railway that requires real life operating methods, you can't use DCC !!! Further DCC is roughly 400% more expensive than any analogue system, even sophisticated ones that can provide the real life track circuitry necessary to operate either semaphore or colour light signals. In EXACTLY the same way as they work on the real railway !!
I use real life Track Circuits to interface with the real life interlocking and ensure signals only show the correct aspect at exactly the moment they would on the real railway. Using a 12v DC Analogue system, my Track Circuits only cost ONE PENNY each and only need a piece of wire ! This provides the train detection and triggers relays which control the relevant signals. And of course if you only have 12v DC accessories on the layout, just ONE common return wire around the layout is all that is needed to complete 40-45% of ALL the wiring on even a large layout. Which means less wiring of large layouts than DCC !!!!
Why waste huge amounts of cash on DCC, which can't provide a realistic operational system, when for roughly 25% of the cost you can use 12v DC to provide all the real life methods of the real railway. Assuming of course you don't want childish gimmicks such as search light type interior lighting, and tinny effect sound systems !!!!
Just driving trains in circles is NOT how real railways work !!!
Hi James, DCC is just a standardise way of communicating data, it doesn't really stop you from implementing the real ways that railways operate. The obvious major advantage of DCC is the ability to run multiple locos on the same track using a single controller and circuit which adds realism. Radio controlled battery powered locos would probably best replicate how the real railway works.
Have you come across this guys current sensors www.dcc-decoders.com/product-page/current-sensor . 10 euros for a 4 section detector, which seems a good price. Feed it back to an arduino and you are sorted. I've used it with JMRI and now about to try with Rocrail.
Hello, this appears to be a useful option. Has anybody tried this?
The W10M bridge rectifier is in series with the track power, so you may notice a speed drop in decoder track sections if there are other sections without detection. Also the rectifier is designed for mains power 50 or 60 cycles per second, so the forward to reverse (recovery) time means you will have some additional losses at DCC switching speeds (5000 to 10000 reversals per second). You could replace the W10M bridge with back-to-back 1N5822 Schottky diodes at 3A for twice the current rating and less voltage drop by a factor of 4 (only 0.5V instead of 2.0V in the bridge configuration) and sub-microsecond recovery time to keep nice clean DCC signals. Should work fine for DC power though...