Maker Pro
Maker Pro

Arduino control of model train signalling (was: LED Power Supply for Control Panel)

Thank You Harald

Do you mean something like this ????

attachment.php


Mark

If so any recommendations on relays would be welcome
 

Attachments

  • Syncro Control Panel4.jpg
    Syncro Control Panel4.jpg
    50.2 KB · Views: 677
Exactly.

What kind of recommendations do you expect?


Well the kind of recommendation that would lead me to buy the correct relays for the job.

Do i need a special type to use with momentary push button switches that will stay latched in the desired position when the switch has been released ???
 

Harald Kapp

Moderator
Moderator
If you use latched relays, you will have to add additional circuitry (pushbuttons or other relay's contacts) to reset the relay. Otherwise it would stay in the latched position forever.
You will now have to define the conditions for resetting the relays.

While all this is possible with relays, the circuit will become quite big and even harder to extend should future requirements arise.
Have you considered doing the logic in an electronic circuit (maybe even a microcontroller) and having only the power relay for actually switching the power to the trains? (The LEDs can be controlled from logic circuits).
 
Hmmm

The circuit we have discussed here is just a part of the actual circuit needed. With very few replies i continued to dabble myself with very little electronic experience and came up with the relay circuit as a solution.

Having said that i did try to read up on logic circuitry but to be honest it baffled me to the point that i gave up reading... (maybe i shouldn't have!!!!!!

I understand a relay cause i've physically seen them but logic side is a mystery i'm afraid, likewise to micro-controllers which i assume need programming ????

All said, a logic circuit does have its benefits as i wanted certain parameters to be met before switches could be pressed (outputs made).

This circuit here here is purely for sequence control and will not be connect to any tracks so will be totally seperate from the DCC tracks.

SO are we talking AND, NAND, NOR , OR gates??

Mark
Bewildered by Technology
 
I have been busy learning (hopefully with some success) Logic Gates as this may, or may not be the key to this build.

Sequence Logic Part 11.jpg

If i have understood what i have read then the circuit in this post should

1. Illuminate D1 when SW 1 is made
2. illuminate D2 when SW2 is made but only once SW 1 has been made
3. Extinguish D1 when SW2 is made

If that is correct then i have learnt something :)

I guess my next learning exercise will need to be...How to utilise the logic part of this circuit and combine it with a circuit that latches the push button inputs until another selection is made :/

Mark
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
SW2 won't work. The resistor needs to be between the input and the positive rail if the switch is pulling the input low.

Think of the resistor as a weak pull in one direction and a switch connected directly to the power rail as a MUCH stronger pull in the other direction.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
And your interpretation of the logic seems wrong to me. Sorry.

I'll try to figure out ll the possibilities later.

With these gates, all that is important is what is pressed now, the order they are pressed will not make a difference to the final state.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
The possibilities are:

S1 S2 | D1 D2
----------+---------
0 0 | 0 0
0 1 | 0 0
1 0 | 1 1
1 1 | 1 0

for switches - means released, 1 means pressed.

for LEDs, 0 means off, 1 means on
 

Harald Kapp

Moderator
Moderator
In addition: wi´th that kind of logic only (wiithout any storage elements) you're back to the original problem that the state of the LEds (and any associated relays) will change back once you release the pushbutton.
You will need some memory circuits, like simple FlipFlops.

Read this tutorial to learn how combinational logic (the type you used) can be usefully combined with flipflops to create sequential logic (state machines).

Go ahead, you're on the right track (pun not intended but fitting :D)
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Actually, I think the simplest solution might be to custom program a small microcontroller to do this.

Whilst maybe a little more expensive, it would be a simple building block that could be incorporated into a design.

Add to that a small circuit board that has (say) input protection, power supply filtering, and a couple of open drain mosfet outputs, the problem would be reduced to just wiring the things in.

P4, how many of these things do you need for your layout? Just the one, or several, or many?

How far apart are the switches and LEDs mounted (cable length question)?
 
In addition: wi´th that kind of logic only (wiithout any storage elements) you're back to the original problem that the state of the LEds (and any associated relays) will change back once you release the pushbutton.
You will need some memory circuits, like simple FlipFlops.

Read this tutorial to learn how combinational logic (the type you used) can be usefully combined with flipflops to create sequential logic (state machines).

Go ahead, you're on the right track (pun not intended but fitting :D)

Thanks Harald ....will read up on them... had no intention of leaving the switch arrangement as i posted in the circuit just trying to get some idea of Logic Circuits but need more education lol
 
Actually, I think the simplest solution might be to custom program a small microcontroller to do this.

Whilst maybe a little more expensive, it would be a simple building block that could be incorporated into a design.

Add to that a small circuit board that has (say) input protection, power supply filtering, and a couple of open drain mosfet outputs, the problem would be reduced to just wiring the things in.

P4, how many of these things do you need for your layout? Just the one, or several, or many?

How far apart are the switches and LEDs mounted (cable length question)?

Thanks Steve,

No doubt with your experience you are right but that may be beyond me..programming a micro controller and the such :eek:


The intention was to have the pcb board with all the circuitry housed in the main control panel which will be stationed (no pun intended) in the middle of the layout..

Then i would need two seperate control stations, one at either end say about 25 foot in each direction from the main control panel.

These outer two mini control stations only housing switches and LED's linked by cable to the main station.

Mark
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Thanks Steve,

No doubt with your experience you are right but that may be beyond me..programming a micro controller and the such :eek:

Possibly...

But if the logic is as simple as you say, then programming a uC to do it would be almost entirely trivial and someone could program them and send them to you.

If there's a need for several of them it would be far cheaper for the second through nth circuit because just putting the program on the chip is trivial.

If you're already looking at having a PCB, then it's even easier since you've kinda already factored that in.
 
Possibly...

But if the logic is as simple as you say, then programming a uC to do it would be almost entirely trivial and someone could program them and send them to you.

]If there's a need for several of them it would be far cheaper for the second through nth circuit because just putting the program on the chip is trivial.[/COLOR]

If you're already looking at having a PCB, then it's even easier since you've kinda already factored that in.

Not sure as to how many I'd need.... know very little about microcontroler chips, so not sure how much they can handle. Would i need one for each line (track) ?

My other concern is that this project seems to be evolving with time. Whilst a micro controller chip may be the ultimate solution it seems to me that once programmed your stuck with it and to change parameters i'd need to pay someone again to change the thing.

Having said that ultimately i guess it can be the final outcome.

My Idea was to create the "sequencing control panels" myself by etching the pcb, populating the boards and wiring them into test panels, then trialling them first before fitting to the final control panels...

That way if things needed updating it could be done without much fuss....all according to me being able to figure out the circuits needed.

Thanks As Always for your Valuable Inputs Steve
 

Harald Kapp

Moderator
Moderator
Would i need one for each line (track) ?
Nope. A single microcontroller can handle lots of tracks. Of course, it depends on the choice of controller, how many. The logic itself should be no task at all even for a tiny 8 bit controller. Another issue is the number of input and output pins (I/O-pins). You may need to add some circuitry to expand the number of I/O-pins of a small controller, but that is easily done using e.g. some shift registers.

My other concern is that this project seems to be evolving with time
Contrary to your concerns, this calls even more for a programmable solution (aka microcontroller). Imagine that you would have to re-wire your logic circuits every time something changes in your circuit...
With a microcontroller it's the same hardware everytime, only add sensors and drivers for new parts of the circuit. The rest is software.

I admit, if you have never bevore programmed a microcontroller, you'll have a steep learning curve. So better start today. You don't have to build the microcontroller hardware from scratch. You can buy ready to run boards e.g. as evaluation boards for different microcontrollers or as prototyping boards.
One very popular platform is arduino which comes with the basic hardware plus lots of so called shields" which take over specialized tasks like e.g. driving relays, sensing inputs, displaying data etc. The arduino is programmed in a highh level language, so getting started is rather easy. Also there is a big community of arduino users where you can find support.

This is not me advertising arduino. Besides the arduino there are a few other similar platforms.
 
WOW.......

Thanks Harald and Steve for coming up with this solution.

Its a very steep learning curve indeed.. BUT

Having Spent a couple of evenings reading about this product i can see more uses than just this project for such a device... one being servo operation of semaphore signals which we had already planned into the equation... now there is a strong possibility this could be linked to the track circuit diagram LED's.

Although i'm still learning i take it at this moment that the Logic Gates circuitry will still be needed ???????

Mark
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Although i'm still learning i take it at this moment that the Logic Gates circuitry will still be needed ???????

Probably not.

You can wire up your inputs to the microcontroller and have it determine which outputs should be on.

With logic gates, you might have 4ns delay. With a microcontroller,, maybe 4ms. For human reactions, they're both close to instant. (actually 4ms is an age, probably .4ms, or .04ms would be closer to reality)

The microcontroller does have a limited number of inputs and outputs, but even so, it's probably not so much more expensive than vanilla logic. As you get to needing more than a single logic chip, the microcontroller starts looking even more and more of a bargain.

You can get microcontrollers for a couple of bucks that will operate pretty much with no external components.

If you're looking at the arduino platform, I would encourage you to get a clone Arduino nano board and a breadboard. With that and the Arduino ERW environment, you can be up and running very quickly.
 
If you're looking at the arduino platform, I would encourage you to get a clone Arduino nano board and a breadboard. With that and the Arduino ERW environment, you can be up and running very quickly.

Thanks for the advice Steve... must have known i was gonna ask this question lol

I was looking at the UNO rev 3 but only cause you can get these

Arduino Sheild1.jpg

Basically convert pin in/out to screw terminal

Which would be handy for the prototype... then move onto cable/pins for the final product. But this only fits the UNO :( The difference in price is minimal.

Mark
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
I would get one of these, these and these. (and you might consider one of these). You might want to shop around, and beware of the long shipping times out of China

Later, when you have a bit more experience, you could start using these. (You can program them from your Arduino nano board). And you can incorporate them inside various modules where you need some control logic. (for the technical amongst us -- you set them up to use the internal clock)

If they're socketed (or using some other tricks) you can reprogram them if you find that you want to change their behaviour or fix some bug.

You will need to run everything from 5V, bit since you're using LEDs, that's not a huge issue. The arduino can drive a LED directly, and as you become more skilled, you can get one arduino to control many, many more things.

Once you have something working on a solderless breadboard, you can transfer it to a PCB or veroboard, or even matrix board, but there is an additional translation step there. There are some boards made which are already wired like breadboards. These allow you to transfer a working prototype from a breadboard to a more permanent construction with almost no changes (beware the power supply connections though).

If you really want screw terminals, look at these. They won't fit onto a breadboard, but they have the correct spacing so they will fit into every other hole on a board with standard 0.1 inch spacing (like the boards above).

Sure, you can also use shields and other things like that, but they tend to make it harder to move away from them for a final construction, and a little too expensive for my tastes to consume one (often with only a small fraction used) for each project.
 
Top