Skip to main content

Python driver for MKS mass flow controllers.

Project description

mfc

Python driver and command-line tool for MKS mass flow controllers.

Installation

pip install mfc

If you want the older python2/tornado driver, use pip install mfc==0.2.11 and review this README.

Usage

This driver uses the ethernet port on the side of the device for communication. If you use this driver, you only need to provide power to the top ports.

Command Line

To test your connection and stream real-time data, use the command-line interface. You can read the flow rate with:

$ mfc 192.168.1.200
{
  "actual": 4.99,
  "gas": "CO2",
  "max": 37,
  "setpoint": 5.00,
  "temperature": 27.34
}

You can optionally specify a setpoint flow and/or gas with e.g. mfc 192.168.1.150 --set 7.5 --set-gas N2. See mfc --help for more.

Python

This uses Python ≥3.5's async/await syntax to asynchronously communicate with the mass flow controller. For example:

import asyncio
from mfc import FlowController

async def get():
    async with FlowController('the-mfc-ip-address') as fc:
        print(await fc.get())

asyncio.run(get())

The API that matters is get, set, and set_gas.

>>> await fc.get()
{
  "actual": 4.99,
  "gas": "CO2",
  "max": 37,
  "setpoint": 5.00,
  "temperature": 27.34
}
>>> await fc.set(10)
>>> await fc.open()   # set to max flow
>>> await fc.close()  # set to zero flow
>>> await fc.set_gas('N2')

There is also set_display, which will only work on devices that support it.

await fc.set_display('flow')

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

mfc-0.3.1.tar.gz (12.9 kB view hashes)

Uploaded Source

Built Distribution

mfc-0.3.1-py2.py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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