Trying to make a standalone signal system...

For the sake of this starter I'm gonna use these variables... Need a Lil help on where they get defined.
Sig[1]
Route[1]
Sw[1]
Bk[1]
Os[1]
Occ ...occupied
Clr..clear block
Grnred...sig indication
Redred...sig indication
Tun ...normal
Tur... Reverse
Cb[4]...codebuttons
I understand the arrays go before the setup to make them global. Would I just put the rest of them in their individual functions that they apply to or make them all global? And for like grnred or tun should I use int or const int or just bytes? I'd like to get that clear before I try.
And is there an easier way to set the signal led assignments besides
Digitalwrite(2,HIGH);
Digitalwrite(3,LOW);
And so forth? And I assume I put that in the signals function since that's the only place it's being used?

Thanx
Harrison

If I spend my time writing code that does what you want and you don't even look at it, I think I'm wasting my time with you. Goodbye!

My phone wasn't allowing me to scroll. Sorry bout that.

ok heres what i got to start with. It compiles with no errors.
I had no assinged the codebuttons to pins yet as i havent setup the circuit yet for them. I want to make sure the signal and switch show lined on the serial monitor and go from there.

byte sig[8];
byte sw[4];
byte cb[6];
byte bk[6];
byte grnred;
byte redred;
byte cancelButton = A0;
byte tun;
byte tur;
byte os1;
byte occ;
byte clr;
int route = 0;

void setup() {
Serial.begin(9600);
  sig[1] = redred;  //initially setting signal 1 to redred
  sw[1] = tun;
  
  for(int x = 0; x<13; x++){
    pinMode(x, OUTPUT);
  }
}

void loop() {




if (digitalRead(cancelButton) == HIGH) route = 0; //reset route if cancel pressed
if (route = 0) { //only do this if no route has been set
  if (digitalRead(cb[1]) == HIGH) {
    route = 10;
  }
  else if (digitalRead(cb[2]) == HIGH) {
    route = 20;
  }
  else if (digitalRead(cb[3]) == HIGH) {
    route = 30;
  }
  else if (digitalRead(cb[4]) == HIGH) {
    route = 40;
  }
  else if (digitalRead(cb[5]) == HIGH) {
    route = 50;
  }
  else if (digitalRead(cb[6]) == HIGH) {
    route = 60;
  }


}


while ((route % 10 == 0) && (route >= 9 )) { // only do this if one of the entry points has been set
  if (digitalRead(cb[4]) == HIGH) {
    route += 4;
  }  //add 4
  else if (digitalRead(cb[5]) == HIGH) {
    route += 5;  //add 5
  }
  else if (digitalRead(cb[6]) == HIGH) {
    route += 6; //add 6
  }
  else if (digitalRead(cb[1]) == HIGH) {
    route += 1; //add 6
  }
  else if (digitalRead(cb[2]) == HIGH) {
    route += 2; //add 6
  }
  else if (digitalRead(cb[3]) == HIGH) {
    route += 3; //add 6
  }
}
if (digitalRead(cancelButton) == HIGH){route = 0; //reset route if cancel pressed
}
if (analogRead(os1) == HIGH){route = 0;  //reset route if os is occupied
}

switch (route) {
case 14:

sw[1] = tun;
switches();
signals();

  break;
  
case 15:

sw[1] = tun; //set switch 1 to normal
switches(); //switch assignments
signals(); //signal assignments
sw[1] = grnred;

  break;

case 36:
switches();
signals();

  break;
}
route = 0;  // ready to set next route
}


void switches() {
  if (sw[1] = tun) {
    digitalWrite(42, HIGH);
    digitalWrite(43, LOW);
    Serial.println ("SW1 Normal");
  }
  if (sw[1] = tur) {
    digitalWrite(42, LOW);
    digitalWrite(43, HIGH);
    Serial.println ("SW1 Reverse");
  }
}
void signals() {
greenup = 0;
yellowup = 1;
redup = 2;
greenlo = 3;
yellowlo = 4;
redlo = 5;




sig[1][6];
sig[1][greenup] = 2;
  
  
  
  
 /* if (sig[1] == grnred) {
    digitalWrite(2, HIGH); //upper green
    digitalWrite(3, LOW);  //upper yellow
    digitalWrite(4, LOW);  //upper red
    digitalWrite(5, LOW);  //lower green
    digitalWrite(6, LOW);  //lower yellow
    digitalWrite(7, HIGH);  //lower red
    Serial.println(" Signal 1 Clear");
  }
  if (sig[1] == redred) {
    digitalWrite(2, LOW);  //upper green
    digitalWrite(3, LOW);  //upper yellow
    digitalWrite(4, HIGH);  //upper red
    digitalWrite(5, LOW);  //lower green
    digitalWrite(6, LOW);  //lower yellow
    digitalWrite(7, HIGH);  //lower red
    Serial.println("Signal 1 Stop");
  } */
}
void blocks() {
  byte occ;
  byte clr;
  byte os1;

  if (analogRead(13) == HIGH) {
    os1 = occ;
    Serial.println ("OS Occupied");
  }
  else
  {
    os1 = clr;
  }
  if (analogRead(10) == HIGH) {
    bk[4] = occ;
    Serial.println ("Block 1 Occupied");
  }
  else {
    bk[4] = clr;
  }
}
  void testdelay(){
    delay(2000);
  }

if (route = 0)This compiles but does not do what you want.
You need to use == to test a value as you have done correctly later in the program.

  for(int x = 0; x<13; x++){
    pinMode(x, OUTPUT);
  }

Do you really want to set pins 0 and 1 to OUTPUTs ?

if (digitalRead(cancelButton) == HIGH) route = 0; //reset route if cancel pressed
if (route = 0) { //only do this if no route has been set
  if (digitalRead(cb[1]) == HIGH) {
    route = 10;
  }

Personally I would always enclose the code block for a true if statement in braces rather than sometimes omitting them when the block has only one line of code

Thanks Harrison, I think that will help us to make big progress. I have taken a copy of your code and I will post again when I have had a good look at it.

...R

I have attempted to rework your code into a series of short functions. It compiles, but I haven't tested it. Have a look and see if you feel it has any merit as a way to organize the code. Be sure to read my comments.

I don't know how you plan to connect the coloured LEDs for each signal so I haven't been able to deal with that.

I don't know the relationship between routes and signal/switch settings so I haven't dealt with that. It may make sense to define these at the top of the program.

My objective has been to use meaningful names so that the code can be read in the way you read a story. There is no value in using abbreviated names.

Have fun ...

// http://forum.arduino.cc/index.php?topic=237805.30

// attempt 04 Jun 14 by Robin2 to reorganize code

//====global variables

const byte numSignals = 8;
const byte numTrackSwitches = 4;
const byte numCodeButtons = 6;
const byte numBlocks = 6;
const byte numSections = 3;

const byte turnoutNormal = 0;  // these are just wild guesses
const byte turnoutReversed = 1;
const byte redred = 0;
const byte grnred = 1;

// all my pin numbers are guesses - replace with correct values

byte signal[numSignals];
byte signalPin[numSignals] = {40,41,42,43,44,45,46,47};

byte trackSwitch[numTrackSwitches]; // the word switch has a special meaning
byte trackSwitchPin[numTrackSwitches] = {48,49,50,51};

byte block[numBlocks]; // guessing bk = block

byte codeButtonPin[numCodeButtons] = {22, 23, 24, 25, 26, 27};  
byte sectionPin[numSections] = {30, 31, 32}; 

byte route = 0;
byte newRoute = 0;
byte digitNum = 1; // to deal with multi-digit values
byte maxDigits = 2;


boolean cancelButton = true; // will make everything go red at the start ?
byte cancelButtonPin = A0;  // an analog pin will work as a digital pin



//==================

void setup() {
  Serial.begin(9600);
  Serial.println("Starting R2SigTest.ino"); // just so we know it is alive
  
  for(byte n = 2; n<13; n++){   // start with x = 2 to avoid the Tx and Rx pins
    pinMode(n, OUTPUT);
  }
  
  for (byte n = 0; n < numCodeButtons; n++) {
    pinMode(codeButtonPin[n], INPUT_PULLUP);
  }
  
  for (byte n = 0; n < numSections; n++) {
    pinMode(sectionPin[n], INPUT_PULLUP);
  }
  
  pinMode(cancelButtonPin, INPUT_PULLUP);

  cancelButton = true;
  respondToCancel(); // initializes settings
  
}

//==================

void loop() {
  readButtons();
  processRoute();
  setSignals();
  setTrackSwitches();

}

//==================

void readButtons(){

  cancelButton = digitalRead(cancelButtonPin);
  updateRouteNumber(); // slightly complex so give it a separate function
}

//======================

void respondToCancel() {
  if (cancelButton) {
    for (byte n = 0; n < numSignals; n++) {
      signal[n] = redred;
    }
    for (byte n = 0; n < numTrackSwitches; n++) { 
      trackSwitch[n] = turnoutNormal;
    }
    return;
  }
}

//======================

void updateRouteNumber() {
  
  // gather the digits for route
  if (digitNum == 1) {
    newRoute = 0;
  }
  for (byte n = 0; n < numCodeButtons; n ++) {
    if (digitalRead(codeButtonPin[n]) == LOW) {
      newRoute = newRoute * 10 + n;
    }
  }
  digitNum ++;
  if (digitNum > maxDigits) {
    digitNum = 1;
    route = newRoute;
  }
}

//================

void processRoute() {
  // get things ready for setSignals() etc
  switch (route) {
      case 14:
        trackSwitch[1] = turnoutNormal;
        break;
        
      case 15:
        trackSwitch[1] = turnoutNormal; //set switch 1 to normal
//        trackSwitch[1] = grnred;  // shouldn't this be a signal
        break;

      case 36:
        // ????
        break;
   }
}

//================

void setSignals() {
 // this is wrong because I don't know how each signal is wired to give different colours
 for (byte n = 0; n < numSignals; n ++) {
   digitalWrite(signalPin[n], signal[n]);
 }
}

//================

void setTrackSwitches() {
  for (byte n = 0; n < numTrackSwitches; n ++) {
   digitalWrite(trackSwitchPin[n], trackSwitch[n]);
 }
}

...R

UKHeliBob:
if (route = 0)This compiles but does not do what you want.
You need to use == to test a value as you have done correctly later in the program.
I see that now. My eyes were having a hard time staying open last nite. Thanx.

  for(int x = 0; x<13; x++){

pinMode(x, OUTPUT);
  }


Do you really want to set pins 0 and 1 to OUTPUTs ?

I just put 13 because I have the mega mounted on a 24"X24" board right now and all i had was my uno.
On the mega it will be pins 2 thru 54 as outputs and Im leaving 0 and 1 blank because i was getting false positives with them before.



if (digitalRead(cancelButton) == HIGH) route = 0; //reset route if cancel pressed
if (route = 0) { //only do this if no route has been set
  if (digitalRead(cb[1]) == HIGH) {
    route = 10;
  }



Personally I would always enclose the code block for a true if statement in braces rather than sometimes omitting them when the block has only one line of code

Robin2:
I have attempted to rework your code into a series of short functions. It compiles, but I haven't tested it. Have a look and see if you feel it has any merit as a way to organize the code. Be sure to read my comments.

I don't know how you plan to connect the coloured LEDs for each signal so I haven't been able to deal with that.
Connect them as in how? the positive leg on the led goes to the mega and the negative goes to ground.
As far as all the pin assignments I have them all written down.

I don't know the relationship between routes and signal/switch settings so I haven't dealt with that. It may make sense to define these at the top of the program.

My objective has been to use meaningful names so that the code can be read in the way you read a story. There is no value in using abbreviated names.

Have fun ...

// http://forum.arduino.cc/index.php?topic=237805.30

// attempt 04 Jun 14 by Robin2 to reorganize code

//====global variables

const byte numSignals = 8;  //Total number of signals? Instead of an array?
const byte numTrackSwitches = 4;
const byte numCodeButtons = 6;
const byte numBlocks = 6;
const byte numSections = 3;

const byte turnoutNormal = 0;  // these are just wild guesses  Turnout in normal position?
const byte turnoutReversed = 1;
const byte redred = 0;
const byte grnred = 1;

// all my pin numbers are guesses - replace with correct values

byte signal[numSignals];
byte signalPin[numSignals] = {40,41,42,43,44,45,46,47};  //all the pin numbers that the signals use?

byte trackSwitch[numTrackSwitches]; // the word switch has a special meaning
byte trackSwitchPin[numTrackSwitches] = {48,49,50,51};

byte block[numBlocks]; // guessing bk = block  //total amount of blocks?
byte codeButtonPin[numCodeButtons] = {22, 23, 24, 25, 26, 27}; 
byte sectionPin[numSections] = {30, 31, 32};

byte route = 0;
byte newRoute = 0;
byte digitNum = 1; // to deal with multi-digit values
byte maxDigits = 2;

boolean cancelButton = true; // will make everything go red at the start ?
byte cancelButtonPin = A0;  // an analog pin will work as a digital pin

//==================

void setup() {
  Serial.begin(9600);
  Serial.println("Starting R2SigTest.ino"); // just so we know it is alive
 
  for(byte n = 2; n<54; n++){   // start with x = 2 to avoid the Tx and Rx pins
    pinMode(n, OUTPUT);
  }
 
  for (byte n = 0; n < numCodeButtons; n++) {
    pinMode(codeButtonPin[n], INPUT_PULLUP);
  }
 
  for (byte n = 0; n < numSections; n++) {
    pinMode(sectionPin[n], INPUT_PULLUP);
  }
 
  pinMode(cancelButtonPin, INPUT_PULLUP);

cancelButton = true;
  respondToCancel(); // initializes settings
 
}

//==================

void loop() {
  readButtons();
  processRoute();
  setSignals();
  setTrackSwitches();

}

//==================

void readButtons(){

cancelButton = digitalRead(cancelButtonPin);
  updateRouteNumber(); // slightly complex so give it a separate function
}

//======================

void respondToCancel() {
  if (cancelButton) {
    for (byte n = 0; n < numSignals; n++) {
      signal[n] = redred;
    }
    for (byte n = 0; n < numTrackSwitches; n++) {
      trackSwitch[n] = turnoutNormal;
    }
    return;
  }
}

//======================

void updateRouteNumber() {
 
  // gather the digits for route
  if (digitNum == 1) {
    newRoute = 0;
  }
  for (byte n = 0; n < numCodeButtons; n ++) {
    if (digitalRead(codeButtonPin[n]) == LOW) {
      newRoute = newRoute * 10 + n;
    }
  }
  digitNum ++;
  if (digitNum > maxDigits) {
    digitNum = 1;
    route = newRoute;
  }
}

//================

void processRoute() {
  // get things ready for setSignals() etc
  switch (route) {
      case 14:
        trackSwitch[1] = turnoutNormal;
        break;
       
      case 15:
        trackSwitch[1] = turnoutNormal; //set switch 1 to normal
//        trackSwitch[1] = grnred;  // shouldn't this be a signal  //yes grnred and redred apply to signals only
        break;

case 36:
        // ????
        break;
   }
}

//================

void setSignals() {
// this is wrong because I don't know how each signal is wired to give different colours
for (byte n = 0; n < numSignals; n ++) {
   digitalWrite(signalPin[n], signal[n]);
}  //All of the signals leds use 1 pin per color.  // I will send you the pin layout so itll make thins easier.
}

//================

void setTrackSwitches() {
  for (byte n = 0; n < numTrackSwitches; n ++) {
   digitalWrite(trackSwitchPin[n], trackSwitch[n]);
}  //Ive been seing alot of this code.  Is this just like a one code fits all?
writing the pin the value?  So if sw1 == tun then this code?

}




...R

hbingham86:
As far as all the pin assignments I have them all written down.

I haven't seen where they are written down (or if it was in a previous post I have forgotten which one).

...R

Heres the pin assignments
Pin Description

2 Sig 1 upper green
3 upper yellow
4 upper red
5 lower green
6 lower yellow
7 lower red
8 Sig 2 upper green
9 upper yellow
10 upper red
11 lower green
12 lower yellow
13 lower red
14 Sig 6 upper green
15 upper yellow
16 upper red
17 lower green
18 lower yellow
19 lower red
20 Sig 5 upper green
21 upper yellow
22 upper red
23 lower green
24 lower yellow
25 lower red
26 Switch 1 normal
27 Switch 1 reverse
28 Switch 2 normal
29 Switch 2 reverse
30 Switch 3 normal
31 Switch 3 reverse
32 Switch 4 normal
33 Switch 5 reverse
34 Sig 7 upper green
35 upper yellow
36 upper red
37 lower green
38 lower lunar
39 Empty
40 block 1 light if (bk1 == occ) digitalWrite(40, HIGH);
41 block 2 light
42 block 3 light
43 block 4 light
44 block 5 light
45 block 6 light
46 os1 light
47 Sig 8 upper green
48 upper yellow
49 upper red
50 upper green
51 upper lunar
52 Empty
53 Empty
54 Empty

A0 cancelbutton
A1 cb1
A2 cb2
A3 cb3
A4 cb4
A5 cb5
A6 cb6
A7 os1
A8 bk1
A9 bk2
A10 bk3
A11 bk4
A12 bk5
A13 bk6
A14 ABS (if this switch is active the it bypasses the codebuttons and it controls the signal indications based upon how the switches are lined
A15

Thanks for that. I will have a look at it.

Meanwhile, how do you feel about the general approach/style of my suggested approach to your program?

...R

i think im starting to get the hang of it. i just added the signal assignments in switch cases. and thought i set signal[1] to redred in setup and it goes redred but when i change it to grnred it stays redred.

heres the updated code

// http://forum.arduino.cc/index.php?topic=237805.30

// attempt 04 Jun 14 by Robin2 to reorganize code

//====global variables

const byte numSignals = 8;
const byte numTrackSwitches = 4;
const byte numCodeButtons = 6;
const byte numBlocks = 6;
const byte numSections = 3;

const byte turnoutNormal = 0;  // these are just wild guesses
const byte turnoutReversed = 1;
const byte redred = 0;
const byte grnred = 1;

// all my pin numbers are guesses - replace with correct values

byte signal[numSignals];
byte signalPin[numSignals] = {2,3,4,5,6,7};//8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,34,35,36,37,38,47,48,49,50,51};

byte trackSwitch[numTrackSwitches]; // the word switch has a special meaning
byte trackSwitchPin[numTrackSwitches] = {26,27,28,29};

byte block[numBlocks]; // guessing bk = block

byte codeButtonPin[numCodeButtons] = {A1,A2,A3,A4,A5,A6};  
byte sectionPin[numSections] = {30, 31, 32}; 

byte route = 0;
byte newRoute = 0;
byte digitNum = 1; // to deal with multi-digit values
byte maxDigits = 2;


boolean cancelButton = true; // will make everything go red at the start ?
byte cancelButtonPin = A0;  // an analog pin will work as a digital pin



//==================

void setup() {
  Serial.begin(9600);
  Serial.println("Starting R2SigTest.ino"); // just so we know it is alive
  
  for(byte n = 2; n<55; n++){   // start with x = 2 to avoid the Tx and Rx pins
    pinMode(n, OUTPUT);
  }
  
  for (byte n = 0; n < numCodeButtons; n++) {
    pinMode(codeButtonPin[n], INPUT_PULLUP);
  }
  
  for (byte n = 0; n < numSections; n++) {
    pinMode(sectionPin[n], INPUT_PULLUP);
  }
  
  pinMode(cancelButtonPin, INPUT_PULLUP);

  cancelButton = true;
  signal[1] = redred;
  respondToCancel(); // initializes settings
  
}

//==================

void loop() {
  readButtons();
  processRoute();
  setSignals();
  setTrackSwitches();

}

//==================

void readButtons(){

  cancelButton = digitalRead(cancelButtonPin);
  updateRouteNumber(); // slightly complex so give it a separate function
}

//======================

void respondToCancel() {
  if (cancelButton) {
    for (byte n = 0; n < numSignals; n++) {
      signal[n] = redred;
    }
    for (byte n = 0; n < numTrackSwitches; n++) { 
      trackSwitch[n] = turnoutNormal;
    }
    return;
  }
}

//======================

void updateRouteNumber() {
  
  // gather the digits for route
  if (digitNum == 1) {
    newRoute = 0;
  }
  for (byte n = 0; n < numCodeButtons; n ++) {
    if (digitalRead(codeButtonPin[n]) == LOW) {
      newRoute = newRoute * 10 + n;
    }
  }
  digitNum ++;
  if (digitNum > maxDigits) {
    digitNum = 1;
    route = newRoute;
  }
}

//================

void processRoute() {
  // get things ready for setSignals() etc
  switch (route) {
      case 14:
        trackSwitch[1] = turnoutNormal;
        break;
        
      case 15:
        trackSwitch[1] = turnoutNormal; //set switch 1 to normal
//        trackSwitch[1] = grnred;  // shouldn't this be a signal
        break;

      case 36:
        // ????
        break;
   }
}

//================

void setSignals() {
 switch (signal[1]){
   case redred:
   digitalWrite(2, LOW);
   digitalWrite(3, LOW);
   digitalWrite(4, HIGH);
   digitalWrite(5, LOW);
   digitalWrite(6, LOW);
   digitalWrite(7, HIGH); 
     break;
     
     case grnred:
   digitalWrite(2, HIGH);
   digitalWrite(3, LOW);
   digitalWrite(4, LOW);
   digitalWrite(5, LOW);
   digitalWrite(6, LOW);
   digitalWrite(7, HIGH); 
 }
  
  // this is wrong because I don't know how each signal is wired to give different colours
 /*for (byte n = 0; n < numSignals; n ++) {
   digitalWrite(signalPin[n], signal[n]);
 } */
}

//================

void setTrackSwitches() {
  for (byte n = 0; n < numTrackSwitches; n ++) {
   digitalWrite(trackSwitchPin[n], trackSwitch[n]);
 }
}

I know this is a little off topic, but I was searching for model railroad programs after reading this thread and I came across Model Railroading with Arduino at http://mrrwa.org. There's a zip file with a couple libraries for arduino with examples. I have attached the zip to this post. I haven't looked through it yet, so I don't know if there is anything to do with signals. I just thought you might find it useful anyway. Maybe you can look at the library and example files to get a feel for coding your project. Like others have stated earlier, don't try to take in too much at once. Just study one small piece at a time until you understand how each piece of code works, one at a time. If it all seems confusing right now, put it aside for now and stick with your project. You can always study it later.

Hope this helps somehow,
DigitalJohnson

MRRwA-2011-12-31.zip (48.1 KB)

It's been awhile since I've looked at that but maybe ur right I'll have to refresh up on . Thanx

I just took a glance at the examples and it looks like one of them controls signaling based on the state of turnouts. It doesn't appear to control the route taken. Perhaps the other examples do. From the examples, it looks like the model railroad is controlled via DCC and LocoNet. This may be just what you want.

DJ

Was it the opendcc that you found that in?

hbingham86:
i think im starting to get the hang of it. i just added the signal assignments in switch cases. and thought i set signal[1] to redred in setup and it goes redred but when i change it to grnred it stays redred.

For the moment please resist the temptation to add anything. Just study the stuff until you are sure you understand it thoroughly. And feel free to ask about anything you don't understand.

...R

I'm looking through your list of pin assignments and I need a little clarification.

For example, Signal 1 has three upper colours and three lower colours. Are they really two separate signals on the same post or are they all part of a single signal?

If they are all part of a single signal can you list all of the lighting options that it will use?

If they are really two separate signals on one post it will be easier to call them by different names.

And let me know if there is anything different about the other signals with upper and lower lights.

I need to know how they are to be used in order to figure out the best data structure to make the programming easy.

Also ...

Am I correct to think the pins allocated to switches are the output pins that control the switch movement? What mechanism are you using to move the switches? Is it really necessary to use 2 pins for each switch? Do any of the switches form a crossover such that both of them will always move as a pair and can be controlled as one?

And ...

What are you using as a keypad to take in route options? And what is the maximum number of route options that are required? I'm assuming the keypad is connected to the cb pins? You seem to only have 6 pins - how many buttons have you?

...R

Regarding the MRRwA libraries, it looks to me like the LocoLinx, LocoNetEtherBuffer and LocoNetMonitor examples are used to control DCC controls using a PC and/or an ethernet shield. The NmraDcc example is used to control DCC accessories and signal aspect packets. This looks like what you're trying to achive. I haven't checked into it, but I'm sure there are DCC signal accessories you can purchase. From what I've read about DCC so far, it looks like the best way to go. You can have multiple engines running on the same track(s) and a good control unit can take care of the switching and signaling for you. It can even control lighting on the train itself and scenery lighting too. I'm starting to get interested in DCC myself now! [I wonder what this is gonna cost me?] :roll_eyes:

DJ

Robin2:
I'm looking through your list of pin assignments and I need a little clarification.

For example, Signal 1 has three upper colours and three lower colours. Are they really two separate signals on the same post or are they all part of a single signal?

They are apart of the same signal. depending what the colors give will tell the operator which route they are taking at a switch

If they are all part of a single signal can you list all of the lighting options that it will use?

signals 1-6 can give the following colors...grnred, yelred, redred, redgrn, redyel, and redflred.(red flashing red on bottom) and signals 7 and 8 can grn, yel, red, yelgrn, and yellun.(yellow on top and lunar on second head)
If they are really two separate signals on one post it will be easier to call them by different names.

And let me know if there is anything different about the other signals with upper and lower lights.

I need to know how they are to be used in order to figure out the best data structure to make the programming easy.

To try to make it easy... the upper head(each signal head consists of the grn, yel and red leds) will tell the operator that they are taking the straight route. the second head will tell them that they are taking the diverging route.

Also ...

Am I correct to think the pins allocated to switches are the output pins that control the switch movement? What mechanism are you using to move the switches? Is it really necessary to use 2 pins for each switch? Do any of the switches form a crossover such that both of them will always move as a pair and can be controlled as one?

I am using the Tortoise slow motion stall switch machines. They need 12v to run at top speed which is also a problem I have to figure out. They have two contacts on them that require one to be positive and one to be negative. switching the polarity will move the switch machine to the other direction. I dont know if there is a circuit i can make that only takes 1 output pin and depending on if its low or high itll adjust the polarity?
And ...

What are you using as a keypad to take in route options? And what is the maximum number of route options that are required? I'm assuming the keypad is connected to the cb pins? You seem to only have 6 pins - how many buttons have you?

The routes will be controlled by 6 pushbuttons that i will have on a panel. All the routes will be according to the picture i uploaded last week. They are 1-4, 1-5, 1-6, 2-4, 2-5, 2-6 3-4, 3-5, 3-6, 4-1, 4-2, 4-3 5-1, 5-2, 5-3, 6-1, 6-2, 6-3,
Route 14 would equals pushbutton 1 then pushbutton 4. And so forth

Ill post the diagram with the available indications for each signal
...R