'ROTATOR CONTROL HEAD OH1TV 'for Idiom Press Rotorcard v.3.1 16.6.2013 ' 455/2048 bytes '----------------------------------------------------------------------------- 'PIC processor Picaxe 14M2, clock frequency 16MHz, 'Serial OLED display 16x2 characters Picaxe AXE133Y 'PS/2 Numerical Pad Deltaco TB-72 as an input device. 'Show Err, if no reply from rotator 'Data speed 4800baud 'PIN CONFIGURATION PICAXE-14M2 ROTORCARD COMMANDS 'Pin1 = V+ = +5V AP1xxx; sets target bearing 'Pin2 = C.5 = programming in AM1; executes rotation 'Pin3 = C.4 = AI1; inquires current bearing 'Pin4 = C.3 = ;xxx respond, xxx = 000-360 'Pin5 = C.2 = kb clock ; terminates rotation 'Pin6 = C.1 = kb data 'Pin7 = C.0 = 'Pin8 = B.5 = serial in RS232 'Pin9 = B.4 = 'Pin10= B.3 = serial out RS232 'Pin11= B.2 = 'Pin12= B.1 = serial to display 'Pin13= B.0 = programming out 'Pin14= 0V = ground 9/14 pins used 'VARIABLES USED 'b0 = keyboard data 'b1 = 100īs of current bearing, ASCII byte 'b2 = 10īs of current bearing, ASCII byte 'b3 = 1īs of current bearing, ASCII byte 'b8 => w4 = target 1-360 'b9 => w4 = target 'b11 = 100īs in transmitted target, ASCII byte 'b12 = 10īs in transmitted target, ASCII byte 'b13 = 1's in transmitted target, ASCII byte 'b14 = 10000's of target, ASCII byte, value not used 'b15 = 1000's of target, ASCII byte, value not used ' '-------------------------------------------------------------------------------- kbled %00000111 'activate the keypad PS/2 pause 1000 'display set-up time 1s setfreq m16 'set clock to 16MHz serout B.1, N2400_16,(254,1) 'clear display serout B.1 ,N2400_16,(254,128,"Target ",32,32,32," deg") 'pre-print serout B.1 ,N2400_16,(254,192,"Current ",32,32,32," deg") Main: kbin [3000,Update],b0 'read keyboard,update current every 3s if b0=$69 then 'number 1 is 225deg w4=225 goto Display_T 'display target elseif b0=$72 then 'number 2 is 180deg w4=180 goto Display_T elseif b0=$7A then 'number 3 is 135deg w4=135 goto Display_T elseif b0=$6B then 'number 4 is 270deg w4=270 goto Display_T elseif b0=$74 then 'number 6 is 90deg w4=90 goto Display_T elseif b0=$6C then 'number 7 is 315deg w4=315 goto Display_T elseif b0=$75 then 'number 8 is 360deg w4=360 goto Display_T elseif b0=$7D then 'number 9 is 45deg w4=45 goto Display_T elseif b0=$70 then 'number 0 is 240deg w4=240 'PY, LU, PA, goto Display_T elseif b0=$71 then './Del is 160deg w4=160 'Arab goto Display_T elseif b0=$77 then 'num lock is 300deg w4=300 'east coast USA goto Display_T elseif b0=$4A then '/ is 330deg w4=330 'west coast USA goto Display_T elseif b0=$7C then '* is 55deg w4=55 'Japan goto Display_T elseif b0=$73 then serout B.3 ,N4800_16,(";") 'number 5 = terminate rotation goto Main endif if b0=$79 then goto Up '+ set target bearing 1 up if b0=$7B then goto Down '- set target bearing 1 down if b0=$5A then goto Target 'Enter, start moving goto Main Up: w4=w4+1 'target 1deg up if w4>360 then w4=w4-360 'overflow correction endif goto Display_T Down: w4=w4-1 'target 1deg down if w4<1 then w4=w4+360 'overflow correction endif goto Display_T Display_T: 'display target bearing w4 bintoascii w4,b14,b15,b11,b12,b13 'conversion to ascii serout B.1,N2400_16,(254,137,b11,b12,b13) 'show target bearing pause 500 'step time 125ms goto Main Target: 'send 3-digit ASCII-coded target serout B.3 ,N4800_16,("AP1",b11,b12,b13,59) 'send new target bearing pause 60 'wait 15ms serout B.3 ,N4800_16,("AM1;") 'execute rotation pause 400 'wait 100ms goto Main Update: 'cannot use return with kbin timeout gosub Current 'ends with return goto Main Current: serout B.3 ,N4800_16,("AI1;") 'request current bearing serin [500,Noreply],B.5 ,N4800_16,(59),b1,b2,b3 'receive bearing, 125ms timeout, serout B.1,N2400_16,(254,201,b1,b2,b3) 'display current bearing return Noreply: serout B.1,N2400_16,(254,201,"Err") 'show Err goto Main '--------------------------------------------------------------------------------------