'######################################################################### '# '# ***** * *** ***** * * *** '# * * * * * * * * * '# * * * * * * * * * * ** '# ***** * * * * * * * * * '# * * * * * * * * * ** * '# * * * * * * * * * '# ***** ***** *** * * * *** '# '# '# *** MEMORY SLOT #0 *** *** MEMORY SLOT #0 *** '# '# 73's Steve - VK6HV '######################################################################### #Slot 0 Rem ********************************************************************** Rem * The PICAXE 28X2 Electronic Keyer * Rem * Pin configuration, Notes etc. etc. * Rem * * Rem * PIN# Project Use PICAXE Pin Definition * Rem * * Rem * Pin #1 Reset [Reset] * Rem * Pin #2 DC Supply Voltage [Digital In/Out, Analog In A.0] * Rem * Pin #3 12 Position Switch [Digital In/Out, Analog In A.1] * Rem * Pin #4 CW Tone [Digital In/Out, Analog In A.2] * Rem * Pin #5 CW Speed [Digital In/Out, Analog In A.3] * Rem * Pin #6 Serial In(Program) [Serial In] * Rem * Pin #7 Serial Out(Program) [Digital In/Out, A.4 Serial Out] * Rem * Pin #8 0 Volts [0 Volts] * Rem * Pin #9 Resonator [Resonator (not used)] * Rem * Pin #10 Resonator [Resonator (not used)] * Rem * Pin #11 DAH paddle [Digital In/Out, C.0] * Rem * Pin #12 DIT paddle [Digital In/Out, C.1] * Rem * Pin #13 LED [Digital In/Out, Analog In C.2] * Rem * Pin #14 4 Position Switch [Digital In/Out, Analog In C.3] * Rem * Pin #15 Relay Output [Digital In/Out, Analog In C.4] * Rem * Pin #16 Speaker Out [Digital In/Out, Analog In C.5] * Rem * Pin #17 LCD RS [Digital In/Out, Analog In C.6] * Rem * Pin #18 LCD E [Digital In/Out, Analog In C.7] * Rem * Pin #19 0 Volts [0 Volts] * Rem * Pin #20 5 Volts [+5 Volts] * Rem * Pin #21 LCD Data Bit 0 [Digital In/Out, Analog In B.0] * Rem * Pin #22 LCD Data Bit 1 [Digital In/Out, Analog In B.1] * Rem * Pin #23 LCD Data Bit 2 [Digital In/Out, Analog In B.2] * Rem * Pin #24 LCD Data Bit 3 [Digital In/Out, Analog In B.3] * Rem * Pin #25 LCD Data Bit 4 [Digital In/Out, Analog In B.4] * Rem * Pin #26 LCD Data Bit 5 [Digital In/Out, Analog In B.5] * Rem * Pin #27 LCD Data Bit 6 [Digital In/Out, B.6] * Rem * Pin #28 LCD Data Bit 7 [Digital In/Out, B.7] * Rem * * Rem ********************************************************************** Rem ********************************************************************** Rem * The PICAXE 28X2 Electronic Keyer * Rem * ---> Words & Bytes used in Slot#0 <--- * Rem * * Rem * W0 = * Rem * Rem * W1 = used for all keyer modes for speeds and spacing * Rem * b2 = * Rem * b3 = * Rem * * Rem * W2 = used for all keyer modes for speeds and spacing * Rem * b4 = * Rem * b5 = * Rem * * Rem * W3 = used for all keyer modes for speeds and spacing * Rem * b6 = * Rem * b7 = * Rem * * Rem * W4 = * Rem * b8 = used for keyer mode "B" and mode "B" A/S * Rem * b9 = used for keyer mode "B" and mode "B" A/S * Rem * * Rem * W5 = * Rem * W6 = * Rem * W7 = * Rem * W8 = * Rem * W9 = * Rem * W10 = * Rem * W11 = * Rem * W12 = * Rem * W13 = * Rem * W14 = * Rem * W15 = * Rem * W16 = * Rem * W17 = * Rem * W18 = * Rem * * Rem * W19 = used for Bin2ASCII to display "Supply Voltage" * Rem * b38 = * Rem * b39 = * Rem * * Rem * W20 = * Rem * b40 = used for Bin2ASCII to display "Supply Voltage" * Rem * b41 = used for Bin2ASCII to display "Supply Voltage" * Rem * * Rem * W21 = * Rem * b42 = used for Bin2ASCII to display "Supply Voltage" * Rem * b43 = used for Bin2ASCII to display "Supply Voltage" * Rem * * Rem * W22 = * Rem * b44 = used for Bin2ASCII to display "Supply Voltage" * Rem * b45 = * Rem * * Rem * W23 = used to clear some Words and Bytes * Rem * * Rem * W24 = * Rem * b48 = used to bypass the "initialising" in slot#0 after startup * Rem * b49 = * Rem * * Rem * W25 = * Rem * b50 = used in For/Next to push characters/instructions to the LCD * Rem * b51 = used in For/Next to push characters/instructions to the LCD * Rem * * Rem * W26 = * Rem * b52 = used for calculating the 4 pole switch position * Rem * b53 = used for calculating the 4 pole switch position * Rem * * Rem * W27 = * Rem * b54 = used for calculating the 12 pole switch position * Rem * b55 = used for calculating the 12 pole switch position * Rem * * Rem ********************************************************************** Rem **NOTES ** HISTORY** **NOTES ** HISTORY** **NOTES ** Rem 30 JUN 2013 Finished drawing up keyer artwork, MS Paint :-( Rem 06 JUL 2013 Etched out PICAXE-28X2 Electronic Keyer board for Rem prototype, programming and testing. Rem 07 JUL 2013 Soldered parts, but found error in the artwork! Rem 07 JUL 2013 Fixed circuit board art work. Rem 08 JUL 2013 Started to tinker around with the code. We'll just pinch Rem most of the code from the PICAXE-14M2 project and add Rem what else is needed. Rem 14 JUL 2013 Etched out final board, drilled all hole and soldered in Rem parts. Started checking 5V analog and digital I/O. Rem 15 JUL 2013 Started working on the code. Rem 10 AUG 2013 Still working on the code. Rem AUG 2013 Lost interest. :-( Rem 6 JUN 2015 Had lost interest in project. Starting to think about it Rem again. Rem 13 JUN 2015 Made final mods to the artwork for new 4pole switch. Rem 15 JUN 2015 Ordered Ammonium persulfate from my favorite electronics Rem outlet in Perth. Took 3 days to get here via courier. Lol. Rem Almost lost interest again! Rem 18 JUL 2015 Etched, drilled and soldered parts to board. Rem 19 JUL 2015 Down loaded code. Debugging. Rem 24 JUL 2015 Connected LCD to keyer. Big learning curve, Lots of Rem debugging. Rem 27 JUL 2015 Slaved over the US callsign code for 3 days. :-( Rem 5 AUG 2015 Tidy up, spell check, etc. etc. Rem 16 AUG 2015 More tidy up, added somemore comments and did more spell Rem checking. :-) Rem 30 OCT 2015 Back from holiday. Time to put pen to paper. '######################################################################### '# It loads all the letters, numbers and punctuation into EEprom memory. '# EEprom space has been left unused from location 42-51 in case you may '# want to add a few more punctuation symbols into the Simple Punctuation '# routine, but you will have to fiddle with the code if you do. '# '# ############################################################ '# # THERE IS NO SPEAKER OUTPUT WHEN IN THE "KEYER" MODES # '# # YOU NEED TO USE YOUR RADIOS MONITOR OR SIDE TONE # '# # # '# # EXCEPT IN MENU #11 BELOW WHICH IS "MODE A" AND HAS BOTH # '# # A RELAY OUTPUT AND SOUND OUTPUT # '# ############################################################ '# '# '######################################################################### Rem ***** THE PROGRAM *** *** THE PROGRAM *** *** THE PROGRAM ***** REM *** ENCODED CHARACTER NUMBERS *** REM A 6, B 17, C 21, D 9, E 2, F 20, REM G 11, H 16, I 4, J 30, K 13, L 18, REM M 7, N 5, O 15, P 22, Q 27, R 10, REM S 8, T 3, U 12, V 24, W 14, X 25, REM Y 29, Z 19, REM 1 62, 2 60, 3 56, 4 48, 5 32, REM 6 33, 7 35, 8 39, 9 47, 0 63, EEPROM 1, (6,17,21,9,2,20,11,16,4,30,13,18,7,5,15,22,27,10,8,3,12,24,14,25,29,19) Rem A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 'Letters EEPROM 27, (62,60,56,48,32,33,35,39,47,63) Rem 1 2 3 4 5 6 7 8 9 0 'Numbers EEPROM 37, (41,76,86,106,115) Rem / ? @ . , 'Simple Punctuation EEPROM 52, (34,41,42,45,49,71,76,82,85,86,94,97,106,108,109,115,117,200) Rem & / + ( = : ? " ; @ ' - . _ ) , ! $ 'All Punctuation EEPROM 70, (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,30,17,19,21,25,27,29,32,33,35,39,47,48,56,60,62,63,34,41,42,45,49,71,76,82,85,86,94,97,106,108,109,115,117,200) Rem E T I N A M S D R G U K W O H L F P V J B Z C X Q Y 5 6 7 8 9 4 3 2 1 0 & / + ( = : ? " ; @ ' - . _ ) , ! $ Rem Locations 70 - 123 is Everything! Letters, Numbers and Punctuation! Rem Locations 70 - 75 are also used for LearnETINAM mode in Slot#1 Rem Locations 76 - 83 are also used for LearnSDRGUKWO mode in Slot#1 Rem Locations 84 - 89 are also used for LearnHLFPVJ mode in Slot#1 Rem Loactions 90 - 95 are also used for LearnBCQXYZ mode in Slot#1 '######################################################################### '# PreStart: '# This stops the Initilising and Supply Voltage from being displayed '# on the LCD everytime there is a return to slot#0. This is only at the '# top of Slot#0. '# '######################################################################### PreStart: If b48 = 1 Then Goto SkipInitialising: b48 = 1 '######################################################################### '# Start: '# There are 6 CW keyer modes, They are: '# '# IambicModeA = Mode A keyer '# IambicModeA_AS = Mode A keyer with Auto Spacing '# IambicModeB = Mode B keyer '# IambicModeB_AS = Mode B keyer with Auto Spacing '# BugMode = A manual dash mode (probably never used) '# StraightKey = Straight key mode '# '######################################################################### Start: SetFreq M4 Let dirsB = %11111111 Gosub ClearSomeWordsAndBytes Gosub Initialise 'Initialise the LCD Gosub Initialising 'Displays "*Initialising*" Gosub SupplyVoltage 'Displays the actual supply voltage, 'should be around 13.8 volts SkipInitialising: MainDirectory: Gosub Check4PoleSwitch Gosub Check12PoleSwitch Select Case b55 Case 1 Goto Menu1 'IambicModeA Case 2 Goto Menu2 'IambicModeA_AS 'with Auto Spacing Case 3 Goto Menu3 'IambicModeB Case 4 Goto Menu4 'IambicModeB_AS 'with Auto Spacing Case 5 Goto Menu5 'BugMode Case 6 Goto Menu6 'StraightKey Case 7 Goto Menu7 'Spare Menu 7 Case 8 Goto Menu8 'Spare Menu 8 Case 9 Goto Menu9 'Spare Menu 9 Case 10 Goto Menu10 'Iambic Mode A with sound and relay output (experimental) Case 11 Goto Menu11 'Iambic Mode A with relay output only (experimental) Case 12 Goto Menu12 'Iambic Mode A sound only, a practice mode (experimental) End Select '######################################################################### '# IambicModeA: '# This is my version of Iambic Mode A. It is used with a dual paddle '# Iambic key. It simply polls the dit and dah paddle input pins for '# closure. If either are closed, it will go and send a Dit or Dah. If '# both are closed, it will send alternating Dots and Dashes. '# '######################################################################### Menu1: Gosub ClearLCDScreen For b50= 0 to 14 Lookup b50, (" IAMBIC MODE A"), b51 Gosub WriteCharacter Next b50 IambicModeA: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 1 Then GOTO MainDirectory Setfreq M8 ReadADC A.3, b2 w1 = b2 * 127 / 255 + 21 'Dit pause time, scales number 21 to 148, (w1) w2 = b2 * 3 'Dah pause time, scales number 63 to 444, (w2) 'Dots, about 32mS. fast, 210mS. slow CheckForModeADit: If PinC.1 = 0 then Goto ModeADit CheckForModeADah: If PinC.0 = 0 then Goto ModeADah Goto IambicModeA ModeADit: High C.4 High C.2 For w3 = 0 to w1 Pause 1 Next Low C.4 Low C.2 For w3 = 0 to w1 Pause 1 Next Goto CheckForModeADah ModeADah: High C.4 High C.2 For w3 = 0 to w2 Pause 1 Next Low C.4 Low C.2 For w3 = 0 to w1 Pause 1 Next Goto CheckForModeADit '######################################################################### '# IambicModeA_AS: '# This is my version of Iambic Mode A with AUTO SPACING. It is used with '# a dual paddle Iambic key. It simply polls the dit and dah paddle input '# pins for closure. If either are closed, it will go and send a Dit or '# Dah. If both are closed, it will send alternating Dots and Dashes. '# '# *BEWARE* if you have never used auto spacing, it may take some time '# getting used to it. In the end, it will be worth it as you'll send '# perfect code! '# '######################################################################### Menu2: Gosub ClearLCDScreen For b50= 0 to 14 Lookup b50, (" IAMBIC MODE A"), b51 Gosub WriteCharacter Next b50 Gosub MoveCursorToSecondLine For b50 = 0 to 13 Lookup b50,(" AUTO SPACING"), b51 Gosub WriteCharacter Next b50 IambicModeA_AS: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 2 then Goto MainDirectory SetFreq M8 ReadADC A.3, b2 w1 = b2 * 127 / 255 + 21 'Dit pause time, scales number 21 to 148, (w1) w2 = b2 * 3 'Dah pause time, scales number 63 to 444, (w2) 'Dots, about 32mS. fast, 210mS. slow CheckModeADit_AS: If PinC.1 = 0 then Goto ModeADit_AS CheckModeADah_AS: If PinC.0 = 0 then Goto ModeADah_AS Goto IambicModeA_AS ModeADit_AS: High C.4 High C.2 For w3 = 0 to w1 Pause 1 Next Low C.4 Low C.2 For w3 = 0 to w1 Pause 1 Next Goto CheckModeADahContacts_AS ModeADah_AS: High C.4 High C.2 For w3 = 0 to w2 Pause 1 Next Low C.4 Low C.2 For w3 = 0 to w1 Pause 1 Next Goto CheckModeADitContacts_AS CheckModeADitContacts_AS: If PinC.1 = 0 then Goto ModeADit_AS If PinC.0 = 0 then Goto ModeADah_AS For w3 = 0 to w1 '1 Dit space Pause 1 Next For w3 = 0 to w1 '1 Dit space Pause 1 Next Goto IambicModeA_AS CheckModeADahContacts_AS: If PinC.0 = 0 then Goto ModeADah_AS If PinC.1 = 0 then Goto ModeADit_AS For w3 = 0 to w1 '1 Dit space Pause 1 Next For w3 = 0 to w1 '1 Dit space Pause 1 Next Goto IambicModeA_AS '######################################################################### '# IambicModeB: '# This is my version of Iambic Mode B. It is used with a dual paddle '# Iambic key. I took the approach of polling the opposite contact being '# sent at a rate of every 5 milliseconds at 4Mhz. But choosing to run at '# a speed of 16Mhz. should see it polling at something like 1.25mS. plus '# code execution overheads. (i think?) '# '# So.... rather then polling the opposite contact for closure a fixed '# number of times, say 10 times for dots and 30 times for dashes '# (1:3 ratio) for a variable lengths of time, I took the approach of '# polling the oppsite contact for closure for a fixed time, 1.25 '# milliseconds, but at N amount of times depending on the scaled number '# from the potentiometer. Keeping with a 1:3 ratio, I used a For/Next '# loop method. I am not sure I have it right, I am not a programmer '# and I failed advanced math in high school, go figure. ;-) '# '######################################################################### Menu3: Gosub ClearLCDScreen For b50= 0 to 14 Lookup b50, (" IAMBIC MODE B"), b51 Gosub WriteCharacter Next b50 IambicModeB: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 3 then Goto MainDirectory Setfreq M16 'running at 16Mhz ReadADC A.3, b2 'Dit pause time, scales number 15 to 103, (w1) w1 = b2 * 88 / 255 + 15 'Dah pause time, scales number 45 to 309, (w2) w2 = w1 * 3 'Dots, about 32mS. fast, 210mS. slow CheckModeBContacts: If PinC.1 = 0 then Goto ModeBDit 'if dit paddle is closed, go send a dit If PinC.0 = 0 then Goto ModeBDah 'if dah paddle is closed, go send a dah Goto IambicModeB ModeBDit: b8 = 0 'status bit, keep track of what the Dah paddle is doing, during a Dit High C.4 'turn on the relay High C.2 'turn on the LED Gosub CheckDahContactStatus 'go check the status of the Dah paddle while sending a Dit Low C.4 'turn off the relay Low C.2 'turn off the LED Gosub CheckDahContactStatus 'go check the status of the Dah paddle after sending a Dit If b8 = 1 then ModeBDah 'if the Dah paddle was pressed durig or after a Dit, go send a Dah Goto CheckBothContacsStatus 'nothing else to do, go check both paddle contacts ModeBDah: b9 = 0 'status bit, keep track of what the Dit paddle is doing, during a Dah High C.4 'turn on the relay High C.2 'turn on the LED Gosub CheckDitContactStatus1 'go check the status of the Dit paddle while sending a Dah Low C.4 'turn off the relay Low C.2 'turn off the LED Gosub CheckDitContactStatus2 'go check the status of the Dah paddle while sending a Dah If b9 = 1 then ModeBDit 'if the dit paddle was pressed during or after a Dah, send a Dit Goto CheckBothContacsStatus 'nothing else to do, go check both paddle contacts CheckDahContactStatus: For w3 = 1 to w1 'For/Next W1 times, how long Dit stays on & off, monitor Dah paddle contact Pause 5 '1.25mS. at 16Mhz.? If pinC.0 = 1 then Goto DahContactStatus 'monitor Dah contact for closure b8 = 1 'if Dah contact closed, B8 = 1 DahContactStatus: Next Return CheckDitContactStatus1: For w3 = 1 to w2 'For/Next 3 x W1 times, how long Dah stays on, monitor Dit paddle contact Pause 5 '1.25mS. at 16Mhz.? If pinC.1 = 1 then Goto DahContactStatus1 'monitor Dit contact for closure b9 = 1 'if Dit contact closed, B9 = 1 DahContactStatus1: Next Return CheckDitContactStatus2: For w3 = 1 to w1 'For/Next W1 times, Dit space after Dah, monitor Dit paddle contact Pause 5 '1.25mS. at 16Mhz.? If PinC.1 = 1 then Goto DitContactStatus2 'monitor Dit contact for closure b8 = 1 'if Dah contact closed, B8 = 1 DitContactStatus2: Next Return CheckBothContacsStatus: If PinC.1 = 0 then Goto ModeBDit 'if dit paddle is closed, go send a dit If PinC.0 = 0 then Goto ModeBDah ' Goto CheckModeBContacts 'if no paddle contacts closed, go read the ADC on Pin C.4 '######################################################################### '# IambicModeB_AS: '# This is my version of Iambic Mode B with AUTO SPACING. It is used '# with a dual paddle Iambic key. I took the approach of polling the '# opposite contact being sent at a rate of every 5 milliseconds at '# 4Mhz. But choosing to run at a speed of 16Mhz should see it '# polling at something like 1.25mS. plus code execution overheads. '# (i think?) '# '# So.... rather then polling the opposite contact for closure a '# fixed number of times, say 10 times for dots and 30 times for '# dashes (1:3 ratio) for a variable lengths of time, I took the '# approach of polling the opposite contact for closure for a fixed '# time, 1.25 milliseconds, but at N amount of times depending on the '# scaled number from the potentiometer. Keeping with a 1:3 ratio, '# I used a For/Next loop method. I am not sure I have it right, I am '# not a programmer. '# '# *BEWARE* if you have never used auto spacing, it may take some time '# getting used to it. In the end, it will be worth it as you'll send '# perfect code! '# '######################################################################### Menu4: Gosub ClearLCDScreen For b50 = 0 to 14 Lookup b50, (" IAMBIC MODE B"), b51 Gosub WriteCharacter Next b50 Gosub MoveCursorToSecondLine For b50= 0 to 13 Lookup b50,(" AUTO SPACING"), b51 Gosub WriteCharacter Next b50 IambicModeB_AS: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 4 then Goto MainDirectory SetFreq M16 'runnig at 16Mhz ReadADC A.3, b2 'Dit pause time, scales number 15 to 103, (w1) w1 = b2 * 88 / 255 + 15 'Dah pause time, scales number 45 to 309, (w2) w2 = w1 * 3 'Dots, about 32mS. fast, 210mS. slow CheckModeBContacts_AS: If PinC.1 = 0 then Goto ModeBDit_AS 'if dit paddle is closed, go send a dit If PinC.0 = 0 then Goto ModeBDah_AS 'if dah paddle is closed, go send a dah Goto IambicModeB_AS ModeBDit_AS: b8 = 0 'status bit, keep track of what the Dah paddle is doing, during a Dit High C.4 'turn on the relay High C.2 'turn on the LED Gosub CheckDahContactStatus_AS 'go check the status of the Dah paddle while sending a Dit Low C.4 'turn off the relay Low C.2 'turn off the LED Gosub CheckDahContactStatus_AS 'go check the status of the Dah paddle after sending a Dit If b8 = 1 then ModeBDah_AS 'if the Dah paddle was pressed durig or after a Dit, go send a Dah Goto AutoSpacing_AS 'nothing else to do, go check both paddle contacts ModeBDah_AS: b9 = 0 'status bit, keep track of what the Dit paddle is doing, during a Dah High C.4 'turn on the relay High C.2 'turn on the LED Gosub CheckDitContactStatus1_AS 'go check the status of the Dit paddle while sending a Dah Low C.4 'turn off the relay Low C.2 'turn off the LED Gosub CheckDitContactStatus2_AS 'go check the status of the Dah paddle while sending a Dah If b9 = 1 then ModeBDit_AS 'if the dit paddle was pressed during or after a Dah, send a Dit Goto AutoSpacing_AS 'nothing else to do, go check both paddle contacts CheckDahContactStatus_AS: For w3 = 1 to w1 'For/Next W1 times, how long Dit stays on & off, monitor Dah paddle contact Pause 5 '1.25mS. at 16Mhz.? If pinC.0 = 1 then Goto DahContactStatus_AS 'monitor Dah contact for closure b8 = 1 'if Dah contact closed, B8 = 1 DahContactStatus_AS: Next Return CheckDitContactStatus1_AS: For w3 = 1 to w2 'For/Next 3 x W1 times, how long Dah stays on, monitor Dit paddle contact Pause 5 '1.25mS. at 16Mhz.? If pinC.1 = 1 then Goto DahContactStatus1_AS 'monitor Dit contact for closure b9 = 1 'if Dit contact closed, B9 = 1 DahContactStatus1_AS: Next Return CheckDitContactStatus2_AS: For w3 = 1 to w1 'For/Next W1 times, Dit space after Dah, monitor Dit paddle contact Pause 5 '1.25mS. at 16Mhz.? If PinC.1 = 1 then Goto DitContactStatus2_AS 'monitor Dit contact for closure b8 = 1 'if Dah contact closed, B8 = 1 DitContactStatus2_AS: Next Return AutoSpacing_AS: If PinC.1 = 0 then Goto ModeBDit_AS 'if dit paddle is closed, go send a dit If PinC.0 = 0 then Goto ModeBDah_AS 'if dah paddle is closed, go send a dah Gosub CheckDahContactStatus_AS 'Gosub's for one dit length Gosub CheckDahContactStatus_AS 'Gosub's for one dit length Goto CheckModeBContacts_AS 'if no paddle contacts closed, go read the ADC on Pin A.3 '######################################################################### '# BugMode: '# This is my version of "Bug Mode". It should be used with a single '# paddle key such as the one made by Vibroplex or Bencher. This mode is '# for those who learned on an old "Bug" keyer but now use an electronic '# keyer. I'm not sure if anyone will use this mode. This mode sends '# continuous dots if the dit paddle is pressed and send one long '# steady continuous dash as long as the dah paddle is held closed. '# '######################################################################### Menu5: Gosub ClearLCDScreen For b50 = 0 to 11 Lookup b50, (" BUG MODE"), b51 Gosub WriteCharacter Next b50 BugMode: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 5 then Goto MainDirectory Setfreq M8 ReadADC A.3, b2 'scales the number 20 to 145, (w1) w1 = b2 * 125 / 255 + 20 'No Dah pause time in Bug Mode. 'Dots, about 32mS. fast, 210mS. slow CheckForBugModeDit: If PinC.1 = 0 then Goto BugModeDit CheckForBugModeDah: If PinC.0 = 0 then Goto BugModeDah Goto Bugmode BugModeDit: High C.4 High C.2 For w2 = 0 to w1 Pause 1 Next Low C.4 Low C.2 For w2 = 0 to w1 Pause 1 Next Goto CheckForBugModeDah BugModeDah: Do High C.4 High C.2 Loop until PinC.0 = 1 Low C.4 Low C.2 Goto CheckForBugModeDit '######################################################################### '#StraightKey: '# This is a straight key mode. I guess it's if you ever want to use one '# straight key but key 2 different rigs... not at the same time. Or one '# rig and CWCom without having to keep swaping cables around. '# '######################################################################### Menu6: Gosub ClearLCDScreen For b50= 0 to 13 Lookup b50, (" STRAIGHT KEY"), b51 Gosub WriteCharacter Next b50 StraightKey: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 6 then Goto MainDirectory If PinC.0 = 0 Then High C.2 High C.4 Else Low C.2 Low C.4 EndIf Goto StraightKey '######################################################################### '# '# *** THESE ARE SPARE MENUS *** *** THESE ARE SPARE MENUS *** '# '######################################################################### Menu7: Gosub ClearLCDScreen For b50 = 0 to 12 Lookup b50, (" SPARE MENU"), b51 Gosub WriteCharacter Next b50 SubMenu7: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 7 then Goto MainDirectory Goto SubMenu7 '######################################################################### '# '# *** THESE ARE SPARE MENUS *** *** THESE ARE SPARE MENUS *** '# '######################################################################### Menu8: Gosub ClearLCDScreen For b50= 0 to 12 Lookup b50, (" SPARE MENU"), b51 Gosub WriteCharacter Next b50 SubMenu8: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 8 then Goto MainDirectory Goto SubMenu8 '######################################################################### '# '# *** THESE ARE SPARE MENUS *** *** THESE ARE SPARE MENUS *** '# '######################################################################### Menu9: Gosub ClearLCDScreen For b50 = 0 to 12 Lookup b50, (" SPARE MENU"), b51 Gosub WriteCharacter Next b50 SubMenu9: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 9 then Goto MainDirectory Goto SubMenu9 '######################################################################### '# IambicModeAW_AllOutputs: '# This is Iambic Mode A keying. It uses the Sound command rather then a '# FOR/NEXT scheme. This sends audio to the speaker, keys the reed relay '# and flashes the LED. '# '######################################################################### Menu10: Gosub ClearLCDScreen For b50= 0 to 14 Lookup b50, (" IAMBIC MODE A"), b51 Gosub WriteCharacter Next b50 Gosub MoveCursorToSecondLine For b50 = 0 to 15 Lookup b50,("W/ SOUND & RELAY"), b51 Gosub WriteCharacter Next b50 IambicModeAW_AllOutputs: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 10 Then GOTO MainDirectory Setfreq M16 ReadADC A.2, b0 w0 = b0 * 110 / 255 + 5 ReadADC A.3, b2 w1 = b2 * 62 / 255 + 8 'Dit pause time, scales number 21 to 148, (w1) w2 = b2 * 3 'Dah pause time, scales number 63 to 444, (w2) 'Dots, about 32mS. fast, 210mS. slow CheckForModeADitW_AllOutputs: If PinC.1 = 0 then Goto ModeADitW_AllOutputs CheckForModeADahW_Alloutputs: If PinC.0 = 0 then Goto ModeADahW_AllOutputs Goto IambicModeAW_AllOutputs ModeADitW_AllOutputs: High C.4 High C.2 Sound C.5, (b0, w1) Low C.4 Low C.2 Sound C.5, (0, w1) Goto CheckForModeADahW_AllOutputs ModeADahW_AllOutputs: High C.4 High C.2 Sound C.5, (b0, W2) Low C.4 Low C.2 Sound C.5, (0, w1) Goto CheckForModeADitW_AllOutputs '######################################################################### '# IambicModeAW_RelayOnly: '# This is Iambic Mode A keying. It uses the Sound command rather then a '# FOR/NEXT scheme. This only keys the reed relay and flashes the LED. It '# does not send audio to the speaker. '# '######################################################################### Menu11: Gosub ClearLCDScreen For b50= 0 to 14 Lookup b50, (" IAMBIC MODE A"), b51 Gosub WriteCharacter Next b50 Gosub MoveCursorToSecondLine For b50 = 0 to 12 Lookup b50,(" RELAY ONLY"), b51 Gosub WriteCharacter Next b50 IambicModeAW_RelayOnly: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 11 Then GOTO MainDirectory Setfreq M16 ReadADC A.3, b2 w1 = b2 * 62 / 255 + 8 'Dit pause time, scales number 21 to 148, (w1) w2 = b2 * 3 'Dah pause time, scales number 63 to 444, (w2) 'Dots, about 32mS. fast, 210mS. slow CheckForModeADitW_RelayOnly: If PinC.1 = 0 then Goto ModeADitW_RelayOnly CheckForModeADahW_RelayOnly: If PinC.0 = 0 then Goto ModeADahW_RelayOnly Goto IambicModeAW_RelayOnly ModeADitW_RelayOnly: High C.4 High C.2 Sound C.5, (0, w1) Low C.4 Low C.2 Sound C.5, (0, w1) Goto CheckForModeADahW_RelayOnly ModeADahW_RelayOnly: High C.4 High C.2 Sound C.5, (0, W2) Low C.4 Low C.2 Sound C.5, (0, w1) Goto CheckForModeADitW_RelayOnly '######################################################################### '# IambicModeAW_SoundOnly: '# This is Iambic Mode A keying. It uses the Sound command rather then a '# FOR/NEXT scheme. This only sends audio to the speaker and flashes the '# LED. It does NOT key the reed relay. It's just for practice. '# '######################################################################### Menu12: Gosub ClearLCDScreen For b50= 0 to 14 Lookup b50, (" IAMBIC MODE A"), b51 Gosub WriteCharacter Next b50 Gosub MoveCursorToSecondLine For b50 = 0 to 12 Lookup b50,(" SOUND ONLY"), b51 Gosub WriteCharacter Next b50 IambicModeAW_SoundOnly: Gosub Check4PoleSwitch Gosub Check12PoleSwitch If b55 <> 12 Then GOTO MainDirectory Setfreq M16 ReadADC A.2, b0 w0 = b0 * 110 / 255 + 5 ReadADC A.3, b2 w1 = b2 * 62 / 255 + 8 'Dit pause time, scales number 21 to 148, (w1) w2 = b2 * 3 'Dah pause time, scales number 63 to 444, (w2) 'Dots, about 32mS. fast, 210mS. slow CheckForModeADitW_SoundOnly: If PinC.1 = 0 then Goto ModeADitW_SoundOnly CheckForModeADahW_SoundOnly: If PinC.0 = 0 then Goto ModeADahW_SoundOnly Goto IambicModeAW_SoundOnly ModeADitW_SoundOnly: High C.2 Sound C.5, (b0, w1) Low C.2 Sound C.5, (0, w1) Goto CheckForModeADahW_SoundOnly ModeADahW_SoundOnly: High C.2 Sound C.5, (b0, W2) Low C.2 Sound C.5, (0, w1) Goto CheckForModeADitW_SoundOnly '######################################################################### '# '# *** THESE ARE THE SUB-ROUTINES *** *** THESE ARE THE SUB-ROUTINES *** '# '######################################################################### '######################################################################### '# Check4PoleSwitch: '# This checks the 0 - 5 VDC analog value of the 4 resistors and then '# calculates a whole number value from 0 to 3. The code then does a '# "Select Case" to determine which memory slot# to "Goto". This happens if '# the 4 pole switch has been turned to a different position. '# NOTE:"Run" is basically a "Goto". You can't "Gosub" to anothr slot. '# '######################################################################### Check4PoleSwitch: ReadADC C.3, b52 b53 = b52 - 32 / 63 Select Case b53 Case 0 Return Case 1 Run 1 'goes to memory slot #1 Case 2 Run 2 'goes to memory slot #2 Case 3 Run 3 'goes to memory slot #3 End Select Return '######################################################################### '# Check12PoleSwitch: '# This checks the 0 - 5 VDC analog value of the 12 resistors and then '# calculates a whole number value from 1 to 12. Eventually the code goes '# back to the "Main Directory" and the Select Case determines which menu '# to "Goto". This happens if the 12 pole switch has been turned to a '# different position. '# '######################################################################### Check12PoleSwitch: ReadADC A.1, b54 b55 = b54 - 12 / 21 + 1 Return '######################################################################### '# ClearSomeWordsAndBytes: '# This clears Words W0 - W18 or Bytes B0 - B37 and sets them all to 0. '# '######################################################################### ClearSomeWordsAndBytes: For w23 = 0 to 18 Poke w23, 0 Next w23 = 0 Return '######################################################################### '######################################################################### '# '# LCD STUFF! LCD STUFF! LCD STUFF! LCD STUFF! LCD STUFF! LCD STUFF! '# '######################################################################### '######################################################################### '######################################################################### '# Initialise: '# This is for setting up the 2 x 16 LCD upon power up. ie. 8 bit mode, '# cursor on, cursor blinking etc. etc. '# '# You must initialise the LCD for it to work properly! This is done by '# sending instructions to the LCD after power up. Otherwise it will NOT '# work! Trust me. '# '# The LCD used is a JAYCAR Electronics part number #QP5515. It's a '# green non backlit 2 lines by 16 character LCD display. '# '# Sending the following instructions on Port B pins to the LCD equals: '# FUNCTION SET '# 56 = 8 Bit mode, 2 lines, 5x7 font. '# '# DISPLAY & CURSOR ON OR OFF '# 12 = Turns the display on and cursor off '# '# There are many other instructions that are not used in this project. '# Consult the full documentation that comes with your LCD. Normally '# the little cheat sheet that comes with the LCD does not contain this '# information. You may have to consult the manufactures web site. '# '######################################################################### Initialise: Let PinsB = 0 'turn off all outout pins on port B Let PinsB = 56 'Port B pins = %00111000 8-bit operation, 2 lines Low C.6 'Set R/S on LCD low Pulsout C.7, 1 '10uS pulse on C.7 LCD E "enable" PinsB = 12 'Port B pins = %00001100 Turn display on, cursor off Low C.6 'Set R/S on LCD low Pulsout C.7, 1 '10uS pulse on C.7 LCD E "enable" Return '######################################################################### '# WriteCharacter: '# For writing characters to be displayed on the LCD. ie. Lettrs, Numbers, '# Punctuation etc. etc. '# '# Output C.6 is the R/S line on LCD. High to write characters to the LCD '# and LOW to write instructions to the LCD '# '# Output C.7 is the E or "Enable" line on the LCD. Once the PICAXE '# presents the variable b51 onto the LCD's data lines, D0-D7, the E line '# needs to be pulsed for 10uS so the LCD can write the character to the '# LCD screen or the instruction into the LCD. '# '# LCD data pins D7=#,D6=#,D5=#,D4=#,D3=#,D2=#,D1=#,D0=# '# 128 64 32 16 8 4 2 1 '# '######################################################################### WriteCharacter: Let pinsB = b51 'put variable b51 onto Port B pins High C.6 Pulsout C.7, 1 '10uS pulse on C.7 LCD E "enable" Return '######################################################################### '# WriteInstruction: '# For writing instructions to the LCD. ie. Moving the cursor, clearing '# the screen etc. etc. '# '# Output C.6 is the R/S line on the LCD. High to write characters to the '# LCD and LOW to write instructions to the LCD. '# '# Output C.7 is the E or "Enable" line on the LCD. Once the PICAXE '# presents the variable b51 onto the LCD's data lines, D0-D7, the E line '# needs to be pulsed for 10uS so the LCD can write the character to the '# LCD screen or the instruction into the LCD. '# '# LCD data pins D7=#,D6=#,D5=#,D4=#,D3=#,D2=#,D1=#,D0=# '# 128 64 32 16 8 4 2 1 '# '######################################################################### WriteInstruction: Let pinsB = b51 'put variable b51, %######## onto Port B pins Low C.6 Pulsout C.7, 1 '10uS pulse on C.7 LCD E "enable" Return '######################################################################### '# ClearLCDScreen: '# This instruction clears the screen on the 2 x 16 LCD '# '# Let b51 = 1 = %00000001 '# LCD data pins D7=0,D6=0,D5=0,D4=0,D3=0,D2=0,D1=0,D0=1 '# 128 64 32 16 8 4 2 1 '# '######################################################################### ClearLCDScreen: Let b51 = 1 Gosub WriteInstruction Return '######################################################################### '# MoveCursorToSecondLine: '# This instruction moves the cursor to the beginning of the second line '# on the 2 x 16 LCD '# '# Let b51 = 192 = %11000000 '# LCD data pins D7=1,D6=1,D5=0,D4=0,D3=0,D2=0,D1=0,D0=0 '# 128 64 32 16 8 4 2 1 '# '######################################################################### MoveCursorToSecondLine: Let b51 = 192 Gosub WriteInstruction Return '######################################################################### '# Initialising: '# This instruction writes the word "*INITIALISING*" to the LCD upon power '# up. '# '######################################################################### Initialising: Gosub ClearLCDScreen Let b51 = 129 Gosub WriteInstruction For b50 = 0 to 13 Lookup b50, ("*INITIALISING*"), b51 Gosub WriteCharacter Next b50 Pause 1000 Return '######################################################################### '# SupplyVoltage: '# This instruction moves the cursor to the beginning of the 2 x 16 LCD's '# second line '# '######################################################################### SupplyVoltage: Gosub ClearLCDScreen Let b51 = 129 'Move cursor to position 129 on LCD Gosub WriteInstruction For b50 = 0 to 11 Lookup b50, ("SUPPLY "), b51 Gosub WriteCharacter Next b50 ReadADC10 A.0,W19 W19 = W19 * 18 / 10 BintoAscii W19, b40, b41, b42, b43, b44 Let b51 = 137 'mover cursor Gosub WriteInstruction Let b51 = b41 Gosub WriteCharacter Let b51 = b42 Gosub WriteCharacter Let b51 = 46 'ACSII #46 = (.) GOSUB WriteCharacter Let b51 = b43 Gosub WriteCharacter Let b51 = b44 Gosub WriteCharacter Let b51 = "V" Gosub WriteCharacter Pause 1000 Return '######################################################################### '# MORSE CODE STUFF '# Encoded character numbers, NOT ASCII numbers. These numbers are for a '# "modulus divide" and a "shift right" in the Morse routine. '# '######################################################################### REM A .- B -... C -.-. D -.. E . F ..-. REM G --. H .... I .. J .--- K -.- L .-.. REM M -- N -. O --- P .--. Q --.- R .-. REM S ... T - U ..- V ...- W .-- X -..- REM Y -.-- Z --.. REM 1 .---- 2 ..--- 3 ...-- 4 ....- 5 ..... REM 6 -.... 7 --... 8 ---.. 9 ----. 0 ----- REM ALL THE PUNCTUATION THAT YOU WILL PROBABLY EVER NEED :-) REM FULL STOP [.] .-.-.- COLON [:] ---... REM COMMA [,] --..-- SEMICOLON [;] -.-.-. REM QUESTION MARK [?] ..--.. EQUAL SIGN double dash [=] -...- REM APOSTROPHE ['] .----. PLUS [+] .-.-. REM EXCLAMATION MARK [!] -.-.-- HYPHEN minus [-] -....- REM FWD SLASH [/] -..-. UNDERSCORE [_] ..--.- REM PARENTHESIS open [(] -.--. QUOTATION MARK ["] .-..-. REM PARENTHESIS closed [)] -.--.- DOLLAR SIGN [$] ...-..- REM AMPERSAND [&] .-... AT SIGN [@] .--.-. REM *** ENCODED CHARACTER LETTERS *** REM A 6, B 17, C 21, D 9, E 2, F 20, REM G 11, H 16, I 4, J 30, K 13, L 18, REM M 7, N 5, O 15, P 22, Q 27, R 10, REM S 8, T 3, U 12, V 24, W 14, X 25, REM Y 29, Z 19, REM *** ENCODED CHARACTER NUMBERS *** REM 1 62, 2 60, 3 56, 4 48, 5 32, REM 6 33, 7 35, 8 39, 9 47, 0 63, REM *** ENCODED CHARACTER PUNCTUATION *** REM FULL STOP [.] 106 COLON [:] 71 REM COMMA [,] 115 SEMICOLON [;] 85 REM QUESTION MARK [?] 76 EQUAL SIGN double dash [=] 49 REM APOSTROPHE ['] 94 PLUS [+] 42 REM EXCLAMATION MARK [!] 117 HYPHEN minus [-] 97 REM FWD SLASH [/] 41 UNDERSCORE [_] 108 REM PARENTHESIS open [(] 45 QUOTATION MARK ["] 82 REM PARENTHESIS closed [)] 109 DOLLAR SIGN [$] 200 REM AMPERSAND [&] 34 AT SIGN [@] 86 '######################################################################### '# LCD INFORMATION AND NOTES '# Character ASCII numbers. '# '######################################################################### REM *** TYPICAL CHARACTERS USED FOR THE LCD *** REM LETTER BINARY DECIMAL # LETTER BINARY DECIMAL # REM A %01000001 65 N %01001110 78 REM B %01000010 66 O %01001111 79 REM C %01000011 67 P %01010000 80 REM D %01000100 68 Q %01010001 81 REM E %01000101 69 R %01010010 82 REM F %01000110 70 S %01010011 83 REM G %01000111 71 T %01010100 84 REM H %01001000 72 U %01010101 85 REM I %01001001 73 V %01010110 86 REM J %01001010 74 W %01010111 87 REM K %01001101 75 X %01011000 88 REM L %01001100 76 Y %01011001 89 REM M %01001101 77 Z %01011010 90 REM ALL UPPER CASE LETTERS! REM *** TYPICAL NUMBERS USED FOR THE LCD (future) *** REM NUMBER BINARY DECIMAL # NUMBER BINARY DECIMAL # REM 0 %00110000 48 5 %00110101 53 REM 1 %00110001 49 6 %00110110 54 REM 2 %00110010 50 7 %00110111 55 REM 3 %00110011 51 8 %00111000 56 REM 4 %00110100 52 9 %00111001 57 REM *** NOTES NOTES NOTES NOTES NOTES NOTES NOTES *** REM This is how it looks on the Port B pins REM D7.....D0 REM | | REM | | REM V V REM %00000000 REM LCD data pins D7=0,D6=0,D5=0,D4=0,D3=0,D2=0,D1=0,D0=0 REM 128 64 32 16 8 4 2 1 REM Example.... REM Decimal 63 = D7=0 D6=0 D5=1 D4=1 D3=1 D2=1 D1=1 D0=1 REM Add them up --> 0 0 32 16 8 4 2 1 = 63 REM So, 63 = %00111111 and ASCII #63 is a "Question Mark" REM D7=2^7 D6=2^6 D5=2^5 D4=2^4 D3=2^3 D2=2^2 D1=2^1 D0=2^0 '################################################################ '# *** PLEASE READ THE NOTES *** *** PLEASE READ THE NOTES *** # '################################################################ 'A place I leave myself notes for slot #0.