Stepping and Scanning 9-17
A loop program can be written to extract the data as follows:
' This is for Channel 2 Data’
Let NumRdgsPerStep = 4 ; 1 Ch2 and 3 Ch1 readings stored in the buffer
/ 2400 current level.
Let CalcRdgs = 6 ; Total number of positive or negative current
levels out of the 2400.
Let k = 1
For j =1 to CalcRdgs
CH2 Rdg#( j ) = Buffer Rdg#( k )- Buffer Rdg#( k + NumRdgsPerStep )
CH2 Rdg#( j ) = CH2 Rdg#( k ) / 2
k = k + ( NumRdgsPerStep * 2 )
Next j
' This for For Channel 1 Data’
Let NumRdgsPerStep = 4
Let CalcRdgs = 6
Let k = 1
For j = 1 to CalcRdgs
Let CH1 Rdg#_pos = 0
Let CH1 Rdg#_neg = 0
For m =1 to NumRdgsPerStep - 1
CH1 Rdg#_pos = CH1 Rdg#_pos + Buffer Rdg#( k +m )
CH1 Rdg#_neg = CH1 Rdg#_neg + Buffer Rdg#( k +m + NumRdgsPerStep )
Next m
CH1 Rdg#( j ) = ( CH1 Rdg#_pos - CH1 Rdg#_neg ) /
( (NumRdgsPerStep - 1) * 2)
Next j
An example program using “QBASIC ” was written that sets up an Array for all the data out
of the 2182 buffer, parses the comma separated data into the array, and calculates the DC current
reversal data for both Channel 1 and Channel 2.
CONST Addr = 7 'Represents the address of the 2182
CONST NumRdgsPerStep = 4 'Represents the total number of CH1 & CH2
'readings at each positive or negative current
'step
CONST CalcReadings = 6 'Represents number of paired positive & negative
'steps in 2400
CONST NumRdgs = (NumRdgsPerStep * 2 * CalcReadings)
'NumRdgs represents the number of readings to
'store in 2182's buffer
'The 2 accounts for positive and negative steps
DIM DataCH2$(CalcReadings) 'array represents total number of channel 2
'readings
DIM DataCH1$(CalcReadings) 'array represents total number of channel 1
'readings
FOR i = 1 TO (CalcReadings) 'allocates space for each channel reading
'DataCH2$(i) = SPACE$(18)
'DataCH1$(i) = SPACE$(18)
NEXT i
'CODE for Parsing single string of buffer response into 48 individual
readings
OneReading$ = SPACE$(20) 'represents 1 reading from buffer string
'response
OneCharacter$ = SPACE$(2) 'represents 1 character from buffer string
'response