Programming the 9103 With Python – Part 3: High Speed

Print Friendly, PDF & Email

For Part 3 of our series on programming the 9103 with Python, we’ve written an application that controls the 9103 in High-speed mode (which can sample as quickly as 500 samples/second) and parses the high-speed messages so they are output to a text file using the same format as standard speed. (All Python samples for the 9103 can be found here.)

(The High-speed option for the 9103 is available as an option when purchasing. The 9103 is also available with a High-voltage option and 90 V fixed or external bias)

Setup the 9103 for High-Speed Sampling

The 9103 has two different modes of operation – high-speed and standard-speed. These run the serial COM ports at different baud rates, so the port needs to be opened at the appropriate rate (the 9103 recalls the last baud rate used). This application does not detect / switch modes, but in our last post we programmed a utility to do just that – it’s part of the set of python scripts included in the download.

The only difference between the code to open the port in standard speed or high speed is the baud rate (57.6k for standard, 230.4k for high) . All oher parameters are the same.

High vs. Standard Speed Interval Sampling

When interval sampling in Standard-speed mode, only the ‘I’ command is available, which provides one sample per message. High-speed mode adds an additional command – ‘i’ – which passes 10 samples per message, thereby reducing the round-trip overhead per sample. You would typlically only use this command for speeds faster than 40 samples / sec., however if can be used at slower speeds. We run a slower speed in our sample application to make it easier to observe the sample messages in the terminal.

(You would probably not choose to use the ‘i’ command for slower sampling rates, because it can only provide one stability warning and range for every 10 samples

Parsing the High Speed Sample Messages

The format for a High-speed sample includes the range and units, along with 10 samples:

&s=,Range=002nA,+0.0013,+0.0012,+0.0012,+0.0012,+0.0013,+0.0012,+0.0012,+0.0011,+0.0012,+0.0012,nA

For this application, we write to a data-logging file just as we do in the Standard-speed Python application. However, we need to parse the 10 sample data to produce a similar, one-sample-per-line output if we want to be able to use the data interchangeably.

The only difference between the samples is that the High-speed samples are prefaced with a lower-case ‘s’ (which could be easily replaced if necessary):

s=,Range=002nA,+0.0013,nA

.

Here’s the code for parsing the high-speed sample message:

def parse_message_for_high_speed_sample( msg):
if '&s' in msg:
msg = msg.strip('\0')
msg = msg.strip('&')
list = msg.split(',')
i = 0
stability = ''
range = ''
new_msg = ''
units = list[-1] # gets last item
list.pop() # remove last item which is units
for value in list:
if i==0:
stability = value
elif i==1:
range = value
else:
new_msg = new_msg + stability + ',' + range + ',' + value + units + '\n'
i=i+1
return new_msg
else:
return ''

That’s about all that’s necessary to create a compatible message, allowing you to mix High-speed and Standard-speed messaging in a compatible data-logging format

Leave a Reply

Your email address will not be published. Required fields are marked *