'DDS-3-1-1 25.2.2014 OH1TV 'Picaxe-20X2 'Push-button frequency setting 525/4096 bytes '------------------------------------------------------------------------------- 'This is a control SW for AD9850 based DDS-VFO, EIM377 or similar '- Good for setting frequencies in 3.9Hz steps. kHz's are even. '- Calculation error is 0.003ppm, less than 0.1Hz '- Displays frequency in format 14 195.011 kHz '- The serial display is Picaxe AXE133Y with yellow OLED's, 16x2 characters '- Bands 160-10m can be selected with up and down push button '- Up and down 1kHz push buttons '- Up and down 12Hz push buttons (4Hz smallest step possible) '- Power off function fot TX mute '- Calibration with multiplier decimal b7 '------------------------------------------------------------------------------- 'Picaxe-20X2 PINOUT: 'pin 1 = +5V pin 20= 0V 'pin 2 = serial in pin 19= A.0 =serial out 'pin 3 = C.7 =4Hz dwn pin 18= B.0 =serial display 'pin 4 = C.6 =4Hz up pin 17= B.1 = 'pin 5 = C.5 =1kHz dwn pin 16= B.2 = 'pin 6 = C.4 =1kHz up pin 15= B.3 = 'pin 7 = C.3 =band up pin 14= B.4 = 'pin 8 = C.2 =band dwn pin 13= B.5 = 'pin 9 = C.1 =hspi sdo,DDS data pin 12= B.6 =DDS FQ_UD 'pin 10= C.0 =mute pin 11= B.7 =hspi sck,DDS clock 'VARIABLES available in X2 b0-b55 or w0-w27 'b0 = band counter w20= sub-kHz target+1000 'b1 = w21= sub-kHz 'w1 = Fout in kHz w22= 'w2 = multiplier w23= 'w3 = b6= decimals of Fout w24= 'w3 = b7= decimals of multiplier w25= 'w4 = byte x byte,display data w26= 'w5 = byte x byte,display data w27= 'w6 = byte x byte,display data 'w7 = byte x byte,display data 'w8 = byte x byte,display data 'w9 = byte x byte 'w10= byte x byte 'w11= byte x byte 'w12= byte x byte 'w13= LSB sum 'w14= MSB sum carry 'w15= LSB sum 'w16= MSB sum carry 'w17= LSB sum 'w18= MSB sum carry 'w19= MSB, LSB sum '------------------------------------------------------------------------------- 'MULTIPLYING PRINCIPLE,(256 based numeral system) ' ' w1,b6 b3 b2 b6 Fout ' w2,b7 b5 b4 b7 multiplier ' ---------------------------- ' w6 w5 w4 ' w9 w8 w7 ' w12 w11 w10 ' ---------------------------- ' w19 w17 w15 w13 LSB ' w18 w16 w14 MSB carry ' '------------------------------------------------------------------------------- pause 2000 'let display to start up serout B.0 ,N2400,(254,1) 'clear display serout B.0 ,N2400,(254,128," kHz") 'preprint on upper line, 12 blank serout B.0 ,N2400,(254,192,"dds-3-1-1 oh1tv") 'preprint on lower line w2=34359 'multiplier, b5=124, b4=55 b7=120 '"decimal" byte of the multiplier 'nominal 189, use for calibration b0=6 'band selection when opening goto Band Main: pause 100 if PinC.7 =0 then b0=b0-1 'step one band down if b0>254 then b0=b0+9 endif goto Band elseif PinC.6 =0 then b0=b0+1 'step one band up if b0>8 then b0=b0-9 endif goto Band elseif PinC.4 =0 then w1=w1+1 'step 1kHz up goto Display elseif PinC.5 =0 then w1=w1-1 'step 1kHz down goto Display elseif PinC.2 =0 then w20=w20+3 'step 12Hz up goto Display elseif PinC.3 =0 then w20=w20-3 'step 12Hz down goto Display elseif PinC.0 =0 then goto Mute 'power off endif goto AD9850 Band: lookup b0,(1830,3520,7020,10110,14020,18080,21020,24900,28020),w1 w20=1000 'sub-kHz bias, clear pause 100 'slow down Display: if w20<1000 then 'carry/borrow from/to sub-kHz w20=w20+256 w1=w1-1 'borrow -1kHz elseif w20>1255 then w20=w20-256 w1=w1+1 'carry +1kHz endif b6=w20-1000 'remove bias w21=b6*39 'scale sub-kHz data bintoascii w21,b12,b11,b10,b9,b8 'convert sub-kHz into ascii bintoascii w1,b17,b16,b15,b14,b13 'convert kHz's into ascii if b17=48 then b17=32 'blank first number if zero endif serout B.0 ,N2400,(254,130,b17,b16,32,b15,b14,b13,46,b11,b10,b9) 'upper line,set cursor, format 14 195.007 Multiply: 'byte x byte as in table above w4=b7*b6 w5=b7*b2 w6=b7*b3 w7=b4*b6 w8=b4*b2 w9=b4*b3 w10=b5*b6 w11=b5*b2 w12=b5*b3 'sum and carry as in table above w13=b9+b10+b14 'LSB,s w14=b27+b11+b15 'MSB's, carry w15=w14+b12+b16+b20 'LSBy's w16=b31+b13+b17+b21 'MSBy's,carry w17=w16+b18+b22 'LSBy's w18=b35+b19+b23 'MSBy's carry w19=w18+w12 'MSB, LSB 'The binary result with 4 bytes is b39,b38,b34,b30 AD9850: spiout B.7, C.1,LSBFirst_L,(b30,b34,b38,b39,0) 'send control word to DDS high B.6 'FQ_UD on low B.6 'FQ_UD off goto Main Mute: spiout B.7, C.1,LSBFirst_L,(b30,b34,b38,b39,4) 'set power off high B.6 'FQ_UD on low B.6 'FQ_UD off goto Main '------------------------------------------------------------------------------- 'In AD9850 module EIM377 ' -Parallel input pins D2-D6 shall be grounded, D0, D1 and D7 are left open.. ' -Reset shall be grounded '-------------------------------------------------------------------------------