Sciencemadness Discussion Board
Not logged in [Login ]
Go To Bottom

Printable Version  
Author: Subject: Controlling Denver Instrument APX-323 balance with Python
kavu
Hazard to Others
***




Posts: 207
Registered: 11-9-2011
Location: Scandinavia
Member Is Offline

Mood: To understand is to synthesize

[*] posted on 26-7-2012 at 11:28
Controlling Denver Instrument APX-323 balance with Python


More expensive lab balances have a serial port connection designed to connect them with printers, computers and so forth. It's really rather simple to write a program to communicate through this port as only basic serial functions are needed. Herein is described a command line python software to do this task with Denver Instrument APX-323 balance. It runs under linux and should work with minor adjustments on other operating systems as well.

Serial ports are nowadays rare, so USB to serial converter is needed. They are rather cheap and work well with this kind of use. I used a cheap Chinese one which I happened to have lying around.

Commands used for serial communication can be found from the manual of the balance. In this case communication is done in 7S1 mode, which corresponds to 8N1 for most ASCII characters (the 8th bit is 0 in all the bytes send/recieved). This is lucky as POSIX version of pyserial library does not support space-parity bits. If this is desired then a simple not-and manipulation mask is needed.

First a escape-character (ASCII 27) is sent and after this the desired command character. When reading data from the balance a buffer flush is needed to keep things up to date.

Such system is quite useful when using computerized lab notebooks and collecting data from sets of measurements. A handy trick is to pipe output of the software to clipboard:

Code:
python readout.py -p | xclip


Full source and pictures of the project can be found at http://koti.kapsi.fi/~kaviaari/apx323/. Feel free to use the software to meet your needs.

Screenshot of the program:


[Edited on 26-7-2012 by kavu]
View user's profile View All Posts By User
Texium
Administrator
Thread Moved
20-11-2023 at 12:22

  Go To Top