IR sensors - count how many cars go past - compare to record of train, make sure no cars have been lost - must be able to sense space between cars reliably - determine when appropriate coupler is over decoupling magnets RFID (NFC) sensors - confirm record of which cars should be attached to each loco Bump sensors - placed in each loco to sense when it backs into cars Speedometers - a pair of sensors used to check speed of train - results used to create table of speed of each loco with given load Section sensors - identifies when a section is occupied - if using IR, set at intersection of every track section - calculate speed of train through each section with current load - results can be used to create a table of expected travel times Sections - each section should have a max speed Motion sensor in each loco so it knows if it has stalled? Cars attached to loco - Resistance (needs a resistor in one wheel of each car) - wire length measurement - capacitance https://www.arduino.cc/en/Tutorial/CapacitanceMeter ---------------------------------------- Table for location sensors: Sensors Section 1:2 AA 2:3 AB 3:4 AC 1:4 AD 1:5 BA 5:6 BB 1:7 CA 7:8 CB 1:9 DA 9:10 DB 0 = block clear 1 = block warning 2 = block occupied Keep one table that shows only occupied/clear status - when loco triggers sensor: - add sensor to train's list of locations - mark block between this and next sensor as occupied - When sensor clears: - mark previous block as clear - remove previous sensor from train's list of locations - If only 1 entry for locations and blocks, keep them marked until train trips the next sensor (prevent train from disappearing when it is between sensors) location: AD - A = previous sensor that has cleared - B:C = sensors currently tripped - D = destination, next expected sensor Train going clockwise around loop: location 1<>4, block AC location 1<4>3, block AB location 4<>3, block AB location 4<3>2, block AA location 3<>2, block AA location 3<2>1, block AD location 2<>1, block AD location 2<1>4, block location 1<>4, block *trigger: "1<" means train has passed sensor 1 Reverse train direction, reverse order of location and block Train wants to back into siding 9:10: location 4<>1, block DA location 4<1>9, block DB location 4<9:1>10, block location 1<9>10, block location 9<>10, block location 9<10>, block *trigger: "<10>" stop train. If train trips an unexpected sensor, stop and sound alarm. Create new table that also shows warning status loop through all blocks { if block occupied { check blocks on either side { if (block == clear) mark block = warning } } } This table is used by locos and signals - Trains are designated as a blob of occupied blocks so they can move in both directions and still maintain a solid area. - Keep a table of each train with unique designation - include all locos and cars - include location blob Routes: Train is sitting in CB, must pick up car from DB, go around loop, drop car at DB, park in CB. CA:AD:1<=R (reverse direction after clearing sensor 1) DA:DB:<10>=R (reverse direction when sensor 10 is triggered) DA:AD:AC:AB:AA:AD1<=R (reverse direction after clearing sensor 1) DA:DB:9<=R (reverse direction after clearing sensor 9) DA:AD:1<=R (reverse direction after clearing sensor 1) CA:CB:<8>=S (stop after triggering sensor 8) BadRoutes: Dest Bad AA CA:DA AD BA DA AA:CA CA AA:DA BA AD Turnouts: Route Turnout(s) AA:AD t1=0:t2=0:t3=0 AA:BA t3=0:t2=0:t1=1 AD:AA t1=0:t2=0:t3=0 AD:CA t1=0:t2=0:t3=1 AD:DA t1=0:t2=1 BA:AA t1=1:t2=0:t3=0 BA:CA t1=1:t2=0:t3=1 BA:DA t1=1:t2=1 CA:AD t3=1:t2=0:t1=0 CA:BA t3=1:t2=0:t1=1 DA:AD t2=1:t1=0 DA:BA t2=1:t1=1