Specifications
1
6.4 Example program
Below is a code sample created with Visual Basic 6.0. The complete Visual Basic project, including the
executable, can be downloaded from the B+K Precision website at www.bkprecision.com
.
Dim CrLf As String
CrLf = Chr$(&HD) + Chr$(&HA)
Dim Buffer(1) As Byte
******* transmit DL8 command to prepare for transmission of 8 word data block ****
*******Function Call WaitRes() receives 3 bytes, in this case ‘Y’+ CRLF **********
MSComm1.Output = "C"
Call WaitRes(3)
MSComm1.Output = "DL8;"
Call WaitRes(3)
**** transmit 8 attenuation values of type word **********
**** set the Sync pulse, move high byte to low byte and low byte to high byte position *****
For i = 1 To 8
If Check1(i) = 1 Then sync = "8" Else sync = "F"
s = sync + Right$("000" + Hex$(TextATT(i) / 0.05), 3)
Buffer(0) = Val("&h" + Left(s, 2))
Buffer(1) = Val("&h" + Right(s, 2))
For j = 1 To Word(i)
MSComm1.Output = Buffer
Next
Next
MSComm1.Output = CrLf
******set the program length to 8 *************
**Function Call WaitRes() receives 3 and 4 bytes respectively, in this case ‘Y’+ CRLF and OK’+ CRLF*
Call WaitRes(4)
MSComm1.Output = "C"
Call WaitRes(3)
MSComm1.Output = "LEN" + CStr(dl) + CrLf
Call WaitRes(4)
31










