'------- [LED_Test] ------------------------------------------------------ '{$STAMP BS2} '{$PBASIC 2.5} ' ' File....... LED_Test.BS2 ' Purpose.... Test LED display connections using ' parallel EEPROM data. ' Author..... CustCrawler Inc. (Mike Gebhard) ' E-mail..... support@crustcrawler.com ' Started.... 26 June 2004 ' Updated.... 26 June 2004 ' Version.... 1.0 ' '========================================================================= ' Getting Started '========================================================================= ' This program contains 2 sub routines; ' Cycle_LED_Display ' Get_LED_and_Gait ' and ' EEPROM Data ' '========================================================================= ' Program Operation Overview '========================================================================= ' Cycle_LED_Display: ' This is the default sub routine. It cycles through ' digits 0-E and repeats indefinitely. Use this program ' to test your 7-segment LED connections ' ' Get_LED_and_Gait: ' To run this sub routine delete the comment from ' "'GOTO Get_LED_and_Gait" below. This sub uses parallel ' EEPROM data to lookup the value of "gaitCode" ' and output the proper digit on the LED display ' (see 7 Segement LED Display table below). This ' sub routine is used in the QuadCrawler and HexCrawler ' programs that use a 7-segment LED. ' '========================================================================= ' Sub Routines '========================================================================= ' Cycle_LED_Display: ' Variables ' counter is a pointer to EEPROM ' Segements is the output to pins 0-7 (LED display) ' ' Counter is assigned to LED (EEPROM address) ' and Segments is initialized to 0 ' The data stored in counter is read into Segments, ' counter is incremented and the process loops until ' Segments reaches the end of LED EEPROM data ($FF). ' This process repeats forever. ' ' Get_LED_and_Gait: ' Variables ' counter is a pointer to EEPROM ' Segements is the output to pins 0-7 (LED display) ' gaitCode is the Lookup value ' ' gaitCode is initialized to a value to lookup in EEPROM. ' ' LED gaitCode ' (0) $00 - Home ' (1) $01 - Spin Left ' (2) $02 - Spin Right ' ' LED gaitCode LED gaitCode ' (3) $10 - Forward Fast (6) $20 - Forward ' (4) $11 - Fast Forward Left (7) $21 - Forward Left ' (5) $12 - Fast Forward Right (8) $22 - Forward Right ' ' LED gaitCode LED gaitCode ' (9) $30 - Backward (C) $40 - Fast Backward ' (A) $31 - Backward Left (d) $41 - Fast Backward Left ' (b) $32 - Backward Right (E) $42 - Fast Backward Right ' (F) Open ' ' counter is initialized to LED (EEPROM address). counter points ' to LED output and counter+gait points to the parallel ' gait selection in EEPROM. The data in counter+gait is ' read into Segments, Segments is compared to gaitCode. ' If they are not equal counter is incremented. This process ' loops until Segments and selected Gait are equal. ' ' Finally, the value in counter is read into ' Segments and the LED display shows the ' correct digit related to gaitCode. ' ' 7 Segement LED Display: ' Segment map: .edc bafg HEX .edc bafg HEX ' (a) 0 %0111 1110 $7E 8 %0111 1111 $7F ' ----- 1 %0001 1000 $18 9 %0001 1111 $1F ' (f) | | (b) 2 %0110 1101 $6D A %0101 1111 $5F ' | (g) | 3 %0011 1101 $3D B %0111 0011 $73 ' ----- 4 %0001 1011 $1B C %0110 0110 $66 ' (e) | | (c) 5 %0011 0111 $37 D %0111 1001 $79 ' | | 6 %0111 0111 $77 E %0110 0111 $67 ' ----- 7 %0001 1100 $1C F %0100 0111 $47 - Open '------------------------------------------------------------------------- gaitCode VAR Byte Segments VAR OUTL ' output on pins 0 - 7 counter VAR Nib '---- [7 Segment LED and Gait EEPROM Data] ----- ' Hex # 0 1 2 3 4 5 6 7 8 9 A B C D E End F LED DATA $7E,$18,$6D,$3D,$1B,$37,$77,$1C,$7F,$1F,$5F,$73,$66,$79,$67,$FF',$47 Gait DATA $00,$01,$02,$10,$11,$12,$20,$21,$22,$30,$31,$32,$40,$41,$42,$FF DIRL = %01111111 ' P0 - P6 are outputs 'GOTO Get_LED_and_Gait Cycle_LED_Display: counter = LED Segments = 0 DO WHILE Segments <> $FF READ counter, Segments counter=counter+1 DEBUG CLS, HEX ?counter, HEX ?Segments PAUSE 500 LOOP GOTO Cycle_LED_Display Get_LED_and_Gait: gaitCode = $40 ' EEPROM lookup counter = LED READ counter+Gait, Segments DO WHILE Segments <> gaitCode counter = counter + 1 READ counter+gait, Segments LOOP READ counter, Segments DEBUG HEX ?counter, HEX ?Segments END