-- -- name : e0003.jal -- author : Wouter van Ooijen -- date : 21-Sep-1998 -- purpose : jal example -- -- firmware for a line following robot -- port B drives 2 4-phase stepper motors via an ULN2803. -- a0 and a1 are connected to 2 white-is-low reflective sensors. -- a2 and a3 drive 2 LEDs which show the state of the sensor inputs. -- target configuration: 16f84 with 10 Mhz Xtal include 16f84_10 -- standard library include jlib -- configure the appropriate port and pin directions port_b_direction = all_output pin_a0_direction = input pin_a1_direction = input pin_a2_direction = output pin_a3_direction = output -- provide steering for the two stepper motors -- and wait the appropriate time (time depends on the -- stepper motors used). procedure steppers( byte in a, byte in b ) is port_b = a + ( b << 4 ) delay_1mS( 10 ) end procedure -- variables for the current steering of the stepper motors -- initialised to appropriate intial values var byte left_stepper = 0b_0001 var byte right_stepper = 0b_0001 forever loop -- copy the sensor values to the indicator LEDs pin_a2 = pin_a0 pin_a3 = pin_a1 -- step each motor only when the associated -- sensor sees white if ! pin_a0 then stepper_motor_half_forward( right_stepper ) end if if ! pin_a1 then stepper_motor_half_forward( left_stepper ) end if -- provide steering and wait steppers( left_stepper, right_stepper ) end loop
.