Instruction manual
Set output voltage
Set output current
Input values:
Current output current: 0.0 A
Current output voltage: 0.02 V
Power supply state:
Operation Mode: Remote Control
Fan Speed: 1
Output Mode: Off
Over heat protection: Normal
Output State: OFF
Output current set to: 5.0
Maximum output voltage: 5.0
Output voltage set to: 2.5
Product info:
Model 6821
Serial no. 6369001100
Firmware version 1.58
Set to local control
Use Visual Basic to access the COM server
If you have Microsoft Office installed on your computer, you can use the Visual Basic programming
environment for the following example. This works with Word, Excel, PowerPoint, etc. If you have
Visual Basic 6, the same code should run identically.
Open Word, then press Alt-F11 to get into the Visual Basic editor. Enter the following function:
Sub ps178x()
' Use power supply's python COM server from Visual Basic
Set server = CreateObject("BKServers.ps178x")
port = 3 'COM3
baudrate = 38400 '38400bps
response = server.Initialize(port, baudrate)
' Get the time and display it in a message box
response = server.TimeNow()
msg = "Time from power supply COM server = " + response
MsgBox msg
' Get the power supply's front panel display
response = server.GetInputValues()
MsgBox "Front panel: " + response
End Sub
Note you may need to change the port and baudrate variables. Put the editor's cursor in the
ps178x() function, then press the F5 button to run the function. You'll see two message boxes .
The first message box demonstrates that the Visual Basic code is talking to the python COM server
and the second message box demonstrates that the Visual Basic code talked to the power supply
using the COM server.
*Note: If you only see the first message box and Word freezes, it is most likely because the power
supply is not set on “Remote” operation. Be sure to turn on “Remote” operation by sending the
remote command “0x20” and “0x01” for bytes 3 and 4. You can quickly do this by calling the
SetRemoteControl() method from the ps178x.py library (i.e. response =
server.SetRemoteControl() ). For more references on command codes, see pages 54-74 in the user
manual. Once set, restart Word and run script again.
Similar code should work from any Windows programming language that supports COM servers.
B&K 1785, 1786B, 1787B, 1788 Python Library 15 January 2009 Page 10 of 14