Skip to main content

tools for communicating with Bronkhorst MFCs with the API for BM31

Project description

Repository for a client/server program for communicating with Bronkhorst MFCs remotely. Intended to be used with Pylatus or similar scripting environment. To install, clone the repository, then run 'pip install -e .' inside. This will create the bronkhorstServer program. Can also get from PyPi, 'pip install bronkhorstControlbm31'. Uses the Bronkhorst propar library. Also requires pandas, matplotlib and PyQt6.

Usage: On the PC connected to the MFCs run bronkhorstServer in a terminal. Options are -c/--com input the com number as an integer (default 1, but check com ports in Device Manager), this will save next time you run so you shouldn't need to input it again. -p/--port port number, (default is value in the script, probably unnecessary to change). A positional argument which can be 'local' ('localhost'), 'remote' (hostname), or remoteip (ip address) (default local). If remote the hostname will be displayed to connect from another computer, otherwise it will be 'localhost'. The port number will also be displayed.

The best way to run is to use the multi client server e.g.

bronkhorstServer remote -c 7

remoteip, the hostname/ hostname.domain (e.g. format: pcname.company.countrycode) or the IP address itself can be used instead of remote to help specify the hostname, sometimes it works better in cases where the PC has multiple connections.

Use ctrl+c to close the server. May take 5 s to take effect.

To send commands import the MFCclient class and connect function, then run it's methods. Initial arguments are MFC address (will be an integer), the IP address (default localhost) and the port (default is that in the script).

E.g.

from bronkhorstControlbm31 import MFCclient

MFCclient(3,'<hostname or ip address>').pollAll() 

(this gives information about all MFCs that are connected in a dataframe, the MFC address isn't used and can be anything in this case).

Some useful snippets:

Ar = MFCclient(3,'myPC') #make MFC object
Ar = MFCclient(3,'myPC', m = 1.2, c = 0.1) #make object with linear calibration values m and c
Ar.writeSetpoint(5) #set MFC flow setpoint to 5 ml/min (or bar for BRR)
Ar.readFlow() #get the current measured flow value from the MFC
Ar.writeSlope(2000) #set the slope of the MFC (in ms/(ml/min)) - 
                    #e.g. setting to 2000 means it takes 2 s to increase flow by 1 ml/min
Ar.writeSetpoint2(10,calculate = True) #write setpoint and adjust the flow value so it fits the set linear 
                                       #calibration (y = m*x + c) - i.e. would set to 12.1 with m=1.2 and c=0.1
                                       # y - MFC measured flow, x - calibrated flow
Ar.writeSP_slope(10,1000) #set the setpoint and slope at the same time - sp to 10 ml/min and slope to 1000 ms(ml/min)
df = Ar.pollAll() #get information on all connected MFCs as pandas DataFrame
Ar.wait() #block script until measured MFC flow/BPR pressure is within 0.1 of the setpoint
Ar.wink() #make the LEDs on the MFC wink for 9 s

There is a gui called mfcgui (still must be used in conjuction with bronkhorstServer). Run in the terminal. There is one option: -m/--maxMFCs - the maximum number of MFCs that may be needed (sets the number of columns of widgets, doesn't matter if it's more than you have), by default this is 10, if you have more, or want to reduce it to make it cleaner, run with the specific number you want. e.g. for 15 MFCs:

mfcgui -m 15
mfcgui_202511

When plot data is checked, the following data will be plotted:

mfc_plot

There is a 'reset axes' box on the plotter. If this is checked, the axes for the time plotters will always reset to show all the data. If unchecked, it allows you to zoom into a region, and it will stay there until the box is checked again. If the graph is not zoomed in, the axes will reset as more data comes in.

The GUI also logs the measure values and setpoints every 5 seconds. This is saved in the <home>/bronkhorstClientLog/ folder.

There are also 3 plotting programs which can be run independently of the GUI, called barPlot, timePlot, and mfcPlotAll which can be run in conjunction with the bronkhorstServer. Takes host as a positional argument (default 'localhost'). Run e.g. 'timePlot <hostname>'. Use --help to display options. mfcPlotAll plots the same data as the GUI. timePlot and mfcPlotAll also log the data.

Can also be controlled more directly, without the server, using the MFC class in the bronkhorst.py module, but the GUI and plotting programs won't work in that case, and it must be on the same PC as the MFCs. e.g.

from bronkhorstControlbm31 import MFC, startMfc

mfcmain = startMfc('COM3')
mfc1 = MFC(1,mfcmain)
mfc1.readName()

I should mention this article https://realpython.com/python-sockets/ and the associated repository which helped me to make this.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bronkhorstcontrolbm31-1.4.0.tar.gz (35.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bronkhorstcontrolbm31-1.4.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file bronkhorstcontrolbm31-1.4.0.tar.gz.

File metadata

  • Download URL: bronkhorstcontrolbm31-1.4.0.tar.gz
  • Upload date:
  • Size: 35.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for bronkhorstcontrolbm31-1.4.0.tar.gz
Algorithm Hash digest
SHA256 6cb47f94abfbf9c4e29bfcce308889e8ffd1105b5dd54fe615f047cf8693e265
MD5 012ed2f4a8f6e33ebf7041f0667787bd
BLAKE2b-256 5b8eb97d59113b63e6e9c3afc828044a56db2613803d336807a34df0fd06378c

See more details on using hashes here.

File details

Details for the file bronkhorstcontrolbm31-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bronkhorstcontrolbm31-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8da0b7a819bf1cbbc0a0d209fbd64e395167f1db4eb3fa03dda90ff177f1dacb
MD5 ede4ba88c0be45daee15a790bda372ab
BLAKE2b-256 b43a9d26a7245d0e4224f66ecd3ec526c565304dc522192beb84f35d1961459a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page