TrainZ

My dad has a set of trains from when I was a kid (N scale, mid 90s). He recently brought it out to get my 3yo son interested.

Since I’m now a software engineer, I decided I need to get into this too. Just for fun. I bought a couple of motor controller boards and I plan on eventually converting my engines to DCC (the new hotness) but they currently are just motors.

I started with some prototype boards, testing and proving some theories. Since Ryan got into easyeda and making his own pcbs, I thought I would get into it as well. I have to say, it it so much more fun and easier than I remember.

I got the boards yesterday and I spent a grueling 2 hours or so soldering the smd components on. I found a few mistakes already, and I’m ready to make v0.2, but I want to take this as far as I can to try to avoid a v0.3 :).

It does seem like it will work, but I toasted my motor control board’s 5V reg and the USB UART on my first esp32. Tough news when you are so careful with the board and then you hook it up wrong :(. But why buy one when you can buy two at twice the price? I have spares. I haven’t connected it back to the track yet, I need some more software, but I think it will work.

Running album:

The current list of v0.2 improvements:

  • joystick needs to be rotated 45 degrees and moved away from the esp for finger clearance.
  • joystick pins need pullups, since those pins on the esp32 don’t have internal pullups. (Although I’m quite proud of my rework).
  • add 5V regulator to board, diode or short pads to choose from internal/external 5V.
  • analog diodes and resistors laid out clearer for soldering.
  • switch diodes to 0603 pads
  • motor and extra pins moved closer to the edge
  • 0.1" pitch power pins moved out a little for more connectors space.
  • maybe, just maybe, integrate the h-bridge to avoid the extra board.
  • Maybe make any extra room full of 0.1" pins for adding extra components, like a builtin perf board.

I also want to design a case, to see what kind of changes I might make w.r.t. that. I also haven’t tested the analog inputs to see if they will do what I want. When I do that, I can order some V0.2.

Anyone have any ideas on what I can do with 9 empty boards? The esp and uln2803 combo is pretty useful for LED controls. Maybe I’ll find a use for them. The 3 analog inputs are pretty specific, but they are protected by zeners, which is also helpful in other things.

3 Likes

I have to have at least one pic here.

[attachment file=63225]

1 Like

I can’t wait to make another board.

I would say definitely break out every pin just in case. If you do need a V3, V2 will just be an easy prototyping board.

What do the lights indicate?

The bank of 8 lights are on when the track switches change (the turnouts). The bank of 2x2 is synced with the track motor outputs. It supports two tracks and if it’s driving in the DC motor mode, it will be either green or blue on each track. If it’s in DCC mode, the tracks that are on will just be blue and green. I doubt any of the encoding will be detectible from the LEDs. I just add them to give some sense of what’s happening.

So the list of features are (still needing software to get these all running):

  • OLED screen
  • 5 way switch
  • two track controls. This needs a separate h-bridge board but should support dc or dcc.
  • two track current sensing
  • control of 4 switches. I dont know the names of the ones we have, but they need a brief pulse (750ms) of 12VDC to switch in either direction.
  • uart connection (to connect to another micro for more buttons or lights).
  • 18V analog input for reading a “classic” speed controller. The old knobs we have are too much fun, so I want to read that value in and use that to determine the speed.

If you don’t know what DCC is, I didn’t either, until I started looking into this stuff. It sends 18V on either the left track or the right track all the time, which provides the power. If it switches from left, right, left fast, then that is a 1 and if it switches slow, then that’s a zero. That’s how it encodes the signals for the engines to drive, or turn on/off lights, or control DCC switches. I am optimistic I can do that encoding with my little CPU. We’ll see. The commercial DCC encoders are crazy expensive and not at all hackable. There are a few people that have used raspberry pi or arduinos for this, and one was even a esp32. It just had a slightly different H-bridge.

My dad’s set is an O-27 (I think) set from I believe just after the war. He was nine going on ten when the war ended and was six when it started, which is what leads me to think that’s the timing. I haven’t looked in the box in years, but IIRC it’s a pretty basic beginners set, a simple oval with less than a half dozen cars. I’d be fun to get it mounted up and maybe expanded… Going to have to be a round tuit though, since I’m still pretty much stuck where the wheelchair reaches.

1 Like

We don’t have any thay old. That’s cool. My dad’s has some from his childhood, so 1960s.

My electronics test track is just 4’ straight. I was thinking of putting one on Ryan’s sensors on each wnd and have it bounce back and forth whenever someone slacks me or something.

Think big, a train that goes though every room. Breakfast in bed for Jr. delivered by train?!? Late night coding session redbulls, cocktails, snacks. Or maybe just reprogram a roomba.

1 Like

Time to really start looking at the robotic arms on Thingiverse to see which will fit on a flat car…