' This is a test program for the AlfaSpid RAK 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 RAK Rotator and Controller in accordance ' with the Alfaspid RAK Manual and ensure that it is wirking 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.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:1200,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 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" LOCATE 4, 24 ' Clear azimuth entry area PRINT #2, " "; LOCATE 4, 1 INPUT ; "Enter desired azimuth ", azim ' Clear invalid entry warning area LOCATE 5, 1 PRINT #2, " " SELECT CASE azim CASE 888 ' Send the stop command to the rotator 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 5 characters are received from the controller read2: IF LOC(1) = 5 THEN GOTO read1 ELSE GOTO read2 END IF 'Read the 5 characters from the receive buff read1: rotstat$ = INPUT$(LOC(1), #1) 'Separate the hundreds, tens and ones numbers 'The first character "W" and the last character"Space" 'are ignored stat100$ = MID$(rotstat$, 2, 1) stat10$ = MID$(rotstat$, 3, 1) stat1$ = MID$(rotstat$, 4, 1) 'convert the three ascii status characters to numbers 'and then assemble into a single intiger stat = (ASC(stat100$) * 100) + (ASC(stat10$) * 10) + ASC(stat1$) ' since the controller sends the status based on 0 Degrees = 360 ' Remove the 360 here stat = stat - 360 'Display the results on the screen LOCATE 10, 20 PRINT #2, "Current Location "; PRINT #2, stat 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 5, 1 PRINT #2, "Invalid Azimuth, Re-enter." GOTO start ELSEIF azim > 360 THEN LOCATE 5, 1 PRINT #2, "Invalid Azimuth, Re-enter." GOTO start ELSE ' Add 360 degrees to the inputted value of the azimuth azim = azim + 360 ' Convert the integer azim to a string and remove the leading space azim$ = LTRIM$(STR$(azim)) ' format the Set command and Send it to the rotator controller PRINT #1, "W" + azim$ + h$ + V$ + CHR$(47) + CHR$(32) END IF END SELECT GOTO start ' go for the next command done: ' exit program CLOSE #1 CLOSE #2