; This program measures the current-voltage characteristics of a probe.
	; Two multimeters (DMM #1 + DMM #2) are used, one for the current and 
	; one for the voltage. The current source is controlled by a voltage
	; from a digital-to-analog (DA) converter. The measured values are 
	; plotted to the screen and written into a text-file.
	;------------------------------------------------------------------------
	
	; define variables
	
	Real i_in, i_out, u_out, i_range
	Real Umin, Umax, Imin, Imax
	
	; initialize the IEEE-devices. The strings are device specific.
	
	Send( "SR530",  "X6,0")                                       ; initialize DA-converter
	Send( "DMM199", "F0R0G1A1X" )                                 ; setup for DMM #1 : DC V, Autoscale, no Prefix
	Send( "DMM199A","F0R0G1A1X" )                                 ; setup for DMM #2 : DC V, Autoscale, no Prefix
	
	; some constants
	
	i_range := 3.0                                                ; measured current range
	
	Umin := -10.0                                                 ; boundary values for the screen graphics
	Umax :=  10.0
	Imin := -i_range
	Imax :=  i_range
	
	; the main part
	
	Openfile( "Filename")                                         ; open file to save the data
	GrafRange( Umin, Umax, Imin, Imax)                            ; initialize the graphic output
	
	LOOP( i_in, ( -i_range, i_range, 1000) )                      ; measure 1000 points between -i_range and i_range 
	  BEGIN
	          Send( "SR530", "X6," + i_in )                       ; send current to DA-converter
	          i_out := Read( "DMM199"  )                          ; measure actual probe current with DMM #1
	          u_out := Read( "DMM199A" )                          ; measure actual probe voltage with DMM #2
	          Put( i_out, u_out )                                 ; write measured values to file
	          Plot( i_out, u_out )                                ; plot the data on the screen
	          Write( "Resistance = " + (u_out/i_out) + " ohms" )  ; calculate the resistance and write it to the screen
	  END; of loop
	
	
	Closefile; close the file
	Beep( 9 ); beep #9
	
	;---------------------------------------------------------------------------
	
	ExitBlock ; this block is executed at the end of the program or after a user break via "command-dot".
	    Send( "SR530", "X6, 0" ) ; set the DA-converter to 0.0 V output
	    Local( "SR530"   )       ; switch the devices to LOCAL-mode
	    Local( "DMM199A" )
	    Local( "DMM199"  )
	End
	
	;---------------------------------------------------------------------------