Skip to main content

Python driver for MKS EtherCAT mass flow controllers.

Project description

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
{
"actual": 0.1,
"setpoint": 0.1
}
```

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

```
$ mfc 2 --set 1
{
"actual": 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.

Other Tools
===========

#### Wireshark

[Wireshark](https://www.wireshark.org/) is a packet analyzer that comes with
[built-in etherCAT support](https://wiki.wireshark.org/Protocols/ethercat).
Use this to view etherCAT packets as they traverse your network.

#### IgH EtherCAT Master

[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. Clone the repo (it's on sourceforge, which is
currently down), install [this patch](http://lists.etherlab.org/pipermail/etherlab-dev/2014/000435.html),
build, insert kernel mods, 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, which don't come by default on some linux distros (e.g. raspbian).

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.1.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

mfc-0.1.2-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mfc-0.1.2.tar.gz.

File metadata

  • Download URL: mfc-0.1.2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mfc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6a7e801903780c8d2f37d81e570f4b2cc270a4e74e3dcd1a2e6cadb2e9a7c4df
MD5 8f5ce91208d4dd6116782c031d0cd48f
BLAKE2b-256 eeb1b3e92707b8f29f8b5ccaaad4f83cc974064643fc017aff60803841315b2a

See more details on using hashes here.

File details

Details for the file mfc-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mfc-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3afec33ec02b84ece4ddd8141a3716764211ecc943c4fe8bb1a09115480d345a
MD5 26e7d93086041cee06e1575419c5483a
BLAKE2b-256 9337231fe34e183ed0cefd59d9acfe050de58c9366c10d651258b311600dea6d

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