DC setup automation


cyxapebpek

New Member
Hello, I'm trying to put together a regular DC setup and hook up a microcontroller to it for automation. From what i understand I can wire power to the track through a relay and control the relay with the microcontroller. Does this sound realistic and can someone suggest a proper relay to use for this?

Thanks.
 
I want to control the power to the track with a computer. Have a computer program switch the power on and off. So i need to run a wire from an input/output pin on the microcontroller (computer) to the track, but the microcontroller cannot power the locomotive directly so i need it to switch the connection from a power pack.
 
Modern power packs have an internal circuit board that pulse width modulates the power... you could hook the computer output to the gate pin of the power transistor and have full speed control instead of just on/off. Add a double-throw relay to that and you could control direction too. This might be overkill for your application, but it would be pretty cool IMO.

From what I've heard, if you use a relay, you should put a diode backwards across the coil to absorb the back EMF when it turns off, as this can damage the transistors inside the computer (or on whatever microprocessor/shield/etc you're using). I heard this about running directly from a parallel port, but I assume it applies to other hookups as well.

To select a relay, you need to know what kind of power your computer setup will put out, and how many amps the train will draw. A standard automotive headlight relay should be more than sufficient for trains (assuming you're not running a huge G-scale articulated or something), but the output of a parallel port won't be powerful enough to trigger it, so you'd need to throw a MOSFET or something in there... and you're back to it being easier to just hack into the speed control.

Actually now that I think about it I think I've seen a board with 7 or so relays that plugs straight into a USB, you might see if you can find something like that.
 
Thank you for your response. I haven't thought about trying to control speed yet, maybe after I get the basic setup right.

I think this is something that might be right for me -

http://www.sainsmart.com/8-channel-...sp-avr-msp430-ttl-logic.html?zizio=powershare

although my microcontroller board uses 3.3V I/O not sure what the amperage would be but probably less than 100mA.

I'm thinking i'll need a relay for each control block on my track. Not quite understanding how I would control polarity though. (complete newbie in electronics).
 
Thank you for your reply.

I want to use a little computer called Raspberry PI to accomplish this. It has 3.3V I/O pins that apparently can't put out more than 20mA. Haven't thought about controlling the speed, just want to get the basic setup done first.

found this write-up, looks like something close to what i need:
http://arduino-info.wikispaces.com/ArduinoPower

also talks about power transistors.
 
Last edited by a moderator:
I work with microcontrollers on a daily basis, and if you'll let me offer a professional opinion, I claim that the Raspberry Pi isn't what most people should use for model railroad control. You can be dazzled by the amount of processing power it gives you for very little money, but that's not what we need to run trains. What would be more valuable would be a processor that's easy to interface and program, and if that's the goal, I'd say get the PICAXE or Arduino (Look them up). They make it simple to write a program on a computer and load it to the processor, and they're designed to interface with external devices easily too.

Only the very smallest relays can run off processor outputs directly. You generally need to control a transistor, which can then drive the relay from a 12V or 24V supply. It's a very common setup to build.
 
Personally, I'm not to fond of the idea of using relays to control the train. The sudden start and stops you get are not very realistic and are hard on the equipment. They also increase the possibility of derailments and unwanted uncouplings. I also agree that something like an Arduino would probably be a better option than a Raspberry pi; although, depending on exactly what you are wanting to accomplish I can think of reasons for going with the pi as well(for example, if you want access to video and a keyboard).

You may already know this, but the Arduino has what are called "shields" that plug right into the Arduino. A "motor shield" can directly power a model train(actually two, because it has two outputs). With a motor shield, you don't just get on and off, but you can vary the output, allowing you to realistically ramp the train speed up and down.

I've actually done this sort of thing. At Christmas, I have an N scale loop of track that that I mount in the tree and an HO scale loop I put under the tree. I use an Arduino with a motor shield, PIR motion sensor and infrared receiver to run the trains. I can control the trains through the infrared receiver using a universal remote, or I can set it to "automatic" mode. In automatic mode, if it detects someone in front of the tree(using the PIR sensor), it will run the trains on it's own. It ramps one up to speed, then the other, waits a set period of time, then slows each one to a stop.
 
Thank you for your suggestions. I am doing this for a school project and i'm stuck using the RasPI. the board that i found is actually designed for arduino, but it seems like it can be used with RasPI too.
I intend for this project to be a very rough prototype, just to test out the concept, controlling the speed would be beyond the scope.
 



Back
Top