B&K user manual BK Precision 4071 User Manual Rev.2.2

Models: 4071

1 88
Download 88 pages 40.73 Kb
Page 72
Image 72

IF PointVal < 0 THEN PointVal = PointVal + 2: j = 32768!

a = INT(PointVal * j)

' Get a number 0 to 65535

a = INT(a / 16) ' Mask off lower 4 bits ($FFF0) a = a * 16

IF

PointNumber = 2 THEN a = a OR &H8

'

Set SYNC Out bit for second point

a$

= HEX$(a)

'

Convert the integer to hexadecimal

'For negative values, the HEX$ fctn will return a 32 bit value, ie $FFFF FFD8,

'so chop off all but the last 4 chars

IF a < 0 THEN a$ = RIGHT$(a$, 4)

PRINT #1, a$' Send hex point to 4071

RETURN

'-------------------------

Send Binary data to 4071 ------------------------

'This is the fastest way to send points to the 4071 since it transfers

'the data point with only 2 characters. It is also the least forgiving

'as far as getting the data sent correctly.

'

'Each data point is a 16 bit word which is sent to the 4071 in two bytes.

'The high byte is sent first, followed by the low byte.

'The 16 bit value is in "two's complement" format, which represents a number

'from -1.0 to +1.0 as follows:

'

 

 

 

 

 

'

8000

---- E000 ---- FFFF,0 ---- 4000

---- 7FFF

'

-1.0

-.5

0.0

+.5

+1.0

'

 

 

 

 

 

'Although a 16 bit value is sent to the 4071, the Arbitrary Waveform system

'uses a 12 bit D/A converter, so not all 16 bits are used. Only the uppermost

'12 bits are used to form the arbitrary waveform point.

'

'

'Rules for Binary format:

'1. IMMEDIATELY after the "B" character in the header the 4071 expects the

'first high byte of data point 1. No whitespace is allowed after the "B"

'in Binary mode.

'

'2. The high byte of each data point is sent first, followed by the low byte.

'3. The SYNC Out output is controlled by bit #3 in the low byte. If this bit

'is set to 1, SYNC Out is set high. If this bit is set to 0, SYNC Out

'is set low.

'------------------------------------------------------------------------------

SendBinary:

IF PointNumber = 1 THEN PRINT #1, "WB"; ' Put header info before 1st data

' point. Must not have CR or LF after

'Convert the value in PointVal to a two's complement hex number j = 32767

IF PointVal < 0 THEN PointVal = PointVal + 2: j = 32768!

a

= INT(PointVal * j)

'

Convert -1.0,+1.0 to

0,65535

a

= INT(a / 16)

'

Only the uppermost

12 bits are used, so

a

= a * 16

'

Mask off the lower

4

bits (AND fff0)

IF

PointNumber = 2 THEN a = a OR &H8

' Set SYNC Out bit for second point

' If you let Basic send a 16 bit variable to a port, it will send the low byte

67

BK Precision 4071 User Manual Rev.2.2

Page 72
Image 72
B&K user manual BK Precision 4071 User Manual Rev.2.2