'PICAXE-08 memory workout demo via Eric van de Weyer & Stan.SWAN Ver 1.02 27th June 2003 'For Silicon Chip August 2003 PICAXE article. Author - Stan.SWAN => s.t.swan@massey.ac.nz 'Ref. Edwin.C =>chick@chickene.freeserve.co.uk -June 2002 RSGB "RadComm" "28" version too 'Program (derived from a Basic Stamp-1 idea ) sends short repeating Morse Code ID message '---------------------------------------------------------------------------------------- 'Almost unbelievably up to ~35 Morse characters can be stored in the tiny PICAXE-08 RAM ! 'Output here just simple Piezo speaker at PICAXE Pin 0, but could be used to key a Tx etc 'Only other component needed = 10k pull up R pin 3 to +ve rail to avoid "floating" 1/0 'Note - although now near obsolete for messages,International Morse Code ( CW ) still has 'wide use for beacons etc since decoding can be via eye or ear,& even unskilled observers 'can thus "read" simple IDs & status at just a few (5?)words per minute.Of course sending 'SOS via torch etc still suits emergencies! Scouting days now long past? Morse chs.are... ' 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 --.. 1 .---- 2 ..--- 3 ...-- 4 ....- ' 5 ..... 6 -.... 7 --... 8 ---.. 9 ----. 0 ----- ' Full stop .-.-.- Comma --..-- Slash -....- ' 'By tradition 1 dah/dash = 3 dits/dots with letter space = 3 dits & word spacing 7 dits ' 'How DOES this work !? Each ch.to be generated is programmed in as a number whose binary 'equiv. then generates the code ! The 5 MSBs(Most Significant Bits =LHS)represent dots & 'dashes, with dit=0 & dah=1. The last 3 LSB (Least Significant Bits = RHS) indicate how 'many elements in a ch. Hence V=00010100 (100 =4 elements). Bit 5 is meaningless here. 'Converting to decimal yields 20. Another ? K=10100011 = decimal 163 ( 011= 3 elements) 'Here's is a list of these characters (abrev. as ch. in comments) & their equiv. number '------------------------------------------------------------------------------------- 'A - 66 B - 132 C - 164 D - 131 E - 1 F - 36 'G - 195 H - 4 I - 2 J - 116 K - 163 L - 68 'M - 194 N - 130 O - 227 P - 100 Q - 212 R - 67 'S - 3 T - 129 U - 35 V - 20 W - 99 X - 148 'Y - 180 Z - 196 1 - 125 2 - 61 3 - 29 4 - 13 '5 - 5 6 - 133 7 - 197 8 - 229 9 - 245 0 - 253 '= - 141 / - 149 . - 86 , - 206 ' 'Encode to suit - thus "AUSTRALIA 2003" = 66,35,3,129,67,66,68,2,66,0,61,253,253,29 '------------------------------------------------------------------------------------- 'Copy & paste main program below to "08" editor via=> www.picaxe.orcon.net.nz/morse.bas 'Still scope for "telemetry" or tweaking SLEEP/NAP,as only 105 bytes (of 128)used as is! '------------------------------------------------------------------------------------- ' Symbol Tone = 100 'sets the tone frequency ( range 20 -127 ) Symbol Quiet = 0 'set quiet tone Symbol Dit_length = 7 'set length of a dot (7 milliseconds)- yields 10wpm Symbol Dah_length = 21 'set length of a dash (21 mS = 3 dots long) Symbol Wrd_Length = 43 'set space between words (43 mS = 2 dashes, 6 dots) Symbol Character = b0 'set register for ch. Symbol Index1 = b6 'loaded with number of chs. in message Symbol Index2 = b2 'counts the number of elements Symbol Elements = b4 'set register for number of elements in ch. Start: 'NB - good program spot to turn on ID, via sensor etc maybe? sleep 5 '5 sec low power delay(varies if no pullup R)-modify to suit if pin3 = 1 then Identify 'wait for high input on pin 3 to start message- 1 by default goto start 'if no input,loop to start. Identify: ' routine to lookup ch.& put its value into the ch. register for Index1 = 0 to 27 'cycle through lookup for times = number of ch. in message lookup Index1,(3,2,68,2,164,227,130,0,0,164,4,2,100,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),Character ' This means (S I L I C O N C H I P dit dit dit etc gosub Morse 'go to the ch. generation routine next 'loop back to get next ch. and load it goto Start 'return to start to wait for next input Morse: let Elements = Character & %00000111 'look at 3 LS digits and load into Elements register if Elements = 0 then Word_sp ' % means binary Bang_Key: for Index2 = 1 to elements 'loop through correct no. of times for number of elements if Character >= 128 then Dah 'test MS digit of ch. If it is 1 goto the Dah sub routine goto Dit 'if it is 0 goto the Dit sub routine Reenter: let Character = Character * 2 'do a left shift on all the bits in ch. next 'loop back to get the next element gosub Char_sp 'go to sub routine to put in inter-ch. space return 'return to Identify routine to get next ch. to send Dit: sound 0,(Tone,Dit_Length) 'sound tone for dit length sound 0,(Quiet,Dit_Length) 'silence for dit length goto Reenter 'return to look at next element of ch. Dah: sound 0,(Tone,Dah_Length) 'sound tone for dah length sound 0,(Quiet,Dit_Length) 'silence for dit length goto Reenter 'return to look at next element of ch. Char_sp: sound 0,(Quiet,Dah_Length) 'send silence for dah length after ch.completely sent return 'return to get next character Word_sp: sound 0,(Quiet,wrd_length) 'send silence for break between words return 'return to get next ch.