forked from PyMoDAQ/pymodaq_plugins_raspberry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.rst
More file actions
146 lines (99 loc) · 5.04 KB
/
Copy pathREADME.rst
File metadata and controls
146 lines (99 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Raspberry plugin
################
.. the following must be adapted to your developed package, links to pypi, github description...
.. image:: https://img.shields.io/pypi/v/pymodaq_plugins_raspberry.svg
:target: https://pypi.org/project/pymodaq_plugins_raspberry/
:alt: Latest Version
.. image:: https://readthedocs.org/projects/pymodaq/badge/?version=latest
:target: https://pymodaq.readthedocs.io/en/stable/?badge=latest
:alt: Documentation Status
.. image:: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry/workflows/Upload%20Python%20Package/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry
:alt: Publication Status
.. image:: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry/actions/workflows/Test.yml/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry/actions/workflows/Test.yml
PyMoDAQ plugin to control an experimental device (or test bench) through a
Raspberry Pi.
A small server runs **on the Raspberry Pi** and drives the components of the
device (sensors, actuators); PyMoDAQ talks to that server over the network. From
PyMoDAQ you then get a detector (to read the sensors) and an actuator (to drive
the outputs) as if they were local instruments.
Authors
=======
* Sebastien J. Weber (sebastien.weber@cnrs.fr)
* Fabien Villedieu
Instruments
===========
Below is the list of instruments included in this plugin
Actuators
+++++++++
* **MoveRasp**: drive the outputs of the device (e.g. PWM or all-or-nothing
actuators) wired to the Raspberry
Viewer0D
++++++++
* **ViewRasp**: read the sensors of the device (e.g. I2C sensors) wired to the
Raspberry
Viewer1D
++++++++
* **daqhats**: control of the MCC128 DAQ hat for analog input/output
Viewer2D
++++++++
* **picamera**: control of the integrated pi camera using the Picamera2 library.
This viewer relies on ``picamera2``, which is **only available on Linux/Raspberry**
(it depends on a Linux-only package). On a Windows/macOS control machine the
plugin still installs and works for the remote actuator/detector, but the
PiCamera viewer is simply not loaded.
Adapting the plugin to your setup
=================================
Beware: some plugins are meant to be used with PyMoDAQ installed on the Raspberry directly:
* **daqhats**
* **picamera**
Some other are using the raspberry and the components plugged on it as an external DAQ connected to a computer.
The computer and the Raspberry communicate over ZMQ:
* **MoveRasp**
* **ViewRasp**
ZMQ plugins
===========
Communication
+++++++++++++
The plugin is built to be adapted to a wide range of benches. Three things can be
changed independently:
* **The PyMoDAQ ⇄ Raspberry communication.** It uses a ZeroMQ link by default,
but the transport is isolated behind a dedicated layer: it can be replaced by
another communication mean (serial, HTTP, ...) without touching the rest. On the
Raspberry side, implement the transport interface (``ITransport``) and wire it in
``main.py``; on the PyMoDAQ side, provide a class exposing the same methods as
``ZMQLink`` (``hardware/Link_PMQ.py``).
* **The Raspberry ⇄ components communication.** Each sensor and each actuator is
driven by an interchangeable driver selected from the bench configuration
(``src_raspberry/config.py``). Adding a new component is just a matter of writing
a small driver class and registering it:
- a new sensor → a class in ``src_raspberry/hardware/sensors.py`` registered in
``SENSOR_DRIVER_REGISTRY``;
- a new actuator control mode → a class in ``src_raspberry/hardware/actuators.py``
registered in ``ACTUATOR_DRIVER_REGISTRY`` (``PWM`` and ``DIGITAL`` are provided).
* **The set of JSON requests.** The PyMoDAQ side and the Raspberry side exchange
JSON messages, and new request types can be added easily on both ends:
- **Raspberry side**: add an entry to the routing table ``_requestHandlers`` in
``src_raspberry/handlers/json_handler.py`` with its handler method, which
delegates any hardware access to the hardware backend (``IHardwareBackend``);
- **PyMoDAQ side**: add a method to ``ZMQLink`` (``hardware/Link_PMQ.py``) that
builds and sends the new request, then call it from the move/viewer plugins.
Raspberry-side server
+++++++++++++++++++++
The code that must run on the Raspberry Pi lives in the ``src_raspberry/`` folder
at the root of this repository. It is organised in independent layers — network
transport, JSON request handling, and hardware communication — each behind an
interface, which is what makes the points above easy to adapt. See
``src_raspberry/README.md`` for installation and the JSON protocol.
Installation instructions
+++++++++++++++++++++++++
* PyMoDAQ’s version >= 5
* On a Windows/macOS control machine the plugin installs as is; the ``picamera2``
dependency (Linux-only) is automatically skipped, so only the PiCamera viewer is
unavailable there.
* The Raspberry-side server requires the I2C bus and the ``pigpio`` daemon
(see ``src_raspberry/README.md``).
OnRaspberry Plugins
===================
* PyMoDAQ’s version >= 5