I’m building a new O scale railroad for the Little Buckeye Children’s Museum. Most O scale railroads, including ours, use 3 rail track. For several reasons, and without going into a long explanation, I am deviating from normal practice and putting DC on the rails. One way of actuating flashers at a road crossing is to use an isolated section of rail, a separate power supply, and a relay (see the diagram below).
The manufacturer of the crossing signals sells a flasher unit for about $120, but I can make one much cheaper with an Arduino and a very simple program. What I am curious/concerned about is whether it would be safe to connect the Arduino ground to the track power supply ground (in place of the accessory power supply in the diagram) and a digital pin to the isolated section of track. The alternative would be to use the relay circuit as shown and connect a relay contact to the Arduino.
My gut says don’t connect the Arduino directly to the track, but I’m curious what others think.
Know that this way of running trains is a bit more dirt sensitive as one rail is not supporting the powering.
I run Marklin trains on K tracks and a signaling like Yours. I've used stuff from Littfinski Daten Technik. Unfortunately it looks like the old knowing owners sold their business to cashier only knowing people.
To the point. Their train indicating system uses opto couplers but sometimes extra pullups are needed. Don't underestimate how track length, length of the section, affects noise levels etc.
Make a principal drawing of the train presence detection You intend.
Did not know, hadn’t thought about, the Arduino ground being connected to earth ground. Probably would not connect it to the track while powering from the USB port though.
Although I’m a ham and pretty good with electronics, I spent a career doing motor control with relays. Sometimes I forget about using electronic parts like transistors and opto isolators instead, thanks for the reminder.
I am aware of the dirt problem. Our current layout is AC powered, but only on 2 rails (not my doing). I have built a couple of HO layouts for me and those only have 2 rails, so I think it will be okay if we keep the rails clean.
I've got 3 cleaning wagons that are pulled around to clean. One has a vacuum cleaner(!) and 2 polish the rails. German stuff, some 250 USD each.... Can't get the name out of my mind right now. Good company, yellow cars...
Relays ought to work, use more current but are likely less noise sensitive. I've got 150 sections... Using 100 mA per section would be heavy..