'{$STAMP BS2} '{$PBASIC 2.5} 'Satellite tracking interface for use between the 'NOVA satellite tracking software package and the 'Yaseu G-5500 azmeth/elevation rotor system. The 'circuit design and this software is an adaptation 'of a similar system developed by Gene Brigman, KC4SA, 'and Mark Hammond N8MH. Specifics of their system 'can be found at: 'http://webpages.charter.net/mlhammond/ham/SAEBRTrack/. 'Information on the NOVA tracking can be found at: 'http://www.nlsa.com/. 'BY MARK SPENCER, WA8SME. Author can be contact at: 'mspencer@arrl.org, or by phone 860-594-0396. 'working variables new_az VAR Word 'place holder for desired azimuth current_az VAR Word 'place holder for current az new_el VAR Word 'place holder for desired elevation current_el VAR Word 'place holder for current el old_az VAR Word 'place holder for old az old_el VAR Word 'place holder for old el direction VAR Nib 'rotor direction relay pin variable delta VAR Word 'working space for difference calculations counter VAR Byte 'working space for run-away rotor trap 'analog to digital converter (adc) working variables adc_config VAR Nib 'configuration nibble for ADC 'startb VAR adc_config.BIT0'ADC start bit 'sgldif VAR adc_config.BIT1'ADC mode select chan VAR adc_config.BIT2'ADC channel select 'msbf VAR adc_config.BIT3'ADC 0's sent after transfer adc VAR Word 'adc data result working space 'adc constants and pin assignments adc_cs CON 0 'adc chip select pin 0 adc_clk CON 1 'adc clock pin 1 adc_data CON 2 'adc data line pin 2 'BStamp relay direction control and communication constants portin CON 16 'Stamp to computer I/O pin ccw CON 4 'counter clockwise relay cw CON 5 'clockwise relay up CON 6 'up relay down CON 7 'down relay deg_toler CON 1 'a change of 1 degree az or el needed to change 'rotor position. Experiment with this number 'if rotor action is too aggressive while tracking 'satellite az_tolerance CON 8 'adc bit tolerance el_tolerance CON 20 'experiment with these value if there is erratic 'rotor operation. Larger values will give larger +/- 'degree settings on position changes. A value of '8 for az is within 1 degree, a value of 20 for el 'is within 1 degree. max_count CON 100 'trap for run-away rotor limit 'main program DIRS = %0000000011110011 'output pins 0, 1, input pin 2 for adc 'output pins 4, 5, 6, 7 for relay controls OUTB = 0 'set relay outputs to off PAUSE 50 'let power and ADC stabilize GOSUB get_current_az 'get starting az position GOSUB get_current_el 'get starting el position old_az = 0 'clear storage variables for start old_el = 0 main: 'begining of main program loop GOSUB get_new_az_el 'get position data from computer 'if auto tracking parameters for elevation are set 'to -5 degrees and 185 degrees, then NOVA will 'return negative elevation values when the satellite 'is below the horizon. The next line will ignore 'negative elevations. If the parameters are set as 'default 0 and 180 degrees, then the interface will 'track the satellite even if it is below the horizon 'because NOVA will send 0 degrees when the satellite 'is below the horizon. IF new_el < 0 OR new_el > 180 THEN main 'because the BStamp uses fuzzy integer math during 'comparisons of negative numbers, this line avoids 'problems by checking for the desired range of positive 'elevations (0 to 180 degrees). IF ((ABS(old_az-new_az) < deg_toler)AND (ABS(old_el-new_el) < deg_toler)) THEN main 'if new az and/or el not displaced by at least 1 'degree then wait for another reading to prevent 'excessive rotor action old_az=new_az 'store new values as old for next position check old_el=new_el GOSUB convert_az_el 'convert new position degrees to adc bits GOSUB move_az PAUSE 50 'slight pause between rotor movements GOSUB move_el GOTO main 'loop back for next position change 'subroutines get_new_az_el: 'get new position from NOVA SERIN portin, 84,2000, get_new_az_el, [WAIT ("AZ"), DEC new_az, WAIT ("."), WAIT ("EL"), SDEC new_el, WAIT (".")] 'PAUSE 75 'some pause here improved performance RETURN 'get_new_az_el convert_az_el: 'math routine that converts angles to 'expected adc output 'convert new az. high byte is integer part of slope 'low byte is fractional part in hex (round .18*256) new_az=new_az*/$082e+30 'y=angle*8.18+30 'convert new el. high byte is integer part of slope 'low byte is fractional part in hex (round .56*256) new_el=new_el*/$148f+12 'y=angle*20.56+12 RETURN 'convert_az_el move_az: 'move az position counter=0 'reset run-away trap counter GOSUB get_current_az 'read current az position direction = cw 'assume default direction IF new_az < current_az THEN 'if current greater than new (to right) then direction = ccw 'change direction ENDIF 'old_delta=0 delta = ABS(new_az - current_az) 'determine how much position change is required IF delta < az_tolerance THEN RETURN 'if change is less than tolerance, do nothing 'and return HIGH direction 'turn on appropriate direction relay DO WHILE delta>az_tolerance 'if delta greater than tolerance then begin movement GOSUB get_current_az 'keep rechecking current az position delta = ABS(new_az - current_az)'recheck difference counter=counter+1 'update the run-away counter IF counter>max_count THEN 'if the run-away counter is exceeded LOW direction 'set relay off and go back for another GOTO main 'check for a new az to make sure there ENDIF 'has not been a wrong reading LOOP 'keep going until with tolerance exit_az: LOW direction 'turn off direction relay RETURN 'move_az move_el: 'move el position GOSUB get_current_el 'read current el position direction = up 'assume default direction IF new_el < current_el THEN 'if current greater than new (too high) then direction = down 'change direction ENDIF delta = ABS(new_el - current_el) 'determine how much position change is required IF delta < el_tolerance THEN RETURN'if change is less than tolerance, do nothing 'and return, tolerance greater for el because 'range of motion is half of az for same range 'of adc values HIGH direction 'turn on appropriate relay DO WHILE delta > el_tolerance GOSUB get_current_el delta = ABS(new_el - current_el) LOOP exit_el: LOW direction 'turn off direction relay RETURN 'move_el get_current_az: 'getting azimuth position data adc_config=adc_config | %1011 'reset config nibble chan = 0 'select az channel (0) GOSUB get_adc_data current_az=adc RETURN 'get_current_az get_current_el: 'getting elevation position data adc_config=adc_config | %1011 chan = 1 'slect el channel (1) GOSUB get_adc_data current_el=adc RETURN 'get_current_el get_adc_data: LOW adc_cs 'slect adc PAUSE 10 SHIFTOUT adc_data, adc_clk, LSBFIRST, [adc_config\4] 'send config nib SHIFTIN adc_data, adc_clk, MSBPOST, [adc\12] 'get 12 data bits HIGH adc_cs 'adc offline RETURN 'get_adc_data END