Logo Banner

ELECTRONICS - [BK1786B software]- [BKcomm class]

BKcomm class

Introduction to the BKcomm class

Communicating with the BK1786B instrument is relatively easy. Each command is executed by sending a data frame to the instrument: this is a packet with 26 bytes of data. Each frame contains a command (the command we want to execute on the BK device) and some additional data (one or more bytes).

I now created a software class for Visual Basic. This class contains all functions that are required to communicate with the BK device. Thanks to this class it is no longer required to work with bits and bytes. The class provides you with functions to set/read the values on the BK device.

You only need to add the class to your own Visual Basic project to get started.

Using the BKcomm class

Using the BKcomm class is very easy. You only need to create an object that is an instance of this class. Then you can communicate with your BK Device through this object. The example below shows the code required to activate the output and set a voltage of 2000 mV (2 Volt) and a maximal output current of 150 mA.

    Dim bkDevice As New BKcomm()
    bkDevice.allowSleepFunction = True
    If bkDevice.connect(8, 9600, 0) Then
    End If		

This is what happens:

  1. First a variable bkDevice is declared. It is an object of the BKcomm class.
  2. Then the allowSleepFunction property is set to true. This means the class will wait 100 milliseconds between the execution of each command.
  3. The connect() method is called to create a connection with the BK. The three parameters are: COM8, BAUD 9600, ADDRESS 0). The function returns true if the connection succeeded.
  4. The setRemoteControlMode is called to set the BK unit to REMOTE_OPERATION. (this is necessary to be able to send any commands).
  5. The SetOutputVoltage() method is called to set the output voltage to 2000 mV (2 V).
  6. The setOutputCurrent() method is called to set the output current to 150 mA (0.15 A).
  7. The enableOutput() method is called to activate the output of the BK.

Downloading the class

Here you can download a a preliminary version of my bkComm class. The class still needs some tuning, but it is fully operational.

Copyright ©1998-2022 Vanderhaegen Bart - last modified: August 24, 2013