Maker Pro
Maker Pro

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

OK, the state change table probably needs to be explained a bit more.

All we're considering is the starting state, and the conditions which cause the state to change (and obviously to what state you change).

Let's start with your list of states and their names:

Code:
State | Designated name
======+===========================
  0   | Default (DEF)
  1   | Down Train Awaiting Dispatch (DTAD)
  2   | Down Train Accepted (DTA)
  3   | Ready Next Service (RNS)
And I've given them some abbreviations so I don't have to type out the full name :)

I've also placed them in numerical order because I like it that way.

So now we create a table that tells us when we're in each state, how do we get to another

Code:
This  | Next  |
State | State | Action
======+=======+====================
 DEF  |  DTAD | BtnA1Edge == true
------+-------+--------------------
 DTAD |  DTA  | BtnB2Edge == true
      |  RNS  | BtnB2Edge == true
------+-------+--------------------
 DTA  |  DTAD | BtnA1Edge == true
      |  RNS  | BtnB2Edge == true
------+-------+--------------------
 RNS  |  DTA  | BtnB2Edge == true
      |  DTAD | BtnA1Edge == true

So we concentrate ONLY on what takes us from one state to the next.

And that translates directly into the stateChange function which has a switch statement for the current case (switch (iState) {...}) that has a case for each of the states in the first column.

Within each of these cases (Case X: ... break;) we test for the actions in turn, and if we find we have one then we call machineState to set the value in the Next State column.

I'M SCRATCHING MY HEAD WITH THIS TABLE (lower one)

Whilst i accept that from DEF to DTAD requires btnA1Edge == true;

DTAD to DTA should require btnB1Edge == true; (not btnB2Edge)
DTAD to RNS is an invalid command.... skipping a step ??

DTA to DTAD is also invalid.... backward move not allowed
DTA to RNS should require btnB2Edge == true;

RNS to DTA invalid backward move
RNS to DTAD requires btnA1Edge == true;

Can you explain why those marked invalid have been included as i cant see why
 
Last edited:
Are you saying that to get from

DTAD to RNS the code needs to know that btnA1Edge, btnB1Edge and btnB2Edge should all be true (if the correct sequence is pressed and you go via DTA that will be true)
 
Code:
//   void function setState - This code will allow you to set a variable to a particular value and record when the variable's value changed

  void function setStateB(bool &bState, long &lTime, bool bValue) { // setStateB -
    if (bState != bValue) { // if bState has changed
      bState = bValue; // Update bState to bValue
      lTime = millis(); // Set time to now
 //   bChanged = true; // bChange is true register a State Change
    }
  }
  
  void function setStateI(int &iState, long &lTime, int iValue) {// setStateI - 
    if (iState != iValue) { // if iState has changed
      iState = iValue; // Update iState to iValue
      lTime = millis(); // Set time to now
//      bChanged = true; // bChange is true register a State Change
    }
  }

Also where does this piece of code fit into that sequence Gathering Data
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
I'M SCRATCHING MY HEAD WITH THIS TABLE

Can you explain why those marked invalid have been included as i cant see why

As you should be. I am not exactly familiar with what these thing mean, and I have just had to make stuff up. The transition I marked as invalid was an example (it may well be totally valid)

We are getting into the area where we are describing the "business logic" and that is an area where you are the expert, not me. I can give examples saying "if the rules were this, then you would make a table like that.

So what you need to do is take my example, then replicate it with the correct content.

In this respect, you're the expert, and you're teaching me.

Are you saying that to get from

DTAD to RNS the code needs to know that btnA1Edge, btnB1Edge and btnB2Edge should all be true (if the correct sequence is pressed and you go via DTA that will be true)

if you're talking about this table:

Code:
This  | Next  |
State | State | Action
======+=======+====================
 DEF  |  DTAD | BtnA1Edge == true
------+-------+--------------------
 DTAD |  DTA  | BtnB2Edge == true
      |  RNS  | BtnB2Edge == true
------+-------+--------------------
 DTA  |  DTAD | BtnA1Edge == true
      |  RNS  | BtnB2Edge == true
------+-------+--------------------
 RNS  |  DTA  | BtnB2Edge == true
      |  DTAD | BtnA1Edge == true
then to get from DTAD to RNS you look at the section dealing with the DTAD state:

Code:
This  | Next  |
State | State | Action
======+=======+====================
 DTAD |  DTA  | BtnB2Edge == true
      |  RNS  | BtnB2Edge == true
edit: Note that this part of the table MUST be wrong since the same condition is used to define the condition required to advance to more than one state. One of these must be other than "BtnB2Edge == true"

And specifically at the second row, which tells you how to get to RNS from there

Code:
This  | Next  |
State | State | Action
======+=======+====================
 DTAD |  RNS  | BtnB2Edge == true
And this tells you that BtnB2Edge being true is the condition which causes that.

Also where does this piece of code fit into that sequence Gathering Data

Those are the definition of two functions that we use for setting states.

As you recall from much nearer the start of the thread, we use functions insead of duplicating code everywhere we want to perform a common function. This simplifies our code by removing fine and repeating detail.

These functions need to be in your code somewhere, I tend to place them at the top of the code somewhere before I use them, but the C++ compiler allows you to put them pretty much anywhere.

If you don't actually use them you need not include them. And speaking of the word "include", that is a keyword to the compiler wich allows you to place these declarations elsewhere, but I'd prefer not to get into that at this stage.
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
In this respect, you're the expert, and you're teaching me.

Actually, what is of fundamental importance here is that we have described how this signalling must operate in a way that you would probably have understood right back at the beginning of this process. (To make that really true, the conditions might need to be expressed as "Press green button", "Actuate reaction control lever", but you understand what BtnB2Edge means)

And hopefully you can see how we take that table and turn it into code with very little change -- and therefore very little chance of getting it wrong.

So now this places you at the point where you can take your expert knowledge of how the train system is supposed to operate, describe it using a table of this form, and then create a C program that will follow those rules.

The next point is to have someone else be the expert, and then you can turn their dreams into reality. (perhaps I am employing too much hyperbole here).
 
Hi Steve,

Actually i don't see, which is why I'm struggling and trying to understand your posts. At the end of the day i guess i've bitten off more than i can chew and as I'm no expert i guess the dream may just fade and i will wake up and realize that i don't have the expertise to make it happen.

The last few weeks have been a struggle BUT i have to Thank You for the time you have spent trying your best to make me understand. Sorry i failed you

Best Wishes

Mark
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
i guess the dream may just fade

Don't give up now! You're --> <-- that close!

Perhaps we can start from the other end. I'll get you to guide me through the rules, then I'll show you how the code is written (so we'll go the other way). Even if you don't think you can do it for yourself next time, you should be somewhat familiar with everything I do.

So how about I do the system's analyst thing and ask you all the questions I would if I were totally unaware of what was going on (and really, I've not concentrated on actually understanding what the real rules are).

So, how about you answer the following questions:

1) Can you give a 1 paragraph overview of what this project is about (e.g. This project is to control a set of signals which govern the entry of a train into a segment of track.)

2) Can you describe what each of the inputs and outputs are (give some name to each switch or other input signal, and for each output) and tell me what sort input/output it is (could be as simple as red light on/off, or a momentary contact switch, or as complex as a PWM output, or sensing an analog voltage input -- I believe all yours are simple) e.g input 1 "Train sensed on line" (TSL) momentary contact switch, and output 1 "Danger signal" Red LED on/off/flashing.

3) Then we'll talk about states and transitions, bit let's just start with 1 and 2.
 
Hi Steve, not quitting just conscious of your time i'm burning up

1) Can you give a 1 paragraph overview of what this project is about (e.g. This project is to control a set of signals which govern the entry of a train into a segment of track.)

Project Overview: (Sequence Control Down Line Only )

The project is to communicate between operators, the correct sequence of events leading up to the dispatch of a train from one control section to the next control section on an exhibition layout. Each operator will have a “Sequence Control Panel” at his/her operating station, it will house the necessary inputs and outputs clearly labelled with a Statement as to the action it controls. Each Input will control 2 LEDs, one on each sequence control panel. The convention used on these Outputs will be SOLID to indicate “statement selected (button pressed) and FLASHING to indicate “user intervention required” (do something else then press a different button).

Can you describe what each of the inputs and outputs are (give some name to each switch or other input signal, and for each output) and tell me what sort input/output it is (could be as simple as red light on/off, or a momentary contact switch, or as complex as a PWM output, or sensing an analog voltage input -- I believe all yours are simple) e.g input 1 "Train sensed on line" (TSL) momentary contact switch, and output 1 "Danger signal" Red LED on/off/flashing.

All inputs are MO pushbuttons
All outputs are LEDs

There are 3 Sequence Control Panels:

1. London Fiddle Yard [LFY]
2. Eridge Main [ERM]
3.Country Fiddle Yard [CFY]

Slow Stopping Services


[LFY] Input 1 "Train Awaiting Dispatch" [ TAD ] MO Pushbutton On/Off
[LFY] Output 1 "Train Awaiting Dispatch" Amber On/Off LED
[ERM] Output 1 "Train Awaiting Acceptance" Amber Flashing LED


[ERM] Input 2 "Train Accepted" [ TA ] MO Pushbutton On/Off
[ERM] Output 2 "Train Accepted" Green On/Off LED
[LFY] Output 2 "Train Accepted" Green On/Off LED


[ERM] Input 3 "Ready Next Service" [ RNS ] MO Pushbutton On/Off
[ERM] Output 3 "Ready Next Sevice" Red On/Off LED
[LFY] Output 3 "Awaiting Next Service" Red Flashing LED


Fast non-Stopping Services

[LFY] Input 4 "Fast Down Ready Dispatch" [ FDRD] MO Pushbutton On/Off
[LFY] Output 4 "Fast Down Ready Dispatch" Amber On/Off LED
[ERM] Output 4 "Fast Down Ready Dispatch" Amber Flashing LED
[CFY] Output 4 Fast Down Ready Dispatch" Amber On/Off LED


[ERM] Input 5 "Route Set" [ RS ] MO Pushbutton On/Off
[ERM] Output 4 Change "Fast Down Ready Dispatch" Amber Flashing LED to On/Off
[CFY] Output 4 Change "Fast Down Ready Dispatch" Amber On/Off LED to Flashing
[LFY] Output 4 UnChanged "Fast Down Ready Dispatch" Amber On/Off LED


[CFY] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off
[CFY] Output 6 "Accept Fast Down" 5x LED Chase Array
[ERM] Output 6 "Accept Fast Down" 5x LED Chase Array
[LFY] Output 6 "Accept Fast Down" 5x LED Chase Array

Note: I have only discussed from London Fiddle Yard [LFY] to Eridge Main [ERM] on Down Slow Trains.... essentially the receiver of the trains at [ERM] will then become the dispatcher of them to [CFY]. So Actually there are 4 Sequence Panels, the 4th being Country End Eridge Main and Eridge Main becomes London End Eridge Main.. As part of the Fast Sequence includes the Country Fiddle Yard i have had to include that function in the above statement.

If you want the complete works i can do that including Up line Operations... although i hope to be able to achieve this myself God willing
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Let's deal with just this at the moment, and considering the time I have, I might even take only part of the task. I'll have to leave a response for when I can give you a couple of hours of my time.

(I'll be back) :D
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Hi Steve, not quitting just conscious of your time i'm burning up

Don't worry about that. This is really interesting for me.

Project Overview: (Sequence Control Down Line Only )

The project is to communicate between operators, the correct sequence of events leading up to the dispatch of a train from one control section to the next control section on an exhibition layout. Each operator will have a “Sequence Control Panel” at his/her operating station, it will house the necessary inputs and outputs clearly labelled with a Statement as to the action it controls. Each Input will control 2 LEDs, one on each sequence control panel. The convention used on these Outputs will be SOLID to indicate “statement selected (button pressed) and FLASHING to indicate “user intervention required” (do something else then press a different button).
OK, so we have three ostensibly independent panels, each with an operator. The outputs inform him of the status. He has some unspecified tasks to perform, and he presses buttons to indicate a change in status. These states are communicated in part (or whole) to other operators vie the outputs (lights) on their panels.

All inputs are MO pushbuttons
All outputs are LEDs
And in addition, some lights have three states, on, off, and flashing. Others are "chase lights", but since they're either chasing or they're not, we can say they are on or off. The colour of the lights has little relevance to the process, but probably a lot more to the operator, so I won't drop that off the descriptions.

There are 3 Sequence Control Panels:
And what I've done is group all the inputs and outputs together so I can see what is on these panels.

1. London Fiddle Yard [LFY]
[LFY_I_TAD] Input 1 "Train Awaiting Dispatch" [ TAD ] MO Pushbutton On/Off
[LFY_I_FDRD] Input 4 "Fast Down Ready Dispatch" [ FDRD] MO Pushbutton On/Off
[LFY_O_TAD] Output 1 "Train Awaiting Dispatch" Amber On/Off LED
[LFY_O_TA] Output 2 "Train Accepted" Green On/Off LED
[LFY_O_ANS*] Output 3 "Awaiting Next Service" Red Flashing LED
[LFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off LED
[LFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array

2. Eridge Main [ERM]
[ERM_I_TA] Input 2 "Train Accepted" [ TA ] MO Pushbutton On/Off
[ERM_I_RNS] Input 3 "Ready Next Service" [ RNS ] MO Pushbutton On/Off
[ERM_I_RS] Input 5 "Route Set" [ RS ] MO Pushbutton On/Off
[ERM_O_TAA] Output 1 "Train Awaiting Acceptance" Amber Flashing LED
[ERM_O_TA] Output 2 "Train Accepted" Green On/Off LED
[ERM_O_RNS] Output 3 "Ready Next Sevice" Red On/Off LED
[ERM_O_FDRD*] Output 4 "Fast Down Ready Dispatch" Amber Flashing LED (on/off/flashing)
[ERM_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array

3.Country Fiddle Yard [CFY]
[CFY_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off
[CFY_O_FDRD*] Output 4 Fast Down Ready Dispatch" Amber On/Off/flashing LED
[CFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array

As you can see, I've grouped them all together and named each input and output with something that should make sense to you essentially it's {yard}-{direction}-{abbr}

Note that some outputs have a "*". I have named them that because these have 3 states. They're not just on or off, but they can also be flashing.

It would be wise for you to review my understanding.

It would also be a good idea to ensure we have all the inputs and outputs defined correctly. If an output has just 2 states (off or flashing) it need not have that * at the end. If it has 3 states (on, off, and flashing) it does need it. Similarly, if there were two types of flashing we would need to allow for extra values for that too.

Note: I have only discussed from London Fiddle Yard [LFY] to Eridge Main [ERM] on Down Slow Trains.... essentially the receiver of the trains at [ERM] will then become the dispatcher of them to [CFY]. So Actually there are 4 Sequence Panels, the 4th being Country End Eridge Main and Eridge Main becomes London End Eridge Main.. As part of the Fast Sequence includes the Country Fiddle Yard i have had to include that function in the above statement.

OK, so that means there is more complexity to come, and that is very useful information because it means we need to plan for something that we need to expand.

If you want the complete works i can do that including Up line Operations... although i hope to be able to achieve this myself God willing
Not yet :)

Next there are some things you might be able to point out for me.

1) are any of the indicators on panels duplicated. For example, does the [LFY_O_FDRD] LED on the LFY panel also appear on the CFY panel? And if it does, is it called the same thing?

2) Are these outputs mapped to signal lights on the track? Or is there some more complexity there?

What we have to consider (and I won't do it right now) is whether each panel is a separate state machine, or if there is one overall state machine. I am leaning toward the former (for a number of reasons including that it is probably the most extensible), but I won't come to a decision until after I have seen the states and state transitions.

3) If I have the inputs and outputs correct, then perhaps we can start with what appears to be the simplest panel (CFY) and the states it can be in. Perhaps you can start by giving me an overview of what the operator at the CFY does. What conditions does he watch for, what other task does he perform (in brief), and then what does he do on the panel, and finally, how does the panel change.

It might be as simple as: The [CFY_O_FDRD] and [CFY_O_AFD] are normally off. When it starts to flash, the operator ensures the track is clear and presses [CFY_I_AFD]. At this point the [CFY_O_FDRD] changes to solid ON and the [CFY_O_AFD] lights turn on. After the Train is clear, the [CFY_O_AFD] stops and the operator presses [CFY_I_AFD] to turn [CFY_O_FDRD] off.

(I'll assume that is all wrong :)) Note that the description I have given has some mysterious input "train is clear" which we would need to get from somewhere. Also note that it gives me a description of a default, or starting state.

From that description we'll start work on the states and transitions for the [CFY]

Sorry I didn't get back to you earlier.
 
And what I've done is group all the inputs and outputs together so I can see what is on these panels.

I have amended the function in the fast train routine as i got it wrong :eek:.
Amendment highlighted


1. London Fiddle Yard [LFY]

[LFY_I_TAD] Input 1 "Train Awaiting Dispatch" [ TAD ] MO Pushbutton On/Off
[LFY_I_FDRD] Input 4 "Fast Down Ready Dispatch" [ FDRD] MO Pushbutton On/Off
[LFY_O_TAD] Output 1 "Train Awaiting Dispatch" Amber On/Off LED
[LFY_O_TA] Output 2 "Train Accepted" Green On/Off LED
[LFY_O_ANS] Output 3 "Awaiting Next Service" Red Flashing LED
[LFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off LED (removed 3 state led)
[LFY_O_FRS] Output 5 "Fast Route Set" Green On/Off LED
[LFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array


2. Eridge Main [ERM]

[ERM_I_TA] Input 2 "Train Accepted" [ TA ] MO Pushbutton On/Off
[ERM_I_RNS] Input 3 "Ready Next Service" [ RNS ] MO Pushbutton On/Off
[ERM_I_RS] Input 5 "Route Set" [ RS ] MO Pushbutton On/Off
[ERM_O_TAA] Output 1 "Train Awaiting Acceptance" Amber Flashing LED
[ERM_O_TA] Output 2 "Train Accepted" Green On/Off LED
[ERM_O_RNS] Output 3 "Ready Next Sevice" Red On/Off LED
[ERM_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber Flashing LED (removed 3 state led)
[ERM_O_FRS] Output 5 "Fast Route Set" Green On/Off LED
[ERM_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array

Mock Sequence Panels.jpg


3.Country Fiddle Yard [CFY]

[CFY_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off
[CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off (removed 3 state led)
[CFY_O_FRS] Output 5 "Fast Route Set" Green Flashing LED
[CFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array



As you can see, I've grouped them all together and named each input and output with something that should make sense to you essentially it's {yard}-{direction}-{abbr}

Yup that all makes sense :)

Note that some outputs have a "*". I have named them that because these have 3 states. They're not just on or off, but they can also be flashing.

It would also be a good idea to ensure we have all the inputs and outputs defined correctly. If an output has just 2 states (off or flashing) it need not have that * at the end. If it has 3 states (on, off, and flashing) it does need it. Similarly, if there were two types of flashing we would need to allow for extra values for that too.

Due to amendment the above is no longer required
 
Next there are some things you might be able to point out for me.

1) are any of the indicators on panels duplicated. For example, does the [LFY_O_FDRD] LED on the LFY panel also appear on the CFY panel? And if it does, is it called the same thing?

Yes and No... for the purpose of this part of the project No. See below 2 for more detailed explanation.


2) Are these outputs mapped to signal lights on the track? Or is there some more complexity there?

No this will be a seperate function with no links to future projects

What we have to consider (and I won't do it right now) is whether each panel is a separate state machine, or if there is one overall state machine. I am leaning toward the former (for a number of reasons including that it is probably the most extensible), but I won't come to a decision until after I have seen the states and state transitions.

Sequence Panel Layout1.jpg

This may help you decide. Essential Each Box is a Sequence Control Panel. Fast trains dispatched from [LFY] are sequenced by all 3 operators but the actual train is controlled by [CFY]... Convention is ALL trains will be driven towards the operator...never away from the operator.

So the Sequence Panel for [ERM] in relation to Fast Train Services on the Down Line will be the first panel the train would meet [ERM]( upper Left Hand Panel) has the sequence controls on it, Similarly for the UP Fast this would be the [ERM](lower Right Hand Panel).

If you go back to the Mock Panel Pictures you will note that the buttons precede the lights and that also is designed into the equation to indicate the direction of travel. On the LFY UP Sequence Panel the buttons will be where the leds are on the Mock Up Panel and vise versa with the leds.

Slow Trains However from [LFY] will be only sequenced by [LFY] and [ERM], [ERM] driving the train. When it reaches the station...[ERM will become the dispatcher and [CFY] the reciever.. so the [ERM](upper right sequence panel) will have the controls to set that sequence ( actually a duplicate of those shown on London End Mock Up excluding Fast Service) and [CFY] panel will include those shown on Main [ERM Mock Up for slow trains and those discussed in this Narrative.

Track Diagram with Sequence - 4 corner call 1.jpg
 
3) If I have the inputs and outputs correct, then perhaps we can start with what appears to be the simplest panel (CFY) and the states it can be in. Perhaps you can start by giving me an overview of what the operator at the CFY does. What conditions does he watch for, what other task does he perform (in brief), and then what does he do on the panel, and finally, how does the panel change.

[CFY] OPERATOR AND PANEL FUNCTIONS - FAST TRAINS

[CFY_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off
[CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off
[CFY_O_FRS] Output 5 "Fast Route Set" Green Flashing LED
[CFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array

1. [CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off Set to On
(by [LFY] operator)

2. Action: Install Empty Cassette to Track (photo)
([CFY_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off will not work)

Cassette.jpg
removable cassette used at both ends of layout [LFY] and [CFY]

3. [CFY_O_FRS] Output 5 "Fast Route Set" Green Flashing LED - Set to Flashing (by [ERM] operator.)
[CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber - Set On (No Change from step1)
Action: Confirm Cassette In Place.
Action: (Set DCC controller Chip Number)
Action: Button Press [CFY_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton ON
Result: [CFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array On
Result: Cancels [CFY_O_FRS] Output 5 "Fast Route Set" Green Flashing LED - Set to OFF
Result Cancels [CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off Set to OFF

4. Drive the train to his location....Ending Sequence.

That about sums it up
As Alwayss forever in your debt :D
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
I have amended the function in the fast train routine as i got it wrong .

Excellent!

[LFY_I_TAD] Input 1 "Train Awaiting Dispatch" [ TAD ] MO Pushbutton On/Off
[LFY_I_FDRD] Input 4 "Fast Down Ready Dispatch" [ FDRD] MO Pushbutton On/Off
[LFY_O_TAD] Output 1 "Train Awaiting Dispatch" Amber On/Off LED
[LFY_O_TA] Output 2 "Train Accepted" Green On/Off LED
[LFY_O_ANS] Output 3 "Awaiting Next Service" Red Flashing LED
[LFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off LED (removed 3 state led)
[LFY_O_FRS] Output 5 "Fast Route Set" Green On/Off LED
[LFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array
Let's look at this one in particular, especially in conjunction with the two panels you've shown me.

10071d1382097179-arduino-control-model-train-signalling-led-power-supply-control-panel-mock-sequence-panels.jpg


It looks to me that these inputs and outputs correspons with the left panel (aside from some slight changes in tense etc.)

Due to amendment the above is no longer required
So all the outputs are either on or off, where in some cases "on" can be defined as flashing or chasing or whatever.

Yes and No... for the purpose of this part of the project No. See below 2 for more detailed explanation.

I'll take "No" :)

No this will be a seperate function with no links to future projects
OK (neither good nor bad, but good to know :))

This may help you decide.
10072d1382098788-arduino-control-model-train-signalling-led-power-supply-control-panel-sequence-panel-layout1.jpg


(And now I have to learn your terminology :D)

Tell me if I have this right (and this is where you get to make me look stupid :D)

Essential Each Box is a Sequence Control Panel. Fast trains dispatched from [LFY] are sequenced by all 3 operators but the actual train is controlled by [CFY]... Convention is ALL trains will be driven towards the operator...never away from the operator.
The "Up line" and the "Down line" are the a pair of sections of track that can be operated independently of each other

The boxes (one is labelled "London end down fiddle yard [LFY]" represent control panels.

There are 8 control panels (4 for each line)

The control panels indicate what is happening on a non-overlapping section of track??

"Dispatched" means "sent/leave with authority from". So "Fast trains dispatched from" means "fast trains departing with authorisation from"

A "Fast Train" is one that has clearance in advance to pass through all sections of track?

"Driven towards the operator" means what? That the operator at the point of departure gives authority for the train to pass the section of track between them and the next operator (who must first accept the train?)

It seems that we need to split [LFY-...] and [CFY-...] into [LFY-D-...] [LFY-U-...], [CFY-D-...], and [CFY-U-...] to represent these 4 panels. Would it be correct to say that the functions of the Country Fiddle Yard Up panel are very similar to that of the London End Down Fiddle Yard? Both ate the origin of services on their line passing through Eridge main.

When we look at [ERM-...] panels, it seems there are 4, but the ones on the same lines have the same name. If I were in the case of the down line to (for clarity) define them as Eridge Main Down Accept and Eridge Main Down Dispatch, would that make sense? So we would have [ERM-DA-...], [ERM-DD-...], [ERM-UA-...], and [ERM-UD-...]. And following this, we would probably add the extra A and D to the other control boxes above ([LFY-DD-...] [LFY-UA-...], [CFY-DA-...], and [CFY-UD-...]).

I see some symetry here (which may not exist in practice) where a given train will essentially travel from dispatch to accept, then get managed to another dispatch where the process continues. I imagine that this includes being managed so the train goes on the down line from LFY to ERM, then to CFY before returning on the up line CFY, ERM, LFY. But it might also include a train going on the down line from LFY to ERM, then returning on the Up line from ERM to LFY.

If the above is true, then I kind of see why this is seperate from signalling because here we are talking about the scheduling of trains on (presumably) longer sections of track. Signalling would be concerned with local issues like permission to cross a set of points, or enter a smaller segment of track, etc.??

So the Sequence Panel for [ERM] in relation to Fast Train Services on the Down Line will be the first panel the train would meet [ERM]( upper Left Hand Panel) has the sequence controls on it, Similarly for the UP Fast this would be the [ERM](lower Right Hand Panel).
I think you're going to have to define "the first panel the train would meet". Since the train starts at LFY, doesn't the LFY-DD panel control it here (or at least, release it) so it can drive toward the next operator (which is analagous to panel I think)?

If you go back to the Mock Panel Pictures you will note that the buttons precede the lights and that also is designed into the equation to indicate the direction of travel. On the LFY UP Sequence Panel the buttons will be where the leds are on the Mock Up Panel and vise versa with the leds.
So the placement of the inputs and ouputs is "inputs on the side the train approaches, and outputs on the side the train departs". This is not important for the software, but useful to visualise things.

Slow Trains However from [LFY] will be only sequenced by [LFY] and [ERM], [ERM] driving the train. When it reaches the station...[ERM will become the dispatcher and [CFY] the reciever.. so the [ERM](upper right sequence panel) will have the controls to set that sequence ( actually a duplicate of those shown on London End Mock Up excluding Fast Service) and [CFY] panel will include those shown on Main [ERM Mock Up for slow trains and those discussed in this Narrative.
So this is pretty much what I said earlier I think.

10074d1382100377-arduino-control-model-train-signalling-led-power-supply-control-panel-track-diagram-sequence-4-corner-call-1.jpg


This image is one I presume I don't need to understand unless I'm worried about signalling?

Presumably the points get set to allow the fast train to go straight through, and you may have a slow train at the other side of a platform or on one of the segments of track (but how that's done is not the purpose of this).

[CFY] OPERATOR AND PANEL FUNCTIONS - FAST TRAINS

[CFY_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off
[CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off
[CFY_O_FRS] Output 5 "Fast Route Set" Green Flashing LED
[CFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array

OK, those are the inputs and outputs as they appear on the CFY_DA panel. We could call them now:

[CFY_DA_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off
[CFY_DA_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off
[CFY_DA_O_FRS] Output 5 "Fast Route Set" Green Flashing LED
[CFY_DA_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array

And now you're having a go at defining states and transitions...

Let me first define an initial state.

0. The initial (or reset state) nothing is hapening.
[CFY_DA_O_FDRD] Off
[CFY_DA_O_FRS] Off
[CFY_DA_O_AFD] Off

1. [CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off Set to On
(by [LFY] operator)
OK, let's look at just the state.

1. Fast train dispatch initiated by LFY operator
[CFY_DA_O_FDRD] On
[CFY_DA_O_FRS] Off
[CFY_DA_O_AFD] Off

2. Action: Install Empty Cassette to Track (photo)
([CFY_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off will not work)
OK, I'm unsure what an empty cassette is. I'm also unsure if this is actually a state. Have any of the outputs changed? This sounds like a task which is performed before the operator initiates the next state.

3. [CFY_O_FRS] Output 5 "Fast Route Set" Green Flashing LED - Set to Flashing (by [ERM] operator.)
[CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber - Set On (No Change from step1)
Action: Confirm Cassette In Place.
Action: (Set DCC controller Chip Number)
Action: Button Press [CFY_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton ON
Result: [CFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array On
Result: Cancels [CFY_O_FRS] Output 5 "Fast Route Set" Green Flashing LED - Set to OFF
Result Cancels [CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off Set to OFF
3. Fast route accepted by ERM
[CFY_DA_O_FDRD] On
[CFY_DA_O_FRS] On
[CFY_DA_O_AFD] Off


And you've noted another state here:

3.5 Fast Train Acccepted
[CFY_DA_O_FDRD] Off
[CFY_DA_O_FRS] Off
[CFY_DA_O_AFD] On

4. Drive the train to his location....Ending Sequence.
And that sounds like an action, not a state or transition.

That about sums it up
Not quite. How do we get back to the initial state?

So now we have the following states:

0. CFY_DA_INIT The initial (or reset state) nothing is hapening.
1. CFY_DA_FDIL Fast train dispatch initiated by LFY operator
3. CFY_DA_FRAE Fast route accepted by ERM
3.5 CFY_DA_FTA Fast Train Acccepted

I've also given them names so we don't refer to numbers

Now let's look at the transitions you've told me about.

When in CFY_DA_INIT (0), on press of [LFY_DD_I_TAD] we change to CFY_DA_FDIL (1)

When in CFY_DA_FDIL (1), on press of [ERM_DD_I_RS] we change to CFY_DA_FRAE (3)

When in CFY_DA_FRAE (3), on press of [CFY_DA_I_AFD] we change to CFY_DA_FTA (3.5)

When in CFY_DA_FTA (3.5), on press of [CFY_DA_I_RNS???] we change to CFY_DA_INIT (0)

So apart from my addition of the extra state 0, and a way to get back there (Ready Next Service button on the CFY_DA panel???) this seems to describe the normal state transitions. (Oh, I also made an assumption about what the ERM operator did).

The question is, are there any other state transitions? What if someone presses [LFY_DD_I_TAD] by mistake? How is that cancelled? Do we have some simple state transition back to CFY_DA_INIT? What if the error is noted only after the ERM operator has done something (so we are in CFY_DA_FRAE), or if the ERM operator accidentally pressed [ERM_DD_I_RS] before things were set up...?

These unusual state transitions may be very important if the system is to egt itself working again after an error.

Another issue is that a button press from a remote panel may not be simply that button press. It may also require the panel to be in a certain state. For example, if the LFY_DD panel is not in a state where a fast train is ready for dispatch, pressing the [LFY_DD_I_TAD] button should not perform a state transition at the [CFY_DA] panel.

What we need to do is to add another output from LFY_DD which is the set when this button is validly pressed, or perhaps remains set for the entire duration between initiating the fast train and its final acceptance. The latter allows us to have simple reset conditions where this signal becomes invalid prior to the final acceptance of the train (and similarly for acceptance from ERM.

As Alwayss forever in your debt
No problems, Sorry I have been a bit busy this weekend to get back to you earlier.
 
The "Up line" and the "Down line" are the a pair of sections of track that can be operated independently of each other

Yes They Are.

Worth noting however they can be combined as well. There is a single train movements that cross over from the "Down Line" to the "Up Line". This originates on the [ERM] "Down Line" and crosses onto the "Up Line" to [LFY]. In this case its destination "the UP Line" will be used to control the sequence.. so no change

The boxes (one is labelled "London end down fiddle yard [LFY]" represent control panels.

There are 8 control panels (4 for each line)

The control panels indicate what is happening on a non-overlapping section of track??

Yes to All Of the Above

"Dispatched" means "sent/leave with authority from". So "Fast trains dispatched from" means "fast trains departing with authorisation from"

A "Fast Train" is one that has clearance in advance to pass through all sections of track?

Not thought of it in those terms But you hit the "nail on the head" EXACTLY CORRECT :D

"Driven towards the operator" means what? That the operator at the point of departure gives authority for the train to pass the section of track between them and the next operator (who must first accept the train?)

You need not worry about this for the purpose of this narrative... however as you have a firm grasp of the concept i will explain more..

If we look at a train movement being dispatch from [ERM] to [LFY] on the up line. Once all the Sequencing Routine is done the train has to move...There are 2 operators ( [ERM] and [LFY] ) concerned with this movement..
"Driven towards"
means [LFY] will operate the train (control its motive action from [ERM] to [CFY]) as clearly it is going away from [ERM] this is what this statement means.

It seems that we need to split [LFY-...] and [CFY-...] into [LFY-D-...] [LFY-U-...], [CFY-D-...], and [CFY-U-...] to represent these 4 panels.

Yes this is correct

Would it be correct to say that the functions of the Country Fiddle Yard Up panel are very similar to that of the London End Down Fiddle Yard?

Very Similar...
If you took the [LFY-D-] Panel as being a dispatchers {dispatch trains from this location on the down line) panel and [LFY-U-] panel as being the receivers (receives trains at this location on the up line) panel then [CFY-D-] panel will have the same functions as [LFY-U-] panel as ultimately [CFY] is the final reciever of all movements on the "Down Line".

Both are the origin of services on their line passing through Eridge main.

Not Strictly True, They are and they are not...

The reason for the "Ready Next Service" button and function is that Eridge Main could have 1 train from both fiddle yards stop at the station and then another from each direction stop in the "bay" platforms. It now has 4 trains waiting to be dispatch ( 2 in each direction) and ERM can dispatch whichever he see fit (although a timetable will be used).

Whilst they Originated from either [LFY] or [CFY] they will in the above senario deem to start their next(originate) journey from [ERM]. The only reason for this is that some trains will have a length wait at [ERM] before they continue onwards and some may only shuttle back and forth from one end of the layout to the station and back to the same end.


When we look at [ERM-...] panels, it seems there are 4, but the ones on the same lines have the same name. If I were in the case of the down line to (for clarity) define them as Eridge Main Down Accept and Eridge Main Down Dispatch, would that make sense? So we would have [ERM-DA-...], [ERM-DD-...], [ERM-UA-...], and [ERM-UD-...]. And following this, we would probably add the extra A and D to the other control boxes above ([LFY-DD-...] [LFY-UA-...], [CFY-DA-...], and [CFY-UD-...]).

Yes, I had another name for each of the 4 [ERM] panels in mind but i didn't want to confuse you on this BUT you have developed a strong grasp of the concepts within a short time..

It makes sense to do this if we look at the entire "Sequence Control Panel " Concept.
Although it makes little odds what you call the panels here in relation to how the interface panel is actually labellled i cant help but think if the 2 married up it would help trace any faults.

I have pondered this only because on fast train movements [ERM] doesn't accept (control) of the train...however on deep contemplation [ERM] does accept authority to allow movement and so...

I'm happy to Roll with your Idea

THANKYOU :D

I see some symetry here (which may not exist in practice) where a given train will essentially travel from dispatch to accept, then get managed to another dispatch where the process continues. I imagine that this includes being managed so the train goes on the down line from LFY to ERM, then to CFY before returning on the up line CFY, ERM, LFY. But it might also include a train going on the down line from LFY to ERM, then returning on the Up line from ERM to LFY.

YOU GOT IT :D

If the above is true, then I kind of see why this is seperate from signalling because here we are talking about the scheduling of trains on (presumably) longer sections of track. Signalling would be concerned with local issues like permission to cross a set of points, or enter a smaller segment of track, etc.??

Oh Man You're On a Roll YEAH :D
 
Last edited:
Presumably the points get set to allow the fast train to go straight through, and you may have a slow train at the other side of a platform or on one of the segments of track (but how that's done is not the purpose of this).

Correct...that's part of signalling control not sequencing. It forms an Action taken by an operator prior to pressing a sequence button.

Originally Posted by P4 Modeller View Post
[CFY] OPERATOR AND PANEL FUNCTIONS - FAST TRAINS

[CFY_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off
[CFY_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off
[CFY_O_FRS] Output 5 "Fast Route Set" Green Flashing LED
[CFY_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array
OK, those are the inputs and outputs as they appear on the CFY_DA panel. We could call them now:

[CFY_DA_I_AFD] Input 6 "Accept Fast Down" [ AFD ] MO pushbutton On/Off
[CFY_DA_O_FDRD] Output 4 "Fast Down Ready Dispatch" Amber On/Off
[CFY_DA_O_FRS] Output 5 "Fast Route Set" Green Flashing LED
[CFY_DA_O_AFD] Output 6 "Accept Fast Down" 5x LED Chase Array

Understood :)

And now you're having a go at defining states and transitions...

Let me first define an initial state.

0. The initial (or reset state) nothing is hapening.
[CFY_DA_O_FDRD] Off
[CFY_DA_O_FRS] Off
[CFY_DA_O_AFD] Off

Yes looks good

1. Fast train dispatch initiated by LFY operator
[CFY_DA_O_FDRD] On
[CFY_DA_O_FRS] Off
[CFY_DA_O_AFD] Off

Yes

OK, I'm unsure what an empty cassette is. I'm also unsure if this is actually a state. Have any of the outputs changed? This sounds like a task which is performed before the operator initiates the next state.

Yes task preformed by operator but makes me think "microswitch" sensing cassette in place.. to stop train driving off rail.

FYI Cassette is a removable piece of rail, that can be aligned to track and then when train driven onto this cassette it can be removed and rotated 180 degrees (turning the train for next departure) and stored on a seperate shelf until needed ;)

3. Fast route accepted by ERM
[CFY_DA_O_FDRD] On
[CFY_DA_O_FRS] On
[CFY_DA_O_AFD] Off


And you've noted another state here:

3.5 Fast Train Acccepted
[CFY_DA_O_FDRD] Off
[CFY_DA_O_FRS] Off
[CFY_DA_O_AFD] On

Correct

Quote:
That about sums it up

Not quite. How do we get back to the initial state?

See Below

So now we have the following states:

0. CFY_DA_INIT The initial (or reset state) nothing is hapening.
1. CFY_DA_FDIL Fast train dispatch initiated by LFY operator
3. CFY_DA_FRAE Fast route accepted by ERM
3.5 CFY_DA_FTA Fast Train Acccepted

State 3: CFY_DA_FRAE should this not be CFY_DA_FRSE Fast route "SET" by ERM as it relates to the button pressed. [FRS]

Oops hang on i see your logic... because Fast Route set button has been pressed the state that [CFY] will be in is Fast Route Accepted by ERM... so ignore this


Now let's look at the transitions you've told me about.

When in CFY_DA_INIT (0), on press of [LFY_DD_I_TAD] we change to CFY_DA_FDIL (1)

When in CFY_DA_FDIL (1), on press of [ERM_DD_I_RS] we change to CFY_DA_FRAE (3)

When in CFY_DA_FRAE (3), on press of [CFY_DA_I_AFD] we change to CFY_DA_FTA (3.5)

When in CFY_DA_FTA (3.5), on press of [CFY_DA_I_RNS???] we change to CFY_DA_INIT (0)

No Not quite:

When in CFY_DA_INIT (0), on press of [LFY_DD_I_TAD] we change to CFY_DA_FDIL (1)

When in CFY_DA_INIT (0), on press of [LFY_DD_I_FRD] (Fast Ready Dispatch) we change to CFY_DA_FDIL.

When in CFY_DA_FDIL (1), on press of [ERM_DD_I_RS] we change to CFY_DA_FRAE (3)

When in CFY_DA_FRAE (3), on press of [CFY_DA_I_AFD] we change to CFY_DA_FTA (3.5)


Actually NO but i will make a seperate post later think names are getting mixed up

When in CFY_DA_FTA (3.5), on press of [CFY_DA_I_RNS???] we change to CFY_DA_INIT (0)

Ahead of the game and very correct :D no pulling the wool over your eyes
 
Last edited:
The question is, are there any other state transitions? What if someone presses [LFY_DD_I_TAD] by mistake? How is that cancelled? Do we have some simple state transition back to CFY_DA_INIT? What if the error is noted only after the ERM operator has done something (so we are in CFY_DA_FRAE), or if the ERM operator accidentally pressed [ERM_DD_I_RS] before things were set up...?

The Plan was to only have 1 button in the "unlocked" state so that the sequence was followed correctly. So in the FAST DOWN TRAIN Routine all the "SLOW DOWN" buttons would be "locked out" until [CFY_DA_I_RNS] was pressed.

The problem is to consider these states

0. CFY_DA_INIT The initial (or reset state) nothing is hapening.
1. CFY_DA_FDIL Fast train dispatch initiated by LFY operator
3. CFY_DA_FRAE Fast route accepted by ERM
3.5 CFY_DA_FTA Fast Train Acccepted

You will need to consider the "Slow Train" States between [ERM] and [CFY] on both panels to include this "button locked out" feature as well as those on {LFY_DD_PANEL] and [ ERM_DA_PANEL]


These unusual state transitions may be very important if the system is to egt itself working again after an error.

Another issue is that a button press from a remote panel may not be simply that button press. It may also require the panel to be in a certain state. For example, if the LFY_DD panel is not in a state where a fast train is ready for dispatch, pressing the [LFY_DD_I_TAD] button should not perform a state transition at the [CFY_DA] panel.

What we need to do is to add another output from LFY_DD which is the set when this button is validly pressed, or perhaps remains set for the entire duration between initiating the fast train and its final acceptance. The latter allows us to have simple reset conditions where this signal becomes invalid prior to the final acceptance of the train (and similarly for acceptance from ERM.

Yes i understand this... Also it may be advisable for me to include a "master reset" button on each panel to provide for noticing something is wrong after the input has been made....."Though in the letter of the law, this is Gross Miss Conduct and after an investigation has been carried out could lead to instant dismissal or revoking operating license on Eridge P4 Model Layout....has been known to happen on other exhibition layouts !!" lmao
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
But you hit the "nail on the head" EXACTLY CORRECT :D
Yes this is correct
YOU GOT IT :D
Yes looks good
Yes
Correct
Ahead of the game and very correct :D no pulling the wool over your eyes

OK, you're probably starting to see what my day job is :-D

I tend to describe it as "Learning enough of people's jobs that I have a thin veneer over the surface." I try never to kid myself that I actually do understand. I'm just a very effective parrot.

So don't relax. Keep your eye out because if I make a mistake, I'm not going to know.

The Plan was to only have 1 button in the "unlocked" state so that the sequence was followed correctly. So in the FAST DOWN TRAIN Routine all the "SLOW DOWN" buttons would be "locked out" until [CFY_DA_I_RNS] was pressed.

Yes, that's generally a very good idea. It produces a nice clean set of states with simple transitions. In terms of what the operator has to do, it means they very rarely have to make a choice of one of two (or more) things to do.

The problem is to consider these states

You will need to consider the "Slow Train" States between [ERM] and [CFY] on both panels to include this "button locked out" feature as well as those on {LFY_DD_PANEL] and [ ERM_DA_PANEL]

Yes, you have spotted *exactly* where we need to work.

I expect that each control panel is it's own state machine and all I hear from you confirms this. It will probably mean a fairly simple set of states and transitions for each.

Yes i understand this... Also it may be advisable for me to include a "master reset" button on each panel to provide for noticing something is wrong after the input has been made....."Though in the letter of the law, this is Gross Miss Conduct and after an investigation has been carried out could lead to instant dismissal or revoking operating license on Eridge P4 Model Layout....has been known to happen on other exhibition layouts !!" lmao

In real life, there's going to be a lot more complexity. In a model layout it's probably advisable to have some simple (and perhaps slightly manual) way to reset things.

This is often called the BRS...

Big

Red

Switch

(Hahahaha)

In your case, perhaps all it needs to do is cycle the power. The state machine will reset to the init state.

Another more complex way is to have a button press that allows you to go to any state. It typically enters a special state which has transitions to all other states. But we can think about that later. Perhaps it is initiated by another button hidden somewhere that you can add later if you need to...

Maybe we can talk more about the slow train stuff and how it impacts the CFY_DA panel.

Start with slow train states and transitions on their own. Then later we can talk about how fast and slow trains do (or perhaps don't) interact.
 
In the Interest of Continuity

Hi Steve

In the interest of continuity i have produced a complete Arduino Identifier for the functions of the "Sequence Panel" adopting your method of identification

Hopefully this will put us both on the same page even if i cant upload the document :mad:

Arduino Identifiers Sequence Control1.jpg

Arduino Identifiers Sequence Control2.jpg

Arduino Identifiers Sequence Control3.jpg

Arduino Identifiers Sequence Control4.jpg


Those are the Down Panels
 
Last edited:
Top