'************************************************************************* ' VXOMate Rev 1.1 ' ' Joe Everhart, N2CX ' 214 New Jersey Rd ' Brooklawn, NJ 08030 ' e-mail: n2cx@voicenet.com ' ' This program uses the BS2 in a QuickieLab breadboard to monitor a ' Variable Xtal Oscillator (VXO). The VXO is actually a voltage tuned ' oscillator which is part of the festivities for the NorCal QRPacificon ' 2002. There is a competition to see who has the widest stable frequency ' swing in oscillators with a nominal frequency of 7040 and 14060 kHz. ' ' The VXOMate uses the IOX ADC, frequency counter and LCD functions to ' monitor the DC tuning voltage and output frequency and to display them. ' ' It has two operating modes. In the default power-on visual display mode ' writes the program's measured values on an LCD screen. ' ' The second mode gives an audio/visual display by sounding the measured ' values on the Quickielab loudspeaker in addition to the LCD screen. ' ' Operation is toggled between the two modes each time pushbutton PB1 ' is depressed. ' ' Revision History: ' ----------------- ' Rev 0.0 10/9/2002 Draft release #1 ' ' Rev 1.0 10/30/2002 Fully functional now ' Rev 1.1 11/3/2002 Cleaned up MORSEDISPLAY routine (per N2APB) ' '************************************************************************* ' Copyright 2002, J. Everhart, N2CX All rights reserved. Permission is granted ' for personal, non-profit use. ' '************************************************************************* '{$STAMP BS2} '******************* ' VARIABLES '******************* Baud con 375 'IOX data rate 2400 baud CMD con 254 'LCD instruction prefix DitTime con 100 'MORSE dit time, 100 ms is 12 wpm Freq con 2000 'Output tone frequency TonePin con 5 'Tone output pin ADCOut var word '8-bit ADC outout value CounterReg var byte(3) 'Unpacked freqeuncy value Dig1 var byte 'Units digit of voltage reading Dig2 var byte 'Tenths digit of voltage reading Dig3 var byte 'Hundredths digit of voltage reading FreqStr var byte(9) '9 digit freq string from IOX oounter I var byte 'Generic counter index Mode var nib 'Operating Mode MorseChar var byte 'Alphanumeric packed morse character TestChar var byte 'Byte test variable Voltdigit var byte 'Individual digits of voltage for display Volts var word '3-digit decimal ADC output scaled 0-100 MorseIndex var nib 'Lookup command index for morse character '************************************************************************* ' MAIN PROGRAM - This is an endless loop that begins in the default mode in ' which the VXO input DC tuning voltage and output frequency ' are monitored and displayed on the LCD screen. ' After each measure/display cycle the pushbutton is polled ' If it has been pressed, a routine is called which toggles ' operation between a visual only display mode and an ' audiovisual mode by adding an audible morse output '************************************************************************* INITIALIZE: 'Initialize and show opening screens Mode =0 'Start in LCD display only mode FreqStr(9) = 0 'Initialize to zero frequency serout 0,Baud,20,[CMD,1] 'Clear LCD serout 0,Baud,7,[" N2CX VXOMate"] 'Write opening display serout 0,Baud,20,[CMD,192] 'Put cursor on 2nd line of LCD serout 0,Baud,7,["Rev 0.1 10/16/02"] pause 1000 'Display the opening screen for a sec serout 0,Baud,30,[CMD,3] 'Clear 2nd line of LCD pause 100 'Wait for the IOX/LCD to finish serout 0,BAUD,20,[CMD,68] 'Issue "Set 1:1 prescaler" command pause 100 START: serout 0,Baud,20,[CMD,80] 'Command ADC to take a reading serin 1,Baud,[ADCout] 'Get ADC reading 'Read freq counter serout 0,BAUD,20,[CMD,65] 'Issue MeasureFreq command pause 1500 serout 0,BAUD,20,[CMD,67] 'Issue ReadOutFreqString command serin 1,BAUD,5000, TIMEOUT, [STR FreqStr\8] 'Read frequency pause 100 goto DISPLAY TIMEOUT: DISPLAY: 'Display voltage and frequency Volts=ADCOut * 160/51 'Scale 8-bit reading to 0-8volts Dig1 = Volts dig 2 'Pick out indivdual voltage digits Dig2 = Volts dig 1 Dig3 = Volts dig 0 serout 0,Baud,20,[CMD,192] 'LCD cursor to line 2 serout 0,Baud,10,[dec Dig1,".", dec Dig2, dec Dig3,"V"] 'Voltage readout to LCD serout 0,Baud,20,[CMD,198] 'LCD cursor to line 2 position 6 serout 0,Baud,7,[ FreqStr(0), FreqStr(1),"."] 'Write MS freq digits for I=2 to 7 serout 0,Baud,7,[FreqStr(I)] 'Remainder of freq digits next serout 0,Baud,7,["H"] 'Add frequency units CHECKSWITCH: 'See if mode change is desired if in2 = 1 then CHECKMODE 'No mode change requested Mode = ~ Mode 'PB1 depressed so toggle mode CHECKMODE: if Mode = 0 then START 'Visual display only mode gosub MORSEDISPLAY 'Add audible Morse code output goto START 'Repeat whole program ad nauseum '************************************************************************* ' MORSEDISPLAY - This subroutine disects the voltage and and frequency ' parameters VOLTAGE and FREQUENCY and converts them ' to a packed morse form. It then calls a routine which ' actually sends the audible morse characters as each is ' converted to packed morse form. ' ' Measured input voltage in the range of 0-10V is sent with ' an "R" serving as a decimal point after the most units ' digit. A "V" is sent as the volts indication after the ' numeric string ' ' Frequency is sent as a string of 9 digits with the ' implied units of MHz. An R is sent after the units ' MHz digit as a decimal point. In order to save time, ' the implied MHz is not sent. '************************************************************************* MORSEDISPLAY: for i = 2 to 0 'Pick off digits from voltage input VoltDigit = Volts dig I 'Grab individual decimal digits 'Get packed Morse characters lookup VoltDigit,[$C0,$7C,$3C,$1C,$0C,$04,$84,$C4,$E4,$F4],MorseChar ' Morse "T" used for "0" for brevity gosub SENDMORSE 'Send Morse character if I = 2 then SENDR 'Add "R' for decimal point after ms digit goto SKIPR 'If not most signif digit SENDR: MorseChar = $50 'Packed Morse representation for "R" gosub SENDMORSE SKIPR: next SENDV: MorseChar = $18 'Packed Morse representation for "V" gosub SENDMORSE 'Send decimal sign after MHz digit/s pause 500 '1/2 sec delay between MORSE readouts for I = 0 to 7 'Pick off digits from frequency string MorseIndex = FreqStr(I) lookup MorseIndex ,[$C0,$7C,$3C,$1C,$0C,$04,$84,$C4,$E4,$F4],MorseChar ' Morse "T" used for "0" for brevity gosub SENDMORSE 'Send Morse character if I = 1 then SNDR 'Add "R' for decimal point after ms digit goto SKPR 'If not most signif digits SNDR: MorseChar = $50 'Packed Morse representation for "R" gosub SENDMORSE 'Send decimal sign after MHz digit/s SKPR: next return 'To main program '************************************************************************* ' SENDMORSE - This subroutine picks apart packed morse characters stored in ' MorseChar and ouputs audible Morse characters on TonePin of ' the BS2. Speed is set to 12 wpm initally by variable DitTime. '************************************************************************* SENDMORSE: 'Sends audible morse chars CHECKMORSE: 'Process packed morse variable if MorseChar = $80 then SENDCHARSPACE 'All dits and dahs shifted out TestChar = MorseChar & $80 'Get high bit MorseChar = MorseChar *2 'Shift out used char if TestChar = $80 then SENDDAH 'Char is a DAH so send it 'If not, it's a DIT so fall thru SENDDIT: freqout TonePin, DitTime, Freq 'Unit time dit tone freqout TonePin, DitTime, 0 'Unit time space goto CHECKMORSE 'Go back for next char SENDDAH freqout TonePin, 3*DitTime, Freq '3*Unit time dit tone freqout TonePin, DitTime, 0 'Unit time space goto CHECKMORSE 'Go back for next char SENDCHARSPACE: freqout TonePin, 2*DitTime, 0 '2*unit time space return 'To MORSEDISPLAY STOP 'Something has gone badly wrong 'to get here! '************************************************************************* ' End of program VXOMate '*************************************************************************