'{$PORT COM1} '**************************************************************************** ' QuickieLab Monitor ' ' Version 1.2 March 2, 2003 ' ' George Heron, N2APB n2apb@amsat.org ' ' This test program issues a series of serial commands to the IOX chip, including ' input parameters (e.g., messages to be displayed), and expecting the appropriate ' responses from the IOX chip (frequency values, ACK signals, etc.) The BS2 program ' cycles through all the commands described in the IOX Data Sheet and then jumps ' back up to the top of the program to repeat the test sequence in an endless loop. ' ' A Debug window is displayed on the PC screen to indicate which tests are in progress. ' This status display enables the user to better understand how to use the QuickieLab. ' The data received from the IOX circuit is also displayed in the Debug window, ' allowing the user to see the input values coming back from IOX, ' such as measured frequency, keypad entry, etc. ' ' Some tests will appear to hang the QuickieLab, even in a properly-running system. ' For example, the KEYPAD routine on the IOX is designed to wait forever for the user to ' press a key pad. Further, when the IOX system is not running properly (e.g., if power is ' lost), the QuickieLab Monitor program would obviously not receive the expected response. ' For these reasons, a "timeout period" is incorporated with all the SERIN commands that ' await feedback from the IOX subsystem. If the user should not be present to press a keypad ' during the automated tests, or if there is a problem with the IOX circuitry, the BS2 test program ' will merely "timeout", issue an "operation failed" message in its Debug window, and ' continue on to the next test. This type of "exception handling" is a common technique ' used by software engineers in industry. ' ' This QuickieLab Monitor program runs forever, even when the PC is shut down or if ' the RS232 programming cable is removed from the BS2. Further, it automatically starts up ' when power is applied to the QuickieLab. ' ' RELEASE HISTORY ' v1.0 10/02/2002 Initial release, based on rev 1.0 schematic ' v1.1 01/10/2003 Changed DDS control lines, ' added Speaker & Pot Test, ' now per rev 1.1 schematic and pc board ' v1.2 03/02/2003 Added Morse code & warbling tones (tnx to W8KOX for the routines) ' ' ' Copyright 2003 by G. Heron. All rights reserved. ' '***************************************************************************** ' '{$STAMP BS2} Response var BYTE ' Create variable for IOX control responses N var BYTE FreqString var BYTE(9) ' Create 9 byte string to hold freq response from IOX CounterReg var BYTE(3) ' Create 3 byte string to hold Frequency Cntr Regs from IOX Frequency var WORD temp var word ' Create a 16-bit variable for storage x var byte y var byte BAUD con 396 CMD con $FE Ain con 3 ' Create an alias for the potentiometer spkr con 4 ' Create an alias for the speaker '**************** 'START OF PROGRAM '**************** START: debug "QuickieLab Monitor v 1.1", CR debug "========================", CR '********* 'LCD TESTS '********* LCDTEST: gosub ClearDisplay 'issue ClearDisplay command debug "Test message to IOX",CR serout 0,BAUD,7,["QuickieLab Mon"] 'send test message to SX chip for individual 'character display, paced at 7ms intervals pause 2000 'wait a bit to ensure message present debug "Cursor On",CR serout 0,BAUD,20,[CMD,15] 'issue Cursor On command pause 20 debug "Cursor to Line 1",CR serout 0,BAUD,20,[CMD,$80] 'issue Line1positioning command pause 20 serout 0,BAUD,7,["Line1 w/cursor"] pause 500 debug "Cursor Off",CR serout 0,BAUD,20,[CMD,12] 'issue Cursor Off command pause 20 debug "Cursor to Line 2",CR serout 0,BAUD,20,[CMD,$C0] 'issue Line2positioning command pause 20 serout 0,BAUD,7,["Line2 no cursor"] pause 500 debug "Clear line 2",CR serout 0,BAUD,20,[CMD,3] 'issue ClearLine2 command pause 500 debug "Clear line 1",CR serout 0,BAUD,20,[CMD,2] 'issue ClearLine1 command pause 500 debug "Blank LCD",CR serout 0,BAUD,7,["Blank LCD 1 sec "] pause 500 serout 0,BAUD,20,[CMD,8] 'issue Blank LCD command pause 500 'wait a bit debug "UnBlank LCD",CR serout 0,BAUD,20,[CMD,12] 'issue UnBlank LCD command pause 200 '************ 'KEYPAD TESTS '************ KEYPADTEST: goto FREQTEST 'remove this line to do KEYPAD tests gosub ClearDisplay 'issue ClearDisplay command debug "Keypad Test: " serout 0,BAUD,7,["Hit any key"] pause 500 serout 0,BAUD,20,[CMD,101] 'issue ReadKeypad command serin 1,BAUD,PARITYERR,2000,TIMEOUT,[Response] debug DEC Response,CR goto FREQTEST TIMEOUT: debug "Keypad error",CR '*************** 'FREQ CNTR TESTS '*************** FREQTEST: gosub ClearDisplay serout 0,BAUD,7,["Reading Freq"] debug "Measuring Freq ..." serout 0,BAUD,20,[CMD,68] 'issue "Set 1:1 prescaler" command pause 100 serout 0,BAUD,20,[CMD,65] 'issue MeasureFreq command pause 2000 serout 0,BAUD,20,[CMD,66] 'issue ReadOutFreqCntrs command serin 1,BAUD,PARITYERR,5000,TIMEOUT4,[STR CounterReg\3] debug CR,"Counter Regs:" debug " ",DEC CounterReg(2) debug " ",DEC CounterReg(1) debug " ",DEC CounterReg(0),CR serout 0,BAUD,20,[CMD,67] 'issue ReadOutFreqString command FreqString(9) = 0 serin 1,BAUD,PARITYERR,5000,TIMEOUT4,[STR FreqString\8] pause 100 debug "Freq String= ",STR FreqString,CR serout 0,BAUD,20,[CMD,$C5] 'issue Line2positioning command pause 40 serout 0,BAUD,7,[STR FreqString] 'display 8 BCD frequency characters on 2nd line pause 1000 goto DIGPOTTEST TIMEOUT4: debug "Freq Meas error",CR '************ 'DIGPOT TESTS '************ DIGPOTTEST: gosub ClearDisplay debug "Dig Pot UP",CR serout 0,BAUD,20,[CMD,2] 'issue ClearLine1 command pause 1000 serout 0,BAUD,7,["DigPot Inc"] pause 10 for N = 1 to 10 serout 0,BAUD,20,[CMD,91,1] 'issue IncPot command + wiper increment count pause 1 next debug "Dig Pot DOWN",CR serout 0,BAUD,20,[CMD,2] 'issue ClearLine1 command pause 250 serout 0,BAUD,7,["DigPot Dec"] pause 10 for N = 1 to 10 serout 0,BAUD,20,[CMD,92,1] 'issue DecPot command + wiper decrement count pause 1 next '********* 'ADC TESTS '********* ADCTEST: gosub ClearDisplay serout 0,BAUD,20,[CMD,80] 'issue Get ADC command serin 1,BAUD,PARITYERR,1000,TIMEOUT2,[Response] 'await reply of ADC value in Response debug "ADC = ",DEC Response,CR serout 0,BAUD,7,["ADC = ",DEC Response] pause 1000 goto SetDDS TIMEOUT2: debug "No ADC response",CR pause 1000 '********* 'SET DDS '********* SetDDS: debug "DDS=10MHz",CR dir8 = 1 'set the DDS_Load pin as an output out8 = 0 'and init it to 0 gosub ClearDisplay 'issue ClearDisplay command serout 0,BAUD,7,["DDS=10MHz"] 'send program name to LCD shiftout 10,9,0,[$01,$EE,$09,$00,$00] 'shift out 40 DDS mode bits on Pin 10 (clock on Pin 9) 'to set freq (01,EE,09,00,00 = 10KHz) 'data sent LSB-to-MSB for each sequencial 8-bit value out8 = 1 'strobe the DDS Load line out8 = 0 pause 1000 '****************** 'SPEAKER & POT TEST '****************** SPKR_POT: debug "Pot & Tones",CR gosub ClearDisplay 'issue ClearDisplay command serout 0,BAUD,7,["Pot & Tones"] 'send program name to LCD high Ain 'Bring the Ain pin up to 5 Vdc pause 5 'Allow time for the capacitor to charge rctime Ain,1,temp 'Measure the RC-time discharge temp = temp*2 'Scale the frequency to hit the high end freqout SPKR,2000,temp 'Output 'temp' to the speaker for short duration pause 500 '******************** 'MORSE CODE TONE TEST '******************** MORSE_TONES debug "Morse Code",CR 'First send the callsign "N2APB" gosub ClearDisplay 'issue ClearDisplay command serout 0,BAUD,7,["Morse Code"] 'send program name to LCD gosub dash : gosub dot : pause 160 gosub dot : gosub dot : gosub dash : gosub dash : gosub dash : pause 160 gosub dot : gosub dash : pause 160 gosub dot : gosub dash : gosub dash : gosub dot : pause 160 gosub dash : gosub dot : gosub dot : gosub dot debug "Warbling Tones",CR 'Next send some warbling tones gosub ClearDisplay 'issue ClearDisplay command serout 0,BAUD,7,["Warbling Tones"] 'send program name to LCD for Y = 1 to 5 for X = 3 to 8 : freqout SPKR,100,(X*100) : next for X = 9 to 3 : freqout SPKR,100,(X*100) : next next '********* 'LED TESTS '********* LEDS: debug "LED Test",CR gosub ClearDisplay 'issue ClearDisplay command serout 0,BAUD,7,["LED Test"] 'send program name to LCD dir7 = 1 'set the DDS_Load pin as an output dir6 = 1 'set the DDS_Load pin as an output dir5 = 1 'set the DDS_Load pin as an output out7 = 1 'and init LED to OFF out6 = 1 'and init LED to OFF out5 = 1 'and init LED to OFF out7 = 0 'turn on LED 1 pause 350 out7 = 1 out6 = 0 'turn off LED 1 and turn on LED 2 pause 350 out6 = 1 out5 = 0 'turn off LED 2 and turn on LED 3 pause 350 out5 = 1 'turn off LED 3 '**************** 'PUSHBUTTON TESTS '**************** '********** ' PING TEST '********** PINGTEST: serout 0,BAUD,[$FF] 'send PING code to SX chip serin 1,BAUD,PARITYERR,2000,TIMEOUT3,[Response] 'await 2 sec for the response byte from SX chip if Response = 1 then ACK debug "Ping error 1!", CR goto START ACK: debug "ACK received OK", CR pause 500 goto START PARITYERR: debug "Parity error", CR goto START TIMEOUT3: debug "Ping error 2",CR goto START end '************ ' SUBROUTINES '************ '------------- 'CLEAR DISPLAY '------------- ClearDisplay: serout 0,BAUD,1,[CMD,$01] 'issue ClearDisplay command pause 400 'ensure SX LCD has enough time to do operation return Dot: freqout SPKR,60,1500 : pause 80 : return Dash: freqout SPKR,180,1500 : pause 80 : return