macro 'Open Serial Port [O]'; begin RequiresVersion(1.48); OpenSerial('9600 baud,no parity,eight data,one stop'); end; macro 'Put Serial [P]'; begin PutSerial(GetString('Enter a string:')); end; macro 'Serial Output Test [T]'; var i:integer; begin SetCursor('Watch'); for i:=1 to 10 do PutSerial('The is line ',i:3,chr(13),chr(10)); end; end; macro 'Get Serial and Echo [G]'; var i:integer; ch:string; {actually one char} begin ShowMessage('Press mouse button to abort.'); SetCursor('Watch'); repeat until GetSerial=''; {Flush input buffer} repeat ch:=GetSerial; {returns null string if input buffer empty} if ch<>'' then ShowMessage('char="',ch,'" (',ord(ch):1,')'); PutSerial(ch); if ch=chr(13) then PutSerial(chr(10)); {if return send line feed} until button; end; macro 'Display Serial InputÉ [D]'; {Displays serial input in a window.} var x,y,width,height,count,line:integer; ch:string; {actually one char} BaudRate:string; begin RequiresVersion(1.48); repeat BaudRate:=Getstring('Baud Rate(1200, 2400, 9600 or 19200)','9600'); until (BaudRate='1200') or (BaudRate='2400') or(BaudRate='9600') or (BaudRate='19200'); OpenSerial(BaudRate); width:=500; height:=500; SetNewSize(width,height); SetForeground(255); SetBackground(0); MakeNewWindow('Serial Input'); SetCursor('Watch'); SetFont('Monaco'); SetText('With background; Left Justified'); SetFontSize(9); MoveTo(8,8); count:=0; line:=0; ShowMessage('Press mouse button to abort'); repeat ch:=GetSerial; if ch<>'' then begin count:=count+1; if (ord(ch)=13) or (count=80) then begin {13=Carriage Return} writeln(ch); count:=0 line:=line+1; if line=54 then begin Clear; moveto(8,8); line:=0; end; end else write(ch); end; until button; end; macro 'Capture Serial Input [C]'; { Captures serial input and saves the characters a pixels in an image. The default image size of 200x200 allows up to 40,000 characters to be captured. The text can be exported(use 'Raw Data"), but you will need to change the file type to 'TEXT' to open it with a text editor. } var x,y,width,height,cc,tc:integer; ch:string; {actually one char} begin RequiresVersion(1.48); OpenSerial('9600'); width:=200; height:=200; SetNewSize(width,height); MakeNewWindow('Serial Input'); SetPalette('Spectrum') SetForeground(ord(' ')); Fill; SetCursor('Watch'); cc:=0; tc:=0; ShowMessage('Use command-period to abort'); for y:=0 to height-1 do begin for x:=0 to width-1 do begin repeat tc:=tc+1; ch:=GetSerial until ch<>''; PutPixel(x,y,ord(ch)); cc:=cc+1; end; ShowMessage(tc:6,' ',cc:6); end; end; procedure GetResponse; {Gets responses to commands sent to the Newport 2-axis controller} var ch:string; TimeOutTicks:integer; TimeOUt:boolean; begin response:=''; TimeOutTicks:=TickCount+60; {1 sec.} repeat ch:=GetSerial; if ord(ch)>=32 {ignore control characters} then response:=concat(response,ch); timeout:=TickCount>TimeOutTicks; until (ch=return) or TimeOut; if TimeOut then response:=concat(response,'[1 second time out]'); end; macro 'Test Newport Motion ControllerÉ[N]'; { Simple macro to test the Newport PMC200-P programmable 2-axis motion controller. Before starting, connect the PMC200-P to the Mac's modem port. This can be done using a modem cable and a 9-pin to 25-pin adapter consisting of a female 25-pin connector wired back-to-back with a female 9-pin connector acording to the table below. 9-pin 25-pin 2 <------> 3 (receive data) 3 <------> 2 (transmit data) 5 <------> 7 (signal ground) Note: RS-232 INPUT ECHO MODE must be disabled. The phone number for Newport is 714-253-1665. } var cmd,response,linefeed,return:string; begin RequiresVersion(1.48); linefeed:=chr(10); return:=chr(13); OpenSerial('9600 baud,no parity,eight data,one stop'); repeat cmd:=GetString('Enter PMC200-P Command:','*IDN?'); repeat until GetSerial=''; {flush input buffer} PutSerial(cmd,return,linefeed); GetResponse; PutMessage(response) until button; end;