Go Down

Topic: Where to start? (Read 567 times) previous topic - next topic

dfargo5133

What is the best way to layout a project like this? I am not asking for somebody to write the code for me just how you start a complex project
It is a modelrailroad diamond interlocked crossing. For example if a train enters the "plant" at say detector 1 the program should check to see that none of the other detectors have a tain over them. Then turn Signal 1 green, as soon as the train is over detector 2 it should turn signal 1 red again. etc... etc... etc...

Thanks
Dan



michinyon

The first thing I would do,   is decide whether I am going to implement a solution for one, fixed, specific track topology,   or alternatively,  implement some kind of generic object oriented design which I could apply to any model railroad network.

The next thing I would do,  is consider very carefully what actions I want to take when any of the sensors changes its input state.

The next thing I would do after that,  is try and write down all the "states"  that the system can be in,   and consider what events
happen when transitioning from one state to another,   and then try to check whether all contingencies of train maloperation and/or
sensor maloperation  are covered.   Because a railway signalling system has to be fail-safe.

ash901226

you mean interlocking?
Urm interesting.
you could start chart all the possibly outcome that you might expect.
then some flowchart or flow diagram
you need to design each signal to be independent of each other but at the same time work coherently (in parallel)
then convert your chart to become your program..
once you have the chart i could help you change that into a program.


HazardsMind

There are a few ways to do this, the first would be to set a condition so that only one signal is green when needed. You also need to take into consideration if four trains are by some chance on detectors 1,4,5 and 8, to decide which train came first, and allow that train to move.

But to answer your first problem, with the detectors turning on and off when a train passes over them, I would use a Set/reset latch. Of course checking the other detectors as well, but I would first try to get that to work.
Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

PeterH

In the initial state you wait for the outer detector for any of the lines to be triggered. When you detect a trigger, set that the signal for that line green, wait for the train to trigger the inner detector and then set the signal red again.

For flexibility I'd implement this junction as a state machine (the state variable would indicate which line (if any) is currently green), and I'd use a non-blocking state machine to 'wait' for the detection triggers rather than blocking until the expected event arrived; this would make it possible for the same processor to control multiple junctions or carry out other activities at the same time. But for a crude proof of concept, a blocking approach would probably only take a dozen lines of code.
I only provide help via the forum - please do not contact me for private consultancy.

Go Up