Skip to main content
mfc
===

Python driver and command-line tool for [MKS EtherCAT mass flow controllers](http://www.mksinst.com/product/category.aspx?CategoryID=406).

<p align="center">
<img src="http://www.mksinst.com/images/gseries.jpg" />
</p>

Installation
============

```
pip install mfc
```

If you don't like pip, you can also install from source:

```
git clone https://github.com/numat/mfc.git
cd mfc
python setup.py install
```

Usage
=====

###Command Line

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

```
$ mfc
{
"flow": 0.1,
"setpoint": 0.1
}
```

You can optionally specify an etherCAT position (default 0), and a setpoint flow.

```
$ mfc 2 --set 1
{
"flow": 0.1,
"setpoint": 1
}
```

See `mfc --help` for more.

###Python (Asynchronous)

Asynchronous programming allows us to send out all of our requests in parallel, and then
handle responses as they trickle in. For more information, read through
[krondo's twisted introduction](http://krondo.com/?page_id=1327).

```python
from mfc import FlowController
from tornado.ioloop import IOLoop, PeriodicCallback

def on_response(response):
"""This function gets run whenever a device responds."""
print(response)

def loop():
"""This function will be called in an infinite loop by tornado."""
flow_controller.get(on_response)

flow_controller = FlowController(position=1)

PeriodicCallback(loop, 500).start()
IOLoop.current().start()
```

This looks more complex, but the advantages are well worth it at scale.
Essentially, sleeping is replaced by scheduling functions with tornado. This
allows your code to do other things while waiting for responses.

Extra Resources
===============

[IgH EtherCAT Master](http://www.etherlab.org/en/ethercat/) is a fully featured
etherCAT tool, and can be used to debug new devices. It's not required for this
driver to function, but it'll help if you're having problems. However, it's a
pain to install.

If you want to install, ctlone the repo (the mercurial repo *may* be down), install
[this patch](http://lists.etherlab.org/pipermail/etherlab-dev/2014/000435.html),
build, and register an ethernet port for use.

```
hg clone http://hg.code.sf.net/p/etherlabmaster/code ethercat-hg
cd ethercat-hg
# Patch
./bootstrap linux
./configure --disable-8139too
make
make modules
sudo insmod master/ec_master.ko main_devices=[mac address] # Get mac from e.g. `ifconfig`
sudo chmod 666 /dev/EtherCAT0
sudo insmod devices/ec_generic.ko
sudo ifconfig eth[X] up
```

If you encounter issues, consult [this forum post](http://lists.etherlab.org/pipermail/etherlab-dev/2014/000368.html).
Test with:

```
dmesg
ethercat --help
ethercat pdos
```

It requires kernel headers, and won't install readily on e.g. raspberry pis.

Metadata

Release files for mfc 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mfc 0.1.1
File Size Uploaded
mfc-0.1.1.tar.gz 13.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mfc 0.1.1
File Interpreter ABI Platform
mfc-0.1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 19.4 kB

Release files / mfc-0.1.1.tar.gz

Download URL mfc-0.1.1.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8a917e12c57d54b499d30f807290ebe1b3a9e0f3792e484262ce2e73ac5b40ee
BLAKE2b-256 checksum
How to use checksums
9769e94b7ab6199a8a81df3d1b70b68ba1dd1042cfc33055f0840d6bf39004a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / mfc-0.1.1-py2.py3-none-any.whl

Download URL mfc-0.1.1-py2.py3-none-any.whl
Size 6.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
14e917fed78d94ce399a3d0534717e91af29491e6bec00e615ec0592060b913d
BLAKE2b-256 checksum
How to use checksums
4b4850805245fcd72297c5202643ad9dd7c2b843d6489e7d11ef4e870972a76a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.11

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page