-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicropython.drawio
43 lines (43 loc) · 3.83 KB
/
micropython.drawio
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
<mxfile host="65bd71144e">
<diagram id="8zyJFC5WoWicYbn_2iFL" name="Page-1">
<mxGraphModel dx="476" dy="683" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="2" value="compiled.mpy&nbsp;" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="520" y="270" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="7" value="" style="edgeStyle=none;html=1;" parent="1" source="4" target="2" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="4" value="source.c" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="520" y="190" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="5" value="# run.py<br><br>from mathpad import *<br><br>from .actuaors import set_actuators<br>from .sensors import read_sensors<br>from .model import control_system<br><br>FREQ = 50<br><br>control = mathpad.codegen.micropython(<br>&nbsp; &nbsp; control_system(FREQ)<br>)<br><br>def update():<br>&nbsp; &nbsp; x = read_sensors()<br>&nbsp; &nbsp; y = control(x)<br>&nbsp; &nbsp; set_actuators(y)<br><br>timer = Timer(0)<br>timer.init(freq=FREQ, callback=update)" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="240" y="10" width="240" height="330" as="geometry"/>
</mxCell>
<mxCell id="14" value="" style="edgeStyle=none;html=1;" parent="1" source="10" target="4" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="10" value="# model.py<br><br>from mathpad import *<br><br>def control_system(hz: int):<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; y = ...<br>&nbsp; &nbsp; return discretize(y)" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="500" y="20" width="160" height="140" as="geometry"/>
</mxCell>
<mxCell id="11" value="# sensors.py<br><br>def read_sensors():<br>&nbsp; &nbsp; x = ...<br>&nbsp; &nbsp; return x" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="70" y="20" width="160" height="90" as="geometry"/>
</mxCell>
<mxCell id="13" value="# actuators.py<br><br>def set_actuators(y: float):<br>&nbsp; &nbsp; x = ...<br>&nbsp; &nbsp; return x" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="70" y="130" width="160" height="90" as="geometry"/>
</mxCell>
<mxCell id="15" value="" style="edgeStyle=none;html=1;" parent="1" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="579.74" y="330" as="sourcePoint"/>
<mxPoint x="579.74" y="350" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="16" value="control(x)" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="520" y="350" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>