Newbie needs some advice on direction

Hello everyone

I’m new to the microcontroller arena but have some electronics experience in my past.
Our statewide model train organization here has been asked to put up a train display for the holidays. We did this last year as a pilot project to see if we could do it. “if” meant seeing if we could design the display in a very short period of time, then put it up in two days over Thanksgiving weekend walking away hoping that for a month the trains, lighting and animated features worked flawlessly. They actually did.

We used a borrowed Insteon Home Automation system to control everything, the trains (on and off), the lighting in the buildings (dimmers), overhead lighting using Christmas lights (dimmer), controlling the Christmas Music sound track playback (on and off). We found third party software that let us schedule everything. Each of 3 trains ran every 20 minutes (20 on, 40 off) so there was always a train running. It worked very well.
This year the display is about 4 times the size with 5 trains running. The Home Automation was borrowed. This year we would have to buy the whole thing. The hub is $200 and each control circuit starts at $50.

I’ve been playing with Arduino (the model train hobby has been for years) for a few months. But it doesn’t have some easily incorporated features we need. I really don’t want to stack a bunch of shields on each other. I thought about moving to an Arduino Mega or Due because they have more IO options but some things are still lacking. This led me to Netduino which in turn led me to Netduino Go, MNF & Gadgeteer. Netduino Go isn’t sufficient so I started looking at controllers outside the Arduino arena.

I like Gadgeteer because it uses Visual Studio. I’m a web developer by trade and have been using VS since .Net 2.0. I have Ultimate 2013 and the 2015 CTP Versions installed. Working in C# or VB is preferred rather than dusting off 15 year old C coding experience.

I think the Raptor is possibly my best option.

Here are most of the requirements.
• It needs to be controlled by a schedule on a real time clock. If the system is reset or loses power it needs to start up and run the schedule where it should be in the schedule, not where it left off.
• It needs to have at least 18 inputs. All are going to be digital. A train passes over a pressure sensor or photoelectric sensor and makes something happen like a set of crossing gates go down and crossing lights flash. The electronics are already in the crossing gate system so I just need to turn it on and off.
• It needs to have upwards of 18 outputs. Some are digital and are “on” or “high” from 1 second momentary (to throw a relay that throws a train track switch) to on for 16 hours. The display starts up at 8am and goes off at 10pm or 11pm. I need some analog and PWM might work. These need to control 120VAC Dimmers for overhead lighting and lighting in buildings (they are Dept. 56 cottages and use 7 watt C7 bulbs. All the dimming lighting is incandescent and the total on a circuit at most would be 500 watts.
• The display uses Lionel Trains which are normally run on 0-16VAC. But more modern Lionel Trains actually use a DC Can Motor and there’s a circuit board inside the locomotive that rectifies the AC for the motor. We can rip out the boards. We would lose some functions like smoke, reversing and sounds but that isn’t an issue. As long as the trains move in one direction with the headlight on that’s OK. We need the speed control on these so when a train comes down a hill it doesn’t pick up speed and go into a turn too fast and runs off the track. Basically this is hit a sensor, drop the speed by 50%, hit a 2nd sensor and go back to 100%.
• Ideally there would be a TFT Touchscreen display (7" to 10") that would provide some manual control. It would have icons on the screen to do things like turn everything off, reset the system, turn everything on for testing, dim the lights, and so on. The screens I have access to have 2 connectors, 1 for VGA and 1 for USB for the touchscreen.

From what I can tell I need the Raptor and the following:

• MaxO Module for adding outputs (Can these be used as Inputs as well?)
• Motor Driver L298 Module to control the trains
• USB Host Module to connect the “mouse” in the touch screen monitor
• Power Extender Module to get more power into the system to control everything
• SD Card module to hold the graphic files for the touch screen and for any XML data needed for configuration read by the software
• VideoOut Module to connect the TFT Screen
• The Touch L12 Module to manually change train speeds and/or dim lights
Pardon the play on words here but am I on the right track with this?
Thanks in advance for your help

@ DanCio - What you have so far sounds like it should work. The Raptor does have a number of analog outputs, but it has only 3 PWMs. So if that is not enough for what you need, the Hub AP5 can always provide more.

You also could potentially do without the MaxO, since it is output only. A few of our breakout modules connected to any X or Y socket would work just as well for input and output.

If you are designing a user interface, Glide would be helpful.

@ DanCio - Sounds like a really cool project! Please keep us informed of your progress, and please post a video of the final layout in action.

@ John

I don’t think I need PWM if I have analog. Varying voltage over time, such as dimming the lighting over a 5 second period is easy enough with a timer. Every .05 seconds drop the voltage that powers the dimmer circuit by 1%. We only dim the lights last year for 2 reasons, and only at the start and end of the day. They last longer coming on and going off by dimming and it’s a nice looking startup and shutdown sequence.

We really don’t need to vary train speed, just change it. Top of hill is sensor TH and bottom of hill is sensor BH. If TH is tripped, drop the voltage through the motor controller by 3 volts. When sensor BH is tripped increase the voltage through the motor controller by 3 volts.

We’d have 4 trains but only 1, maybe 2 will need the change in voltage. the Lionel Trolleys are a pain and they can’t be on a variable circuit. The reversing unit is a mechanical bumper on both ends of the trolley. When the trolley smacks into a bumper it reverses. The problem is that when the trolley is shut down close to a bumper when it powers back up it doesn’t have enough distance to gain enough momentum to hit the bumper hard enough to reverse. What I want to do is put a sensor halfway between the bumpers and when I trigger the trolley shutdown it continues to run until it hits the sensor. When it hits the sensor it would need to immediately stop. There isn’t any flywheel in these motors so if it loses power it will stop where it is.

When you say the Breakout Boards will work, do you mean (I’m newbie), that Pins labeled P3-P9 are 6 separate outputs?

I’d rather do plug and play rather than solder, so if I can use a hub with breakouts and the motor controls, I’ll pass on the GPIO modules.

How would I add additional inputs if needed?

Hi Dan,

On breakouts: Yes, P3-P9 are simply the IO pins that the socket exposes. The breakout also exposes the 3v3 and 5v and GND power connections.

PWM is often the “best” way to vary voltage from a microcontroller. Analog Output is an “uncommon” feature, but you can be sure of one thing - it will be of limited current and of limited voltage range. But then again, PWM is subjected to the same max voltage and current limits, so the key will be how you interface these outputs into the “controls” of the circuits you have such as the lighting and speed controller. Do you have any detail on how that is done today or how it’s been done with Arduinos etc? Because of this, I suspect that there’s still a place for you to need soldering and perhaps even custom circuit boards (possibly as simple as strip-board and components; unless you already have that). So knowing what these control interfaces need to be will help guide this more.

I don’t know yet if the sensors will be pressure or photoelectric. It’s going to depend on the weight of the train engines whether or not I can use pressure. I know regardless of which, I need to build the sensors and that requires some soldering. I was going to have to do that regardless of which microcontroller was used, whether it Arduino or Gadgeteer.

The variable outputs aren’t that critical. The only ones that are really needed are the lighting dimmers and that’s even a would like not a must have. Like I said the trains just need a voltage change and I can do that with the motor module.