Lakeshore Learning Materials 622 User Manual

Page 47

Advertising
background image

Lake Shore Model 620/622/623/647 Magnet Power Supply User’s Manual

Remote Operation

4-9

4.2.4

Notes On Using The Serial Interface

• To chain commands together, insert a semi-colon (;) between them. Multiple queries cannot be chained.

• Queries use the same syntax as the associated setting command followed by a question mark (?). They

usually return the same information that is sent.

• Add a query to the end of a command string if the controller must return information. For example, RMP

0;RMP? commands the MPS to pause the ramp then return the ramp status to confirm the change.

• The MPS returns nothing queries without a “?" and ignores misspelled commands and queries.

• The term "free field" indicates a floating decimal point that can be placed at any appropriate place in the

string of digits.

• Leading zeros and zeros following a decimal point are unneeded in a command string, but they are sent in

response to a query. A leading “+” is not required, but a leading “

is required.

[term] indicates where the user places terminating characters or where they appear on a returning character

string from the MPS.

Table 4-3. Sample BASIC Serial Interface Program

'

SEREXAM.BAS

EXAMPLE PROGRAM FOR SERIAL INTERFACE

'

This program works with QuickBasic 4.0/4.5 or Qbasic on an IBM PC or compatible

'

with a serial interface. It uses the COM1 communication port at 9600 BAUD. Enter

'

an instrument command or query at the prompt. The command transmits to the

'

instrument which displays any query response. Type "EXIT" to exit the program.

'

NOTE: The INPUT instruction in this example accepts no commas as part of an input

'

string. If a comma appears in an instrument command, replace it with a space.

'

CLS

'Clear screen

PRINT " SERIAL COMMUNICATION PROGRAM"
PRINT
TIMEOUT = 2000

'Read timeout (may need more)

BAUD$ = "9600"

TERM$ = CHR$(13) + CHR$(10)

'Terminators are <CR><LF>

OPEN "COM1:" + BAUD$ + ",N,8,1,RS" FOR RANDOM AS #1 LEN = 256

LOOP1: INPUT "ENTER COMMAND (or EXIT):"; CMD$

'Get command from keyboard

CMD$ = UCASE$(CMD$)

'Change input to upper case

IF CMD$ = "EXIT" THEN CLOSE #1: END

'Get out on Exit

CMD$ = CMD$ + TERM$
PRINT #1, CMD$;

'Send command to instrument

IF INSTR(CMD$, "?") <> 0 THEN

'Test for query

RS$ = ""

'If query, read response

N = 0

'Clr return string and count

WHILE (N < TIMEOUT) AND (INSTR(RS$, TERM$) = 0) 'Wait for response

IN$ = INPUT$(LOC(1), #1)

'Get one character at a time

IF IN$ = "" THEN N = N + 1 ELSE N = 0 'Add 1 to timeout if no chr
RS$ = RS$ + IN$

'Add next chr to string

WEND

'Get chrs until terminators

IF RS$ <> "" THEN

'See if return string is empty

RS$ = MID$(RS$, 1, (INSTR(RS$, TERM$) - 1)) 'Strip off terminators
PRINT "RESPONSE:"; RS$

'Print response to query

ELSE

PRINT "NO RESPONSE"

'No response to query

END IF

END IF

'Get next command

GOTO LOOP1

Advertising
This manual is related to the following products:

623, 620