( Incomplete code for buzzing wall following robot - SCOTTY ORR ) ( The code here is only for the buzzing portion. Code not presented ) ( here was covered in class. Check your notes. ) LOOPINDEX SPIN-CNT EEWORD LOOPINDEX BUZZ-ON-CNT EEWORD LOOPINDEX BUZZ-OFF-CNT EEWORD VARIABLE BUZZ-COUNTER EEWORD ( ----- motor defs, etc cut here ----- ) : OBSTACLE? PA7 OFF? ; EEWORD ( if using analog sensor, will be different ) MACHINE BUZZALOT EEWORD ON-MACHINE BUZZALOT APPEND-STATE START_BUZZ EEWORD APPEND-STATE BUZZ_ON EEWORD APPEND-STATE BUZZ_OFF EEWORD APPEND-STATE SPIN_L EEWORD APPEND-STATE BUZZ_PAUSED EEWORD ( ----- WALLBOT machine and wall following code cut here ----- ) IN-STATE BUZZ_PAUSED CONDITION FALSE CAUSES THEN-STATE BUZZ_PAUSED TO-HAPPEN IN-EE ( Note on above: since always false - CAUSES may be left blank ) ( and is never executed. THEN-STATE must be specified but will ) ( never transition. Only way to get out of this state is with ) ( a SET-STATE from another machine... ) IN-STATE START_BUZZ CONDITION TRUE CAUSES 3000 PWMA0 PWM-PERIOD 3000 PWMA0 PWM-OUT THEN-STATE BUZZ_ON TO-HAPPEN IN-EE IN-STATE BUZZ_ON CONDITION BUZZ-ON-CNT COUNT CAUSES PWMA0 OFF 1 BUZZ-COUNTER +! THEN-STATE BUZZ_OFF TO-HAPPEN IN-EE IN-STATE BUZZ_OFF CONDITION BUZZ-OFF-CNT COUNT BUZZ-COUNTER @ 5 < AND CAUSES 3000 PWMA0 PWM-OUT THEN-STATE BUZZ_ON TO-HAPPEN IN-EE IN-STATE BUZZ_OFF CONDITION BUZZ-COUNTER @ 5 = OBSTACLE? AND CAUSES LBAK RSTOP 0 BUZZ-COUNTER ! THEN-STATE SPIN_L TO-HAPPEN IN-EE IN-STATE BUZZ_OFF CONDITION BUZZ-COUNTER @ 5 = OBSTACLE? NOT AND CAUSES STARTUP SET-STATE ( this is initial state in WALLBOT machine ) 0 BUZZ-COUNTER ! THEN-STATE BUZZ_PAUSED TO-HAPPEN IN-EE IN-STATE SPIN_L CONDITION SPIN-CNT COUNT CAUSES STARTUP SET-STATE ( in WALLBOT ) THEN-STATE BUZZ_PAUSED TO-HAPPEN IN-EE : MAIN ( initialize variables, set initial states, install machines ) 150 SPIN-CNT END 50 BUZZ-ON-CNT END 50 BUZZ-OFF-CNT END 0 BUZZ-COUNTER ! STARTUP SET-STATE BUZZ_PAUSED SET-STATE INSTALL WALLBOT INSTALL BUZZALOT ; EEWORD ( IMPORTANT NOTE: Any state called with SET-STATE must have only ) ( one transition. That includes states set from MAIN as well as ) ( those set from other machines. These states usually have a ) ( condition of TRUE - (or maybe FALSE). )