Voltage and Current Programming With Variables

You can use variables in a program to represent data values in the device commands. This is useful in applications that require changing the voltage and current values to different predetermined settings. The following program uses a variable in a FOR NEXT loop to ramp up output voltage in 0.1 volt steps from 0 to 5 volts.

10 ASSIGN @Ps TO 705

20 OUTPUT @Ps;"CLR;ISET1,1"

30 FOR Voltage=0 TO 5 STEP 0.1

40 OUTPUT @Ps;"VSET1,'';Voltage

50 WAIT 0.2

60 NEXT Voltage

70 END

Line 10: Assigns the I/O pathname to the power supply.

Line 20: Initializes the power supply to its power on state and sets the current limit.

Line 30,60: Increments the voltage in 0.1 V steps to 5 volts.

Line 40: Sets the voltage of output 1 to the value of the variable "Voltage''. The comma inside the quotes is required because it separates numbers in the device command (the output channel number from the voltage value in this case). A space < SP > may also be used instead of the comma. The semicolon outside the quotes is used because it suppresses the <CR > <LF> that the computer would normally send to the power supply if a comma were used as a separator after a string item. Using a comma in this case would produce a syntax error in the power supply.

Line 50: Waits 0.2 seconds between steps.

Another way to use variables to represent data values in device commands is when using input statements to program the power supply. The following program uses input statements to program the voltage and current settings of output 1 and output 2.

10 ASSIGN @Ps TO 705

20 INPUT "ENTER A VOLTAGE FOR OUTPUT #1",V1

30 INPUT "ENTER A CURRENT LIMIT FOR OUTPUT #1",I1

40 INPUT ''ENTER A VOLTAGE FOR OUTPUT #2",V2

50 INPUT "ENTER A CURRENT LIMIT FOR OUTPUT #2",I2

60 OUTPUT @Ps;''VSET1,";V1;";ISET1,'';I1;'';VSET2,";V2;";ISET2,";I2

70 END

Line 10: Assigns the I/O pathname to the power supply.

Line 20,30: Enter voltage and current values for output 1.

Line 40,50: Enter voltage and current values for output 2.

Line 60: Sets the voltage and current of outputs 1 and 2 to the values entered into the variables. The previous example explained the use of the comma inside the quotes and the semicolon that precedes the variable. The semicolon that follows the variable suppresses the comma that the computer would normally send to the power supply if a comma were used as a separator after a numeric item. The leading semicolons inside the quotes separate multiple device commands (the VSET commands from the ISET commands in this case).

Voltage and Current Readback

Reading back data from the power supply requires two statements. First, an output statement is used to query the power supply. A list of queries appears in Table 5-2. The power supply responds to the query by entering the requested data into a buffer. Next, an enter statement is used to read the data from the buffer on the power supply into a variable in the computer. The following program queries the power supply for the voltage and current settings of output 1 and prints the results on the screen.

98 Programming with a Series 200/300 Computer