I'm new to Arduino and have decided to get involved for one reason; creating a control system using logic control. The intended use for this will be outputs to relays controlling point motors, servo motors, a number of LEDs and power feeds on a model railway.
I have spent a considerable amount of time over the past few months creating tables of routes and the required position of turnouts for each route, creating the logic control using AND gates to set the turnouts on each route to their respective positions and incorporating checks for normal and reverse positioning to check if a turnout requires switching and subsequently if it has then moved into the correct position. I have also included a route availability check to determine if any turnouts on the route selected are currently in use by another route that is already set, thus making the requested route unavailable.
I have yet to go into signalling or track feeds. However, this should be feasible to incorporate into the program at a later stage (I hope). So to give an outline of how the system should function:
- The route selected must be a valid route. (there are 57 routes).
- The route selected must not conflict with any other route already set.
- All the points along the route are set.
The movement of each Fulgurex point machine is controlled by its own relay, which will be "normal" or "reversed". - Changeover contacts on each point machine complete a circuit which logically represents the route.
When this circuit is complete, it indicates that each point machine has moved correctly, and confirms the route.
5, Separate relays connect traction current from the operator's controller to each finite element of the set route. These can be very small elements of track, only a few centimetres long in complex areas of pointwork. - Mini LEDs illuminate the route on the control panel.
- After a few seconds delay, the necessary signals along the route are cleared.
- The signal aspect is repeated on the control panel
Now, to start off the plan is to get all of the turnouts set along a route with just two button presses. As this is a terminus station, the signalling is much simpler in its operation and being semaphore signalling, a little easier to control.
I have drawn up the tables of turnouts to be switched for each route and their individual positions.
The reason for the use of the shiftIn and shiftOut functions is quite obvious; there are 17 individual route buttons on the control panel, with a reset button also. The function of this button is to clear the set route, freeing up that routes resources to be used in another route. The idea is to ultimately have two operators, each with their own reset button so only their route is cleared. This is especially useful should an operator make a mistake as it has no effect on the other operator.
Using the shiftIn function, it will be necessary to first read the state of each route button to determine which route is being requested, before running through the required resources for the route to check for route conflict, required turnout position and then using the shiftOut function to switch the required point motors etc. then checking that each turnout on the route has correctly switched, confirming the route before moving onto the next procedure (track feeds, signals, mimic diagram LEDs) and so on.
I have attached a spreadsheet containing the requirements for each individual route (just turnouts). The routes with number 1 and 2 in parenthesis indicate two paths for that particular route; the routes numbered 1 will be requested and if unavailable, the 2nd option requested.
Any help in helping me understand the coding requirements and how to go about this is much appreciated.
Route Setting.pdf (43.4 KB)