Town and country - automated N-scale layout


Having the layout that you can set on its side sure has its advantages, I cant imagine doing that wiring on your back looking up.

You sure know what you are doing with that stuff. The biggest problem I have with wiring is I forget it within a month of doing it, so when I have to go back and trouble shoot something from months earlier often results in retracing everything, almost a total re do.

Super neat job, looks great!

Thanks for the complement! I have made some more progress with the wiring. Since I am using computer control, wiring quickly gets out of control if you're not organized. It will get even worse when I install the track sensors. And when I install street lights and building lights for the structures that's going to be yet more complexity :)

The last step for this phase of wiring is to install the Atlas switches for the Rabbit on the right side of the layout. I have run out of hookup wire so I have to wait until I get the wire. By mistake I bought a lot of 20 AWG wire a while back but its just too thick for this project. I have ordered some 22 AWG stranded hookup wire which should be here in a few days.

IMG_7123.jpeg
 
I got the Raspberry Pi stuff mostly sorted out from a wiring perspective yesterday. It took pretty much the whole day to update the software and debug some JMRI installation problems. By the end of the day, I was able to receive GPIO inputs from within JMRI.

Next step is to the install track occupancy sensors. This is going to result in a lot of wiring as I will need to install 12 of them. Here's a pic of a sensor which is actually a miniature reed switch. When you bring a magnet near it, the contact is made - super simple. All it takes is a 1/8" hole between the ties in the track to install. I will be using Wago connectors to hook them up.

IMG_7127.jpeg
 
I got the layout temporarily back on its feet for some test runs. It's only by actually running trains that I can figure out where to install the sensors. So far everything has been running fine. The Tortoises and the stationary switch decoders are over 16 years old and are still working perfectly - they are now on their third layout!

I'm having way too much fun running trains for the moment - its only on this layout that a SW1500 can have a meet with a Swiss Ge 4/4 III :)

IMG_7131.jpeg


IMG_7132.jpeg
 
One more thing to add - I absolutely love the Peco Unifrog code 55 turnouts - they work much better than any N-scale Atlas turnout. I am using one of the sets of contacts on the Tortoise to switch the polarity of the frog so it has been super smooth for locos.
 
Installed the sensors and now in the process of wiring them up. There are 12 track sensors. I am also using one set of contacts on each Tortoise as a sensor so that the computer knows when way a turnout is set. That means 16 sensors in all. Good thing there are at least 20 GPIO pins I can use on the Raspberry Pi. Right now I have completed wiring 4 of the sensors - only another 12 to go :)

IMG_7134.jpeg
 
Finally finished installing and wiring the track sensors. Also used some zip ties to tidy up the wiring a bit. Next step is to install the detachable connectors for the sensors and track power. I will be installing the SPROG and Raspberry Pi on a separate detachable board - this will make transporting the layout a lot easier.

IMG_7135.jpeg
 
Getting ready to hook up the Raspberry Pi to the layout. I installed some standoffs and mounted the RPi on a piece of 1/8" plywood. I installed a couple of plugs so that the sensor lines can be easily detached from the layout. These plugs are actually meant for use between a car or truck and a trailer but it works fine for my needs!

IMG_7138.jpeg
 
I got everything assembled and then discovered that some of the sensors did not work at all - no state change was showing up in JMRI. I then belatedly discovered that not all GPIO pins have pull up resistors. So I pulled the stuff off the layout to do a careful study of how the various pins work with JMRI.

The connectors just look horribly ugly and are just too big:

IMG_7139.jpeg


It looked really bad once I assembled everything together:

IMG_7140.jpeg


I need to regroup and figure out a better approach to wire management.

And just to add to my annoyance, I recently bought this cheap knockoff of a Knipex wire stripper on Amazon. It worked exactly twice and then went out of alignment. Now it just snaps wires when I try to strip the insulation.

Grr - lesson learned. I have long wanted Knipex tools but avoided getting them because they are so expensive. Now I know why they are so much more expensive but I have decided that I am just going to get the real thing.

IMG_7141.jpeg
 
maybe make a nice little cover that easily slides off and on. Ironic the part we can't see has such a neat appearance (the underside of the table).

Thanks for the heads up on the knock-off stripper tool!
 
maybe make a nice little cover that easily slides off and on. Ironic the part we can't see has such a neat appearance (the underside of the table).

Thanks for the heads up on the knock-off stripper tool!
Yup - It just occurred to me I need to get a wood or plastic box to hold the electronics. It has to be detachable so it won't get banged up when carrying the layout to shows.

The other thing I just realized is I want is to have a single cable between the electronics box and the layout. This cable will carry DCC (2 wires) and all of the sensor lines (12 reed switches + 4 tortoises + 1 ground= 17 wires). So that's 19 wires in all.

What I have to see is whether the DCC signal will interfere with the sensors though.
 
I spent most of the day carefully testing each GPIO pin on the Raspberry Pi and discovered that there are a total of 19 usable input lines in configuration that I am using. This is a relief since I need 16 lines for this project.

I think I have figured out a better way to connect electronics with the layout: good old DB25 cables!

I found this breakout board for DB25 connectors.

Screen Shot 2022-09-16 at 15.57.25.png


And this is what the cables look like

Screen Shot 2022-09-16 at 15.57.48.png

You may recognize that these are the printer cables that we used in the 1990s before printers switched to USB!
 
Next problem I ran into this morning was that once I got everything hooked up, sensors did not work - they just kept randomly switching back and forth on their own. After some debugging, I discovered that there is a serious electrical problem with those ugly square connectors. The electrical interference is causing the sensor inputs to trigger randomly. I have ordered the cables I mentioned in my previous post - I think that will take care of the problem - keeping my fingers crossed!
 
I did some more experimentation and am now coming to the conclusion that GPIO lines are probably not going to work for sensor input. The sensors work fine as long as the SPROG is turned off. The moment I turn on the SPROG, all hell breaks loose and the sensors start randomly flipping back and forth. This means that the SPROG is introducing some electrical noise. With enough time and equipment, I could probably fix this but its just not worth the effort.

On the whole, I am beginning to think I would be better off with a Digitrax based system. I found a product from Tony's Trains that will likely work for my needs: https://tonystrains.com/product/dcc-specialties-jack-ad-sensor so I went ahead and ordered it.

I might have a SPROG that I don't need - any takers? :) [Just to be clear, the SPROG works perfectly on its own, just not in my configuration]
 
I rummaged through my box of DCC parts and realized I had a DS64 that I had bought for an old layout. I spent some time working through the manual and programming it. And hey presto, it works perfectly as an 8 line feedback encoder. The functionality seems robust and it would help me avoid a lot of extra wiring.
In a nutshell, the DS64 would be perfect for my needs. Only small problem is that Digitrax has discontinued the DS64 :)
Also, the DS74, which is the Digitrax successor to the DS64 is not a direct replacement as it does not have 8 sensor inputs. The question in my mind is whether to buy a used DS64 on eBay or find some other equivalent device.

IMG_0056.jpeg
 
While I was looking through my box of DCC stuff, I came across this quad servo DCC decoder from Tam Valley that I had bought years ago and then completely forgotten. Just for the heck of it, I tried it out with the linear servo and, to my great surprise, it actually worked! I was able to get the servo to move back and forth.

The servo moved much more smoothly compared to when I was using the Raspberry Pi to generate the PWM ( pulse width modulation) signal. I feel silly for not remembering I had this gadget - it could have saved me a lot of trouble a few weeks ago. Lesson learned - you really need dedicated hardware to control servos.

Even so, I still think I did the right thing in switching to Tortoise switch motors. If I had used this gadget, I would have needed an additional bunch of relays to switch the frog polarity and provide feedback.

IMG_7145.jpeg

Even so
 
It took over a week but I finally got the LocoNet sensor boards from Tony's Train Exchange. Unfortunately they came without any documentation and there was nothing available online either. I tried out a board anyway and it clearly shows some sign of life but it's generating turnout throw events instead of sensor events. Hopefully I'll be able to get the required documentation on Monday. Grr - so close and still stuck :(

I have really had to learn to be patient with this layout - lots of struggle but it will be worth it in the end!

IMG_7165.jpeg
 



Back
Top