# Points Operation on Rowandale - Sidings and Inner & Outer Holding # ================================================================= # Version I2C Pololu A - Pololu Mini Maestro 24 channel ( 0 - 23 ) # 5 I2C Outputs on Pololu Inputs 18 19 20 21 & 22 selects 1 of 17 routes # controlling servo Channels 1 to 17 ( Ch 0 not used ). # Range 4000 to mid 6000 to 8000 # 20 speed - 50 acceleration - exact midpoints ~ 1500uS - all set in Channel Configuration # "Busy" digital Output on Channel 23 # The post-fix "s" & "d" in the Setting Routes procedures # refer to the point being "Straight" or "Diverted". # # Start Up # ======== busy_on 1000 delay set_initial_positions busy_off 0 # put dummy route zero on stack begin get_route # get a route number dup rot # need to place current route number at BOTTOM of stack # so as it is remembered for next pass through main loop. equals if moving_wait # if no change toggle Busy goto pause # then check again. endif # Sidings Routes # -------------- dup 1 equals if route_incoming goto pause endif dup 2 equals if route_run_round goto pause endif dup 3 equals if route_outgoing goto pause endif dup 4 equals if route_goods_shed goto pause endif dup 5 equals if route_small_goods goto pause endif dup 6 equals if route_cattle_dock goto pause endif dup 7 equals if route_factory_bay goto pause endif dup 8 equals if route_coal_yard goto pause endif dup 9 equals if route_engine_shed goto pause endif dup 10 equals if route_turntable goto pause endif dup 11 equals if route_shunter goto pause endif dup 12 equals if route_sidings goto pause endif # Main Line Routes # ---------------- dup 13 equals if route_inner_holding_1 goto pause endif dup 14 equals if route_inner_holding_2 goto pause endif dup 15 equals if route_full_inner_loop goto pause endif dup 16 equals if route_outer_holding goto pause endif dup 17 equals if route_full_outer_loop goto pause endif pause: 100 delay repeat # subroutines # =========== sub get_route read: get_value # need to check twice get_value # in case input bits are in middle of changing dup equals if goto ok else goto read endif ok: return sub get_value # Get the value of inputs 18 19 20 21 22 # High to Low value on bits 1 to 5 # as a binary number from 0 to 17, defining a route. 18 get_position 500 less_than if 1 else 0 endif 19 get_position 500 less_than if 2 else 0 endif plus 20 get_position 500 less_than if 4 else 0 endif plus 21 get_position 500 less_than if 8 else 0 endif plus 22 get_position 500 less_than if 16 else 0 endif plus 100 delay # temporary - allows time to see value on stack return sub moving_wait busy_on begin get_moving_state while # wait until it is no longer moving repeat busy_off return sub busy_on 4000 23 servo # Set "busy" output return sub busy_off 8000 23 servo # Clear "busy" output return # Setting the Sidings Routes # ======================= sub route_incoming point_10_d point_9_s point_1_s point_2_s moving_wait return sub route_run_round point_10_d point_9_d point_7_d point_2_d point_1_d moving_wait return sub route_outgoing point_10_d point_9_d point_7_d point_2_s # also point_1_s moving_wait return sub route_goods_shed point_10_s point_8_s moving_wait return sub route_small_goods point_10_s point_8_d point_3_s moving_wait return sub route_cattle_dock point_10_s point_8_d point_3_d moving_wait return sub route_factory_bay point_10_d point_9_d point_7_s point_5_d point_4_s moving_wait return sub route_coal_yard point_10_d point_9_d point_7_s point_5_d point_4_d moving_wait return sub route_engine_shed # From Factory or Coal Yard point_5_s point_6_d # also point_7_d moving_wait return sub route_turntable # From Factory or Coal Yard point_5_s point_6_s # also point_7_d moving_wait return sub route_shunter # point_11_s moving_wait return sub route_sidings # point_11_d moving_wait return # Setting the Main Line Routes # ============================ sub route_inner_holding_1 # Main Line B1 - Holding under Town point_13_d # Temporary as Sidings In & Out point_14_s # point_16_d # point_17_d moving_wait return sub route_inner_holding_2 # Main Line B2 - Holding under Town point_13_d point_14_d point_16_d # point_17_s moving_wait return sub route_full_inner_loop # Main Line B - Inner Loop point_13_s point_16_s # point_17_s moving_wait return sub route_outer_holding # Main Line A1 - Holding under Town point_12_d point_15_d moving_wait return sub route_full_outer_loop # Main Line A - Outer Loop point_12_s point_15_s # point_18_s # point_22_s # point_23_s # point_19_s # point_11_d moving_wait return # Initial Point Positions # ======================= sub set_initial_positions point_1_s point_2_s point_3_s point_4_s point_5_s point_6_d point_7_d point_8_s point_9_s point_10_d # point_11_d point_12_s point_13_s point_14_d point_15_s point_16_s # point_17_s moving_wait return # Moving the Sidings Points # ========================= sub point_1_s 5720 1 servo return sub point_1_d 6820 1 servo return sub point_2_s 7000 2 servo return sub point_2_d 5550 2 servo return sub point_3_s 6750 3 servo return sub point_3_d 5350 3 servo return sub point_4_s 5350 4 servo return sub point_4_d 7050 4 servo return sub point_5_s 7150 5 servo return sub point_5_d 5900 5 servo return sub point_6_s 5550 6 servo return sub point_6_d 7050 6 servo return sub point_7_s 6800 7 servo return sub point_7_d 5400 7 servo return sub point_8_s 5800 8 servo return sub point_8_d 7050 8 servo moving_wait return sub point_9_s 5550 9 servo return sub point_9_d 6600 9 servo return sub point_10_s 5900 10 servo return sub point_10_d 7100 10 servo return # Moving the Mainline Points # ========================== # All on lever arm hole 1 sub point_11_s 6400 11 servo return sub point_11_d 5050 11 servo return sub point_12_s 6200 12 servo return sub point_12_d 4800 12 servo return sub point_13_s 5400 13 servo return sub point_13_d 6800 13 servo return sub point_14_s 5440 14 servo return sub point_14_d 6450 14 servo return sub point_15_s 5400 15 servo return sub point_15_d 6800 15 servo return sub point_16_s 5500 16 servo return sub point_16_d 6500 16 servo return sub point_17_s 5500 17 servo return sub point_17_d 6600 17 servo return