' This is a test program for the AlfaSpid RAS controller and ' is written in Microsoft QuickBasic version 4.5. ' The program was written for demonstartion purposes only and as ' a template for users to fashion any custom software project ' they may be attempting. ' Before using this program, the user must: ' 1. Install and setup the RAS Rotator and Controller in accordance ' with the Alfaspid RAS Manual and ensure that it is working with the ' manual controls on the controller. ' 2. Obtain a controller program such as Ham Radio Delux or N1MM to ' confirm that the RS232 connection between Computer and controller ' are fully functional ' A copy of file "Program format-Komunicacji-2005-08-10-p2.pdf" must be ' obtained from the AlfaRadio website to fully understand this program. ' This program was tested on a Toshiba 1200 laptop running MSDOS and ' a Dell Latitude D610 running Microsoft XP. ' No warrenty is stated nor implied by Alfaradio for this program's use. ' Open the ports needed OPEN "com1:600,N,8,1,cd0,cs0,ds0,op0,rs,rb2048" FOR RANDOM AS #1 ' Since the controller only has the RXD, TXD and GND leads, set Com Port to ' ignore all other RS232 control leads. ' cd0 = Turns off time-out for Data Carrier Detect (DCD) line. ' cs0 = Turns off time-out for Clear To Send (CTS) line ' ds0 = Turns off time-out for Data Set Ready (DSR) line ' op0 = Turns off time-out for a successful OPEN ' rs = Suppresses detection of Request To Send (RTS) ' rb2048 = Increases the receive buffer to 2048 bytes OPEN "SCRN:" FOR OUTPUT AS #2 ' Format words to make up the three different ratator commands ' Stop stop the rotator in mid spin ' Status ask the rotator where it is h$ = CHR$(48) + CHR$(1) V$ = CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) stop$ = "W" + V$ + V$ + CHR$(15) + CHR$(32) status$ = "W" + V$ + V$ + CHR$(31) + CHR$(32) CLS INPUT ; "Enter Rotator Divider (1 for 1 pulse/degree 2 for 1 pulse/0.5 degree) ", multin CLS start: LOCATE 1, 1 PRINT #2, "Enter 888 to stop rotation" PRINT #2, "Enter 999 to update rotator status" PRINT #2, "Enter 987 to quit program" ' Clear Elevation entry area LOCATE 5, 1 PRINT #2, " " ' Clear azimuth entry area LOCATE 4, 24 PRINT #2, " "; LOCATE 4, 1 INPUT ; "Enter desired azimuth ", azim ' Clear invalid entry warning area LOCATE 6, 1 PRINT #2, " " SELECT CASE azim CASE 888 ' Send the stop command to the rotator controller and ' read the current location from the controller PRINT #1, stop$ GOTO read2 CASE 999 ' ask rotator controller for current location ' send Status request to the rotator controller PRINT #1, status$ ' wait until all 12 characters are received from the controller read2: IF LOC(1) = 12 THEN GOTO read1 ELSE GOTO read2 END IF 'Read the 12 characters from the receive buffer read1: rotstat$ = INPUT$(LOC(1), #1) 'Separate the hundreds, tens, ones and decimal numbers for 'azimuth and elevation 'The first character "W" and the last character"Space" 'are ignored stata100$ = MID$(rotstat$, 2, 1) stata10$ = MID$(rotstat$, 3, 1) stata1$ = MID$(rotstat$, 4, 1) stata0$ = MID$(rotstat$, 5, 1) multa$ = MID$(rotstat$, 6, 1) state100$ = MID$(rotstat$, 7, 1) state10$ = MID$(rotstat$, 8, 1) state1$ = MID$(rotstat$, 9, 1) state0$ = MID$(rotstat$, 10, 1) multe$ = MID$(rotstat$, 11, 1) 'convert the four azimuth ascii status characters to numbers 'and then assemble into a single intiger stata = (ASC(stata100$) * 100) + (ASC(stata10$) * 10) + ASC(stata1$) + (ASC(stata0$) / 10) ' now do the same for Elevation state = (ASC(state100$) * 100) + (ASC(state10$) * 10) + ASC(state1$) + (ASC(state0$) / 10) ' since the controller sends the status based on 0 Degrees = 360 ' Remove the 360 here stata = stata - 360 state = state - 360 'Display the results on the screen LOCATE 10, 20 PRINT #2, "Current Aximuth "; PRINT #2, stata, " " LOCATE 11, 20 PRINT #2, "Azimuth Multiplier "; PRINT #2, ASC(multa$), " " LOCATE 13, 20 PRINT #2, "Current Elevation "; PRINT #2, state, " " LOCATE 14, 20 PRINT #2, "Elevation Multiplier "; PRINT #2, ASC(multe$), " " CASE 987 ' Quit program GOTO done CASE ELSE ' send command to rotator controller to move rotator ' to azmuth desired location ' test to see if azimuth is in the range of 0 to 360 degrees IF azim < 0 THEN LOCATE 6, 1 PRINT #2, "Invalid Azimuth, Re-enter." GOTO start ELSEIF azim > 360 THEN LOCATE 6, 1 PRINT #2, "Invalid Azimuth, Re-enter." GOTO start 'ELSE END IF ' input the elevation elevin: LOCATE 5, 26 PRINT #2, " "; LOCATE 5, 1 INPUT ; "Enter desired elevation ", elev ' Clear invalid entry warning area LOCATE 6, 1 PRINT #2, " " ' test to see if elevation is in the range of 0 to 180 degrees IF elev < 0 THEN LOCATE 6, 1 PRINT #2, "Invalid Elevation, Re-enter." GOTO elevin ELSEIF elev > 180 THEN LOCATE 6, 1 PRINT #2, "Invalid Elevation, Re-enter." GOTO elevin ELSE ' Add 360 degrees to the inputted value of the azimuth and elevation azim = azim + 360 elev = elev + 360 ' If the rotator dividor is 1 pules /0.5 degree then multiply ' azim and elev by 2 IF multin = 2 THEN azim = azim * 2 elev = elev * 2 END IF ' Convert the integers azim and elev to a string and remove the leading space azim$ = LTRIM$(STR$(azim)) elev$ = LTRIM$(STR$(elev)) ' convert string to four digits IF LEN(azim$) = 3 THEN azim$ = "0" + azim$ END IF IF LEN(elev$) = 3 THEN elev$ = "0" + elev$ END IF ' format the Set command and Send it to the rotator controller PRINT #1, "W" + azim$ + CHR$(multin) + elev$ + CHR$(multin) + CHR$(47) + CHR$(32) END IF END SELECT GOTO start ' go for the next command done: ' exit program CLOSE #1 CLOSE #2