Programming the 9103 With Python – Part 1: Standard Speed

New sample Python code for the 9103 is now available on RBD’s website. The 9103’s API is easy to program with any language and documented fully, but as always with any device programming, a few examples always help. We chose Python because it’s well supported, easy to understand even if you’re using another language and compatible with a number of popular lab control and analysis environments.

The sample code we provide is open-source and free for you to use and distribute as you see fit.

(If you haven’t taken a look at the 9103 USB auto-ranging picoammeter, everything you need to know can be found here. Measure bi-polar DC current from picoamps to milliamps, with optional built-in bias and 5 kV isolation.)

Programming the 9103 with Python

A Quick Look at the Standard Speed Sampling Code

Python’s pySerial module abstracts the calls to class-compliant USB serial COM port drivers, so setting up communications with the 9103 is a matter of a few simple calls:

    'com' + port_number,

With the addition of a few helper functions for handling ASCII, it’s simple to write functions to send individual commands to the 9103. The following sets the auto-range and filter settings:

def message(message_string):
return bytes('&'+ message_string + '\n','utf-8')

def command_range_auto():
port.write(message('R0')) # put in autorange

def command_default_filter_32():

Similarly, with the addition of a few helper functions, the 9103 samples can be read with a simple loop that reads lines from the port buffer: In this case, we’ve setup the 9103 to read in interval mode, and poll the port for incoming samples, with a simple keyboard interrupt. This code also writes the sample information to a text file.

while True:
parsed = parse_message_for_sample(msg)
if parsed:
samplefile.write( parsed + '\n')

except KeyboardInterrupt:

All of the code is commented and documented in the Python file.

Using Python with LabView and MATLAB

The Python code samples can be helpful to both LabView and MATLAB users.
LabVIEW now supports Python through the Python Node, which features low-latency calls from a LabVIEW Block Diagram using LabVIEW primitives.

The MATLAB Engine API for Python allows you to call MATLAB as a computational engine from Python, and you can call functions and objects in Python from MATLAB.

More to Come…

Next up we’ll be posting some sample code to write and read using the high-speed version of the 9103. Since high-speed data from the 9103 arrives in packets, there are some minor differences in parsing the message samples.

Programming the 9103 Picoammeter

Programming the 9103 Picoammeter

Progamming the 9103 Picoammeter

RBD’s 9103 USB PIcoammeter is packaged with Windows application software for control, current display, data-logging, and graphing. However, it’s often desirable to use the 9103 with other operating systems, integrate it with other hardware or software systems, and/or extend the capabilities of the application software. Fortunately, the 9103 utilizes an ASCII command set that exposes all of its features. Programming the 9103 Picoammeter is straightforward and easy to test.

A complete guide to programming the 9103 picoammeter can be viewed and downloaded  from RBD’s website here. This post will give you an overview of setting up communications with the 9103 and the message structure for controlling the unit and gathering status and data.

Of course, every programming environment is different. As long as you are working with a tool that supports USB communication and text streaming, you can create a custom application for your 9103.

Setting up Communications

If you are using your 9103 with Windows, the installed driver creates a virtual serial COM port. RBD’s Actuel application software uses this port for communicating with the 9103, and any application you use to interface with the 9103 will use this same port for communications.

For other operating systems, you’ll need to download the appropriate driver from the manufacturer of the USB communications components, FTDI. Those drivers can be found here.

If you are interfacing the 9103 with LabView, drivers and scripts can be found on the 9103 downloads page.

Communications Protocol

The communications protocol for the 9103 is typical for many serial devices. Whether you configure the USB port using your operating system or program it within your application, the protocol is as follows:



Bits per Second (Baud Rate)


Data Bits




Stop Bits


Flow Control


Sending and Receiving Commands

Communication with the 9103 is asynchronous. Most commands sent from the computer control device to the Picoammeter will be answered with a response, which may include an error message if there is a problem understanding/executing the command.

All messages are delivered as ASCII text – there is no binary message data. This includes the actual data delivered by the 9103, which is a formatted ASCII value.

Depending on your programming environment and application, you’ll normally be coding (at the least) logic to deliver the messages to the 9103, as well as to monitor the USB port and parse incoming messages.

Message Formats and Sample Messages

All messages are preceded by the “&” character, followed by a single character denoting the command or data type, as well as additional characters representing command parameters or data.

Here are a few examples:

I – From PC, command message to set the data sample interval, parameter is in milliseconds, 0015 to 9999.Example: ‘&I0500‘ sets the sampling interval to 500 milliseconds
F – From PC, controls the filter settings for the sample data. Allowed values are 000, 002, 004, 008, 016, 032, and 064.Example: ‘&F016‘ sets the filter value to 16

Data and status are passed back to the PC from the 9103 using a similar format. For example:

E – From device, sent if there was an error. Includes string description of error.

A full description of the command and data messages, as well as additional information on programming the 9103 Picoammeter are found in the 9103 User Guide.


Using Actuel’s Console Window For Debugging

If you are communicating with the 9103 using Windows, you can view the communications taking place in real-time using the Console window – simply click the Console button on the main window. You can also type commands here and see the results in real-time.