move exercises, lecture examples, labs into subfolders
This commit is contained in:
173
Labs/Lab_1/InitialiseEncoderStateMachineAAR.drawio
Normal file
173
Labs/Lab_1/InitialiseEncoderStateMachineAAR.drawio
Normal file
@@ -0,0 +1,173 @@
|
||||
<mxfile host="app.diagrams.net" modified="2023-10-12T18:46:09.574Z" agent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0" etag="9HDBEFZMa76t1pz0U8o6" version="22.0.4" type="device">
|
||||
<diagram name="Page-1" id="yRchuW892y1ctgYDUm2v">
|
||||
<mxGraphModel dx="1674" dy="744" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-3" value="InitialiseEncoderStateMachine()" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="120" y="10" width="200" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-4" value="Return" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="190" y="210" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-8" value="state = get_current_state()" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="120" y="120" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-9" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitPerimeter=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-3" target="7HQgMKtUSoPUuWo0Vc0E-8" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="220" y="320" as="sourcePoint" />
|
||||
<mxPoint x="440" y="350" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-10" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-8" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="230" y="80" as="sourcePoint" />
|
||||
<mxPoint x="220" y="210" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="220" y="170" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-2" target="2CJKvL2Wo2MYQ2Wh3AHo-5">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-2" value="<div>get_current_state()</div><div><br></div>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.start_1;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="360" width="220" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-5" target="2CJKvL2Wo2MYQ2Wh3AHo-8">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-5" target="2CJKvL2Wo2MYQ2Wh3AHo-16">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-5" value="A == 1 and B == 1" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="185" y="460" width="150" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-8" target="2CJKvL2Wo2MYQ2Wh3AHo-11">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-7" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-8" target="2CJKvL2Wo2MYQ2Wh3AHo-18">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-8" value="A == 1 and B == 0" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="185" y="580" width="150" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-9" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-11" target="2CJKvL2Wo2MYQ2Wh3AHo-14">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-10" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-11" target="2CJKvL2Wo2MYQ2Wh3AHo-20">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-11" value="A == 0 and B == 1" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="185" y="700" width="150" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-12" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-14" target="2CJKvL2Wo2MYQ2Wh3AHo-22">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-13" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-14" target="2CJKvL2Wo2MYQ2Wh3AHo-24">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-14" value="A == 0 and B == 0" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="185" y="825" width="150" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-15" value="<div>Return state</div>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="210" y="1070" width="100" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-16" value="state = 3" style="whiteSpace=wrap;html=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="430" y="470" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-17" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-18" target="2CJKvL2Wo2MYQ2Wh3AHo-27">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-18" value="state = 2" style="whiteSpace=wrap;html=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="430" y="590" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-19" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-20" target="2CJKvL2Wo2MYQ2Wh3AHo-32">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-20" value="state = 4" style="whiteSpace=wrap;html=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="430" y="710" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-21" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-22" target="2CJKvL2Wo2MYQ2Wh3AHo-28">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-22" value="state = 1" style="whiteSpace=wrap;html=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="430" y="835" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-23" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-34" target="2CJKvL2Wo2MYQ2Wh3AHo-15">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-24" value="state = 1" style="whiteSpace=wrap;html=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="940" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-25" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-16" target="2CJKvL2Wo2MYQ2Wh3AHo-27">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="550" y="500" as="sourcePoint" />
|
||||
<mxPoint x="680" y="680" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-26" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-32" target="2CJKvL2Wo2MYQ2Wh3AHo-30">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-27" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="670" y="610" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-28" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="670" y="855" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-29" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-30" target="2CJKvL2Wo2MYQ2Wh3AHo-34">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="680" y="1040" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-30" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="670" y="855" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-31" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-27" target="2CJKvL2Wo2MYQ2Wh3AHo-32">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="680" y="620" as="sourcePoint" />
|
||||
<mxPoint x="680" y="865" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-32" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="670" y="730" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-33" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="2CJKvL2Wo2MYQ2Wh3AHo-24" target="2CJKvL2Wo2MYQ2Wh3AHo-34">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="260" y="1000" as="sourcePoint" />
|
||||
<mxPoint x="260" y="1070" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-34" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="250" y="1030" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-35" value="<div>true</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="320" y="470" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-36" value="<div>true</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="325" y="590" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-37" value="<div>true</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="325" y="710" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-38" value="<div>true</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="320" y="835" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-39" value="<div>false</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="540" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-40" value="<div>false</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="660" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-41" value="<div>false</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="780" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2CJKvL2Wo2MYQ2Wh3AHo-42" value="<div>false</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="895" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
BIN
Labs/Lab_1/InitialiseEncoderStateMachineAAR.pdf
Normal file
BIN
Labs/Lab_1/InitialiseEncoderStateMachineAAR.pdf
Normal file
Binary file not shown.
7
Labs/Lab_1/Makefile
Normal file
7
Labs/Lab_1/Makefile
Normal file
@@ -0,0 +1,7 @@
|
||||
include ../../Makefile
|
||||
|
||||
build:
|
||||
zip Lab1PrepAAR.zip *.c *.ino *.pdf *.png
|
||||
|
||||
clean:
|
||||
rm -f Lab1PrepAAR.zip TestEncoderAAR TwoSensorsAAR
|
||||
339
Labs/Lab_1/MotorEncoderAAR.ino
Normal file
339
Labs/Lab_1/MotorEncoderAAR.ino
Normal file
@@ -0,0 +1,339 @@
|
||||
/* Example of driving servomotor and reading encoder signals in various ways */
|
||||
|
||||
#include <avr/io.h> /* Needed to set up counter on pin 47 */
|
||||
#include <SPI.h> /* Needed to communicate with LS7366R (Counter Click) */
|
||||
|
||||
/* Serial input aspects are based closely upon:
|
||||
http://forum.arduino.cc/index.php?topic=396450
|
||||
Example 4 - Receive a number as text and convert it to an int
|
||||
Modified to read a float */
|
||||
|
||||
/* LS7366R aspects very loosely based on concepts used in controlling
|
||||
the Robogaia 3-axis encoder shield though implementation is very different
|
||||
https://www.robogaia.com/3-axis-encoder-conter-arduino-shield.html */
|
||||
|
||||
/* Counting using Timer 5 (external counter input) based loosely on code from
|
||||
https://forum.arduino.cc/index.php?topic=59396.0 written by bubuldino */
|
||||
|
||||
/* Pins used for L298 driver */
|
||||
#define enA 13 /* PWM output, also visible as LED */
|
||||
#define in1 8 /* H bridge selection input 1 */
|
||||
#define in2 9 /* H bridge selection input 2 */
|
||||
#define minPercent -100.0
|
||||
#define maxPercent 100.0
|
||||
|
||||
/* Encoder input pins (used for state machine and interrupts) */
|
||||
#define channelA 2
|
||||
#define channelB 3
|
||||
|
||||
/* Used to to initiate SPI communication to LS7366R chip (Counter click) */
|
||||
#define chipSelectPin 10
|
||||
|
||||
/* Size of buffer used to store received characters */
|
||||
#define numChars 32
|
||||
|
||||
/* Intervals in milliseconds for user-defined timed loops */
|
||||
#define printInterval 1000
|
||||
|
||||
/* Global variables used in serial input */
|
||||
char receivedChars[numChars]; // an array to store the received data
|
||||
float dataNumber = 0; // new for this version
|
||||
boolean newData = false;
|
||||
|
||||
/* Global variables used for motor control and encoder reading */
|
||||
double percentSpeed;
|
||||
double encoderValue;
|
||||
|
||||
/* Used for state machine and encoder reading */
|
||||
typedef enum states{state1=1, state2, state3, state4};
|
||||
volatile long int count = 0;
|
||||
volatile long int error = 0;
|
||||
volatile states state;
|
||||
bool channelAState, channelBState;
|
||||
|
||||
/* Used for handling overflows in Timer 5 */
|
||||
volatile long int bigLaps;
|
||||
|
||||
/* Global variables used for loop timing */
|
||||
unsigned long prevMillisPrint = 0; /* stores last time values were printed */
|
||||
unsigned long prevMillisControl = 0; /* stores last time control action was updated */
|
||||
|
||||
/* Overlapping regions of memory used to convert four bytes to a long integer */
|
||||
union fourBytesToLong
|
||||
{
|
||||
long result;
|
||||
unsigned char bytes [4];
|
||||
};
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
Serial.println("Enter PWM duty cycle as a percentage (positive for forward, negative for reverse");
|
||||
|
||||
/* Set encoder pins as input but with pullup resistors to be compatible with various encoders */
|
||||
pinMode(channelA, INPUT_PULLUP);
|
||||
pinMode(channelB, INPUT_PULLUP);
|
||||
|
||||
channelAState = digitalRead(channelA);
|
||||
channelBState = digitalRead(channelB);
|
||||
|
||||
initialiseEncoderStateMachine(); /* Find initial state based on inputs */
|
||||
|
||||
/* Set up and initialise pin used for selecting LS7366R counter: hi=inactive */
|
||||
pinMode(chipSelectPin, OUTPUT);
|
||||
digitalWrite(chipSelectPin, HIGH);
|
||||
|
||||
SetUpLS7366RCounter();
|
||||
|
||||
delay(100);
|
||||
|
||||
/* Configure Timer 5 to count pulses on pin 47 */
|
||||
pinMode(47, INPUT_PULLUP); // set pin to input with pullup resistor
|
||||
|
||||
TCCR5A = 0; // No waveform generation needed.
|
||||
TCCR5B = (1<<CS50) | (1<<CS51) | (1<<CS52); // Normal mode, clock from pin T5 on rising edge. T5 is Arduinos Pin 47
|
||||
TCCR5C = 0; // No force output compare.
|
||||
TCNT5 = 0; // Initialise counter register to zero.
|
||||
TIMSK5= (1<<TOIE5); // Enable overflow interrupt
|
||||
sei(); // Enable all interrupts
|
||||
bigLaps = 0; // Initialise number of overflows
|
||||
|
||||
/* Configure control pins for L298 H bridge */
|
||||
pinMode(enA, OUTPUT);
|
||||
pinMode(in1, OUTPUT);
|
||||
pinMode(in2, OUTPUT);
|
||||
|
||||
/* Set initial rotation direction */
|
||||
digitalWrite(in1, LOW);
|
||||
digitalWrite(in2, HIGH);
|
||||
|
||||
//attachInterrupt(digitalPinToInterrupt(channelA), updateEncoderStateMachine, CHANGE);
|
||||
//attachInterrupt(digitalPinToInterrupt(channelB), updateEncoderStateMachine, CHANGE);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
if (currentMillis - prevMillisPrint >= printInterval) {
|
||||
// save the last time you printed output
|
||||
prevMillisPrint = currentMillis;
|
||||
printLoop();
|
||||
}
|
||||
|
||||
recvWithEndMarker();
|
||||
if(convertNewNumber())
|
||||
// Update value read from serial line
|
||||
{
|
||||
percentSpeed=dataNumber;
|
||||
driveMotorPercent(percentSpeed);
|
||||
}
|
||||
|
||||
updateEncoderStateMachine();
|
||||
}
|
||||
|
||||
void driveMotorPercent(double percentSpeed)
|
||||
/* Output PWM and H bridge signals based on positive or negative duty cycle % */
|
||||
{
|
||||
percentSpeed = constrain(percentSpeed, -100, 100);
|
||||
int regVal = map(percentSpeed, -100, 100, -255, 255);
|
||||
analogWrite(enA, (int)abs(regVal));
|
||||
digitalWrite(in1, regVal>0);
|
||||
digitalWrite(in2, !(regVal>0));
|
||||
}
|
||||
|
||||
void printLoop()
|
||||
/* Print count and control information */
|
||||
{
|
||||
/* Sample all counters one after the other to avoid delay-related offsets */
|
||||
long encoderCountFromLS7366R = readEncoderCountFromLS7366R();
|
||||
long encoderCountFromStateMC = count;
|
||||
long stateMCerror = error;
|
||||
long timer5Count = TCNT5 + bigLaps*65536;
|
||||
Serial.print("Count from LS7366R = ");
|
||||
Serial.print(encoderCountFromLS7366R);
|
||||
Serial.print(" from state m/c = ");
|
||||
Serial.print(encoderCountFromStateMC);
|
||||
Serial.print(" State m/c errors = ");
|
||||
Serial.print(stateMCerror);
|
||||
Serial.print(" Count from LS7366R/4 = ");
|
||||
Serial.print(encoderCountFromLS7366R/4);
|
||||
Serial.print(" from Timer 5 = ");
|
||||
Serial.print(timer5Count);
|
||||
Serial.print(" Percent speed = ");
|
||||
Serial.print(percentSpeed);
|
||||
Serial.print("\r\n");
|
||||
}
|
||||
|
||||
long readEncoderCountFromLS7366R()
|
||||
/* Reads the LS7366R chip to obtain up/down count from encoder. Reads four
|
||||
bytes separately then concverts them to a long integer using a union */
|
||||
{
|
||||
fourBytesToLong converter; /* Union of four bytes and a long integer */
|
||||
|
||||
digitalWrite(chipSelectPin,LOW); /* Make LS7366R active */
|
||||
|
||||
SPI.transfer(0x60); // Request count
|
||||
converter.bytes[3] = SPI.transfer(0x00); /* Read highest order byte */
|
||||
converter.bytes[2] = SPI.transfer(0x00);
|
||||
converter.bytes[1] = SPI.transfer(0x00);
|
||||
converter.bytes[0] = SPI.transfer(0x00); /* Read lowest order byte */
|
||||
|
||||
digitalWrite(chipSelectPin,HIGH); /* Make LS7366R inactive */
|
||||
|
||||
return converter.result;
|
||||
}
|
||||
|
||||
|
||||
void SetUpLS7366RCounter(void)
|
||||
/* Initialiseds LS7366R hardware counter on Counter Click board to read quadrature signals */
|
||||
{
|
||||
/* Control registers in LS7366R - see LS7366R datasheet for this and subsequent control words */
|
||||
unsigned char IR = 0x00, MRD0=0x00;
|
||||
|
||||
// SPI initialization
|
||||
SPI.begin();
|
||||
//SPI.setClockDivider(SPI_CLOCK_DIV16); // SPI at 1Mhz (on 16Mhz clock)
|
||||
delay(10);
|
||||
|
||||
/* Configure as free-running 4x quadrature counter */
|
||||
digitalWrite(chipSelectPin,LOW); /* Select chip and initialise transfer */
|
||||
/* Instruction register IR */
|
||||
IR |= 0x80; /* Write to register (B7=1, B6=0) */
|
||||
IR |= 0x08; /* Select register MDR0: B5=0, B4=0, B3=1 */
|
||||
SPI.transfer(IR); /* Write to instruction register */
|
||||
/* Mode register 0 */
|
||||
MRD0 |= 0x03; /* 4x quadrature count: B0=1, B1=1 */
|
||||
/* B2=B3=0: free running. B4=B5=0: disable index. */
|
||||
/* B6=0: asynchronous index. B7: Filter division factor = 1. */
|
||||
SPI.transfer(MRD0);
|
||||
digitalWrite(chipSelectPin,HIGH);
|
||||
|
||||
/* Clear the counter i.e. set it to zero */
|
||||
IR = 0x00; /* Clear the instructino register IR */
|
||||
digitalWrite(chipSelectPin,LOW); /* Select chip and initialise transfer */
|
||||
IR |= 0x20; /* Select CNTR: B5=1,B4=0,B3=0; CLR register: B7=0,B6=0 */
|
||||
SPI.transfer(IR); /* Write to instruction register */
|
||||
digitalWrite(chipSelectPin,HIGH);
|
||||
|
||||
}
|
||||
|
||||
void recvWithEndMarker()
|
||||
/* Receive data from serial port finishing with "newline" character.
|
||||
Based on http://forum.arduino.cc/index.php?topic=396450 Example 4 */
|
||||
{
|
||||
static byte ndx = 0;
|
||||
char endMarker = '\n';
|
||||
char rc;
|
||||
|
||||
if (Serial.available() > 0) {
|
||||
rc = Serial.read();
|
||||
|
||||
if (rc != endMarker) {
|
||||
receivedChars[ndx] = rc;
|
||||
ndx++;
|
||||
if (ndx >= numChars) {
|
||||
ndx = numChars - 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
receivedChars[ndx] = '\0'; // terminate the string
|
||||
ndx = 0;
|
||||
newData = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool convertNewNumber()
|
||||
/* Converts character string to floating point number only if there are new
|
||||
data to convert, otherwise returns false */
|
||||
{
|
||||
if (newData) {
|
||||
dataNumber = 0.0; // new for this version
|
||||
dataNumber = atof(receivedChars); // new for this version
|
||||
newData = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Could be implemented as a C macro, which would be faster
|
||||
// but I've forgotten how to define C macros
|
||||
enum states get_current_state()
|
||||
{
|
||||
channelAState = digitalRead(channelA);
|
||||
channelBState = digitalRead(channelB);
|
||||
|
||||
/* If A is 0 and B is 0, system is in State 1
|
||||
If A is 1 and B is 0, system is in State 2
|
||||
If A is 1 and B is 1, system is in State 3
|
||||
If A is 0 and B is 1, system is in State 4 */
|
||||
if (channelAState && channelBState) return state3;
|
||||
if (channelAState && (!channelBState)) return state2;
|
||||
if ((!channelAState) && channelBState) return state4;
|
||||
if ((!channelAState) && (!channelBState)) return state1;
|
||||
}
|
||||
|
||||
|
||||
// doesn't have to be a fn anymore, but will be to maintain readability, expandability,
|
||||
// compatibility with setup() fn
|
||||
// also speed impact probably doesn't matter much since setup() runs once per boot
|
||||
void initialiseEncoderStateMachine()
|
||||
{
|
||||
// gets current state (initial) state and sets it
|
||||
state = get_current_state();
|
||||
}
|
||||
|
||||
|
||||
void updateEncoderStateMachine()
|
||||
{
|
||||
enum states new_state = get_current_state(); // get new state, don't update state var yet so states can be compared
|
||||
|
||||
// check new state is valid, coming from state1, increment error count if not
|
||||
// adjust count as appropriate if new state is valid
|
||||
// repeat for all other state cases
|
||||
switch (state)
|
||||
{
|
||||
case state1:
|
||||
switch (new_state) {
|
||||
case state1: break;
|
||||
case state2: count++; break;
|
||||
case state3: error++; break;
|
||||
case state4: count--; break;
|
||||
}
|
||||
|
||||
break;
|
||||
case state2:
|
||||
switch (new_state) {
|
||||
case state1: count--; break;
|
||||
case state2: break;
|
||||
case state3: count++; break;
|
||||
case state4: error++; break;
|
||||
}
|
||||
break;
|
||||
case state3:
|
||||
switch (new_state) {
|
||||
case state1: error++; break;
|
||||
case state2: count--; break;
|
||||
case state3: break;
|
||||
case state4: count++; break;
|
||||
}
|
||||
break;
|
||||
case state4:
|
||||
switch (new_state) {
|
||||
case state1: count++; break;
|
||||
case state2: error++; break;
|
||||
case state3: count--; break;
|
||||
case state4: break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
state = new_state; // set new state
|
||||
}
|
||||
128
Labs/Lab_1/TestEncoderAAR.c
Normal file
128
Labs/Lab_1/TestEncoderAAR.c
Normal file
@@ -0,0 +1,128 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define bool int
|
||||
#define byte unsigned char
|
||||
#define numChars 32
|
||||
|
||||
// Here we are using global variables simply to be compatible with the Arduino program structure
|
||||
// This is REALLY bad practice so please don't do it otherwise!
|
||||
long int count = 0;
|
||||
long int error = 0;
|
||||
|
||||
enum states {state1=1, state2, state3, state4};
|
||||
bool channelAState=0;
|
||||
bool channelBState=0;
|
||||
|
||||
enum states state;
|
||||
char receivedChars[numChars]="00"; // an array to store the received data
|
||||
|
||||
void initialiseEncoderStateMachine();
|
||||
void updateEncoderStateMachine();
|
||||
enum states get_current_state();
|
||||
|
||||
int main()
|
||||
{
|
||||
// Replicates the setup in Arduino
|
||||
printf("Enter a pair of characters representing initial states of channels A and B\n");
|
||||
scanf("%s",receivedChars);
|
||||
channelAState = receivedChars[0]!='0';
|
||||
channelBState = receivedChars[1]!='0';
|
||||
|
||||
initialiseEncoderStateMachine();
|
||||
printf("State %d, count %ld, error %ld\n", state, count, error);
|
||||
printf("Enter a pair of characters representing channels A and B, enter 99 to end\n");
|
||||
|
||||
// Replicates the loop in Arduino
|
||||
do
|
||||
{
|
||||
scanf("%s",receivedChars);
|
||||
if (strcmp(receivedChars, "99")==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
channelAState = receivedChars[0]!='0';
|
||||
channelBState = receivedChars[1]!='0';
|
||||
updateEncoderStateMachine();
|
||||
printf("State %d, count %ld, error %ld\n", state, count, error);
|
||||
|
||||
}
|
||||
while(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Could be implemented as a C macro, which would be faster
|
||||
// but I've forgotten how to define C macros
|
||||
enum states get_current_state()
|
||||
{
|
||||
/* If A is 0 and B is 0, system is in State 1
|
||||
If A is 1 and B is 0, system is in State 2
|
||||
If A is 1 and B is 1, system is in State 3
|
||||
If A is 0 and B is 1, system is in State 4 */
|
||||
|
||||
if (channelAState && channelBState) return state3;
|
||||
if (channelAState && (!channelBState)) return state2;
|
||||
if ((!channelAState) && channelBState) return state4;
|
||||
if ((!channelAState) && (!channelBState)) return state1;
|
||||
|
||||
return state1; // silences clang-diagnostic-return-type warning
|
||||
}
|
||||
|
||||
|
||||
// doesn't have to be a fn anymore, but will be to maintain readability, expandability,
|
||||
// compatibility with setup() fn
|
||||
// also speed impact probably doesn't matter much since setup() runs once per boot
|
||||
void initialiseEncoderStateMachine()
|
||||
{
|
||||
// gets current state (initial) state and sets it
|
||||
state = get_current_state();
|
||||
}
|
||||
|
||||
|
||||
void updateEncoderStateMachine()
|
||||
{
|
||||
enum states new_state = get_current_state(); // get new state, don't update state yet so states can be compared
|
||||
|
||||
// check new state is valid, coming from state1, increment error count if not
|
||||
// adjust count as appropriate if new state is valid
|
||||
// repeat for all other state cases
|
||||
switch (state)
|
||||
{
|
||||
case state1:
|
||||
switch (new_state) {
|
||||
case state1: break;
|
||||
case state2: count++; break;
|
||||
case state3: error++; break;
|
||||
case state4: count--; break;
|
||||
}
|
||||
|
||||
break;
|
||||
case state2:
|
||||
switch (new_state) {
|
||||
case state1: count--; break;
|
||||
case state2: break;
|
||||
case state3: count++; break;
|
||||
case state4: error++; break;
|
||||
}
|
||||
break;
|
||||
case state3:
|
||||
switch (new_state) {
|
||||
case state1: error++; break;
|
||||
case state2: count--; break;
|
||||
case state3: break;
|
||||
case state4: count++; break;
|
||||
}
|
||||
break;
|
||||
case state4:
|
||||
switch (new_state) {
|
||||
case state1: count++; break;
|
||||
case state2: error++; break;
|
||||
case state3: count--; break;
|
||||
case state4: break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
state = new_state; // set new state
|
||||
}
|
||||
BIN
Labs/Lab_1/TestEncoderAAR.png
Normal file
BIN
Labs/Lab_1/TestEncoderAAR.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
183
Labs/Lab_1/TwoSensorsAAR.c
Normal file
183
Labs/Lab_1/TwoSensorsAAR.c
Normal file
@@ -0,0 +1,183 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
// Forward TC function
|
||||
float NISTdegCtoMilliVoltsKtype(float tempDegC); // returns EMF in millivolts
|
||||
|
||||
// Inverse TC function
|
||||
float NISTmilliVoltsToDegCKtype(float tcEMFmV); // returns temp in degC assuming 0 degC cold jcn
|
||||
|
||||
float adc_to_voltage(float v_ref, int n_adc);
|
||||
float kelvin_to_c(float k);
|
||||
float resistance_to_thermistor_temperature(float r);
|
||||
float voltage_to_thermistor_resistance(float v);
|
||||
float voltage_to_erc(float v);
|
||||
|
||||
int main()
|
||||
{
|
||||
float v_ref = 5, e_rc, e_comp;
|
||||
float thermistor_temp, thermocouple_temp;
|
||||
int thermistor_val, thermocouple_val; // User input for pins A0 and A1
|
||||
|
||||
printf("Enter values for thermistor pin, thermocouple pin: ");
|
||||
scanf("%d %d", &thermistor_val, &thermocouple_val);
|
||||
|
||||
// Calculate thermistor temperature in degrees C ( Part b, i,ii,iii & v)
|
||||
thermistor_temp = kelvin_to_c(resistance_to_thermistor_temperature(voltage_to_thermistor_resistance(adc_to_voltage(v_ref, thermistor_val))));
|
||||
|
||||
// Calculate thermocouple temperature in degrees C ( Part c, i - iv)
|
||||
e_rc = 1000*voltage_to_erc(adc_to_voltage(v_ref, thermocouple_val)); // convert to millivolts
|
||||
e_comp = NISTdegCtoMilliVoltsKtype(thermistor_temp); // eqn (6) lab prep sheet
|
||||
thermocouple_temp = NISTmilliVoltsToDegCKtype(e_rc + e_comp); // eqn (7) lab prep sheet
|
||||
|
||||
|
||||
// Output results
|
||||
printf("Thermistor temperature (deg C): %f \n", thermistor_temp);
|
||||
printf("Thermocouple temperature with CJC (deg C): %f \n", thermocouple_temp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Write a function here to convert ADC value to voltages. (Part a, equation 1)
|
||||
Call it from the main() function above */
|
||||
float adc_to_voltage(float v_ref, int n_adc) {
|
||||
return (float)n_adc*v_ref/1024.0; // eqn (1) lab prep sheet
|
||||
}
|
||||
|
||||
|
||||
/* Write a function to convert degrees K to degrees C (Part b, (iv))
|
||||
Call it from the main() function above */
|
||||
|
||||
float kelvin_to_c(float k) {
|
||||
return k-273.15;
|
||||
}
|
||||
|
||||
|
||||
// Convert Resistance (Ohms) to Temperature (Kelvin) (for thermistor)
|
||||
float resistance_to_thermistor_temperature(float r) {
|
||||
// Define Thermistor constants
|
||||
float t_0 = 298.15; // Kelvin
|
||||
float r_0 = 10000; // Ohms
|
||||
float b = 3975; // Kelvin
|
||||
|
||||
return 1.0 / ( (1.0/t_0) + (1.0/b)*log(r/r_0)); // eqn (3) lab prep sheet
|
||||
}
|
||||
|
||||
|
||||
// Convert Voltage (Volts) to Resistance (Ohms)
|
||||
float voltage_to_thermistor_resistance(float v) {
|
||||
float pull_down_resistance = 10; // kOhms
|
||||
float v_hi = 3.3; // Volts
|
||||
|
||||
return 1000*((pull_down_resistance*v_hi/v)-10.0); // eqn (4) lab prep sheet
|
||||
}
|
||||
|
||||
|
||||
// Convert Voltage to E_RC
|
||||
float voltage_to_erc(float v) {
|
||||
return (v-0.35)/54.4; // eqn (5) lab prep sheet
|
||||
}
|
||||
|
||||
|
||||
/* returns EMF in millivolts */
|
||||
float NISTdegCtoMilliVoltsKtype(float tempDegC)
|
||||
{
|
||||
int i;
|
||||
float milliVolts = 0;
|
||||
if(tempDegC >= -170 && tempDegC < 0)
|
||||
{
|
||||
const float coeffs[11] =
|
||||
{
|
||||
0.000000000000E+00,
|
||||
0.394501280250E-01,
|
||||
0.236223735980E-04,
|
||||
-0.328589067840E-06,
|
||||
-0.499048287770E-08,
|
||||
-0.675090591730E-10,
|
||||
-0.574103274280E-12,
|
||||
-0.310888728940E-14,
|
||||
-0.104516093650E-16,
|
||||
-0.198892668780E-19,
|
||||
-0.163226974860E-22
|
||||
};
|
||||
for (i=0; i<=10; i++)
|
||||
{
|
||||
milliVolts += coeffs[i] * pow(tempDegC,i);
|
||||
}
|
||||
}
|
||||
else if(tempDegC >= 0 && tempDegC <= 1372)
|
||||
{
|
||||
const float coeffs[10] =
|
||||
{
|
||||
-0.176004136860E-01,
|
||||
0.389212049750E-01,
|
||||
0.185587700320E-04,
|
||||
-0.994575928740E-07,
|
||||
0.318409457190E-09,
|
||||
-0.560728448890E-12,
|
||||
0.560750590590E-15,
|
||||
-0.320207200030E-18,
|
||||
0.971511471520E-22,
|
||||
-0.121047212750E-25
|
||||
};
|
||||
const float a0 = 0.118597600000E+00;
|
||||
const float a1 = -0.118343200000E-03;
|
||||
const float a2 = 0.126968600000E+03;
|
||||
|
||||
for (i=0; i<=9; i++)
|
||||
{
|
||||
milliVolts += coeffs[i] * pow(tempDegC,i);
|
||||
}
|
||||
|
||||
milliVolts += a0*exp(a1*(tempDegC - a2)*(tempDegC - a2));
|
||||
}
|
||||
else
|
||||
{
|
||||
milliVolts = 99E99;
|
||||
}
|
||||
return milliVolts;
|
||||
}
|
||||
|
||||
// returns temperature in deg C.
|
||||
float NISTmilliVoltsToDegCKtype(float tcEMFmV)
|
||||
{
|
||||
|
||||
int i, j;
|
||||
float tempDegC = 0;
|
||||
const float coeffs[11][3] =
|
||||
{
|
||||
{0.0000000E+00, 0.000000E+00, -1.318058E+02},
|
||||
{2.5173462E+01, 2.508355E+01, 4.830222E+01},
|
||||
{-1.1662878E+00, 7.860106E-02, -1.646031E+00},
|
||||
{-1.0833638E+00, -2.503131E-01, 5.464731E-02},
|
||||
{-8.9773540E-01, 8.315270E-02, -9.650715E-04},
|
||||
{-3.7342377E-01, -1.228034E-02, 8.802193E-06},
|
||||
{-8.6632643E-02, 9.804036E-04, -3.110810E-08},
|
||||
{-1.0450598E-02, -4.413030E-05, 0.000000E+00},
|
||||
{-5.1920577E-04, 1.057734E-06, 0.000000E+00},
|
||||
{0.0000000E+00, -1.052755E-08, 0.000000E+00}
|
||||
};
|
||||
if(tcEMFmV >=-5.891 && tcEMFmV <=0 )
|
||||
{
|
||||
j=0;
|
||||
}
|
||||
else if (tcEMFmV > 0 && tcEMFmV <=20.644 )
|
||||
{
|
||||
j=1;
|
||||
}
|
||||
else if (tcEMFmV > 20.644 && tcEMFmV <=54.886 )
|
||||
{
|
||||
j=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 99E9;
|
||||
}
|
||||
|
||||
for (i=0; i<=9; i++)
|
||||
{
|
||||
tempDegC += coeffs[i][j] * pow(tcEMFmV,i);
|
||||
}
|
||||
return tempDegC;
|
||||
}
|
||||
197
Labs/Lab_1/TwoSensorsAAR.ino
Normal file
197
Labs/Lab_1/TwoSensorsAAR.ino
Normal file
@@ -0,0 +1,197 @@
|
||||
/* Test program for reading of thermistor, thermocouple and LVDT.
|
||||
K-type thermocouple functions written by Arthur Jones using
|
||||
official NIST polynomial data from
|
||||
https://srdata.nist.gov/its90/download/type_k.tab */
|
||||
|
||||
#include <math.h> /* needed for exp() and pow() */
|
||||
|
||||
/* It is good practice to define things like pins used at the start
|
||||
so that you avoid hard-coded values (magic numbers) in code */
|
||||
#define TCpin A0
|
||||
#define ThermistorPin A1
|
||||
|
||||
/* Similarly, define any constant values e.g. Vref, B, R0 here to avoid
|
||||
need for "magic numbers" in code */
|
||||
#define V_REF 5
|
||||
|
||||
float adc_to_voltage(int n_adc);
|
||||
float kelvin_to_c(float k);
|
||||
float resistance_to_temperature(float r);
|
||||
float voltage_to_thermistor_resistance(float v);
|
||||
float voltage_to_erc(float v);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
float e_rc, e_comp, thermistor_temp, thermocouple_temp;
|
||||
int thermistor_val, thermocouple_val;
|
||||
/* Put your code here to read ADCs and convert ADC voltages to
|
||||
temperatures */
|
||||
thermistor_val = analogRead(ThermistorPin);
|
||||
thermocouple_val = analogRead(TCpin)
|
||||
// Calculate thermistor temperature in degrees C ( Part b, i,ii,iii & v)
|
||||
thermistor_temp = kelvin_to_c(resistance_to_temperature(voltage_to_thermistor_resistance(adc_to_voltage(thermistor_val))));
|
||||
|
||||
// Calculate thermocouple temperature in degrees C ( Part c, i - iv)
|
||||
e_rc = 1000*voltage_to_erc(adc_to_voltage(thermocouple_val)); // convert to millivolts
|
||||
e_comp = NISTdegCtoMilliVoltsKtype(thermistor_temp); // eqn (6) lab prep sheet
|
||||
thermocouple_temp = NISTmilliVoltsToDegCKtype(e_rc + e_comp); // eqn (7) lab prep sheet
|
||||
|
||||
/* Display results. Don't use printf or formatting etc., they don't work on the Arduino. Just use
|
||||
the serial print statements given here, inserting your own code as needed */
|
||||
Serial.print("Thermistor temperature (deg C): ");
|
||||
Serial.println(thermistor_temp);
|
||||
Serial.print("Thermocouple temperature with CJC (deg C): ");
|
||||
Serial.println(thermocouple_temp);
|
||||
Serial.println("\n");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
/* Write a function to convert ADC value to
|
||||
voltage: put it here and use it in your code above*/
|
||||
float adc_to_voltage(int n_adc) {
|
||||
return (float)n_adc*V_REF/1024.0; // eqn (1) lab prep sheet
|
||||
}
|
||||
|
||||
|
||||
/* Write a function to convert degrees K to degrees C
|
||||
Call it from the main() function above */
|
||||
float kelvin_to_c(float k) {
|
||||
return k-273.15;
|
||||
}
|
||||
|
||||
|
||||
// Convert Resistance (Ohms) to Temperature (Kelvin) (for thermistor)
|
||||
float resistance_to_thermistor_temperature(float r) {
|
||||
// Define Thermistor constants
|
||||
float t_0 = 298.15; // Kelvin
|
||||
float r_0 = 10000; // Ohms
|
||||
float b = 3975; // Kelvin
|
||||
|
||||
return 1.0 / ( (1.0/t_0) + (1.0/b)*log(r/r_0)); // eqn (3) lab prep sheet
|
||||
}
|
||||
|
||||
|
||||
// Convert Voltage (Volts) to Resistance (Ohms)
|
||||
float voltage_to_thermistor_resistance(float v) {
|
||||
float pull_down_resistance = 10; // kOhms
|
||||
float v_hi = 3.3; // Volts
|
||||
|
||||
return 1000*((pull_down_resistance*v_hi/v)-10.0); // eqn (4) lab prep sheet
|
||||
}
|
||||
|
||||
|
||||
// Convert Voltage to E_RC
|
||||
float voltage_to_erc(float v) {
|
||||
return (v-0.35)/54.4; // eqn (5) lab prep sheet
|
||||
}
|
||||
|
||||
|
||||
/* Under no circumstances change any of the following code, it is fine as it is */
|
||||
float NISTdegCtoMilliVoltsKtype(float tempDegC)
|
||||
/* returns EMF in millivolts */
|
||||
{
|
||||
int i;
|
||||
float milliVolts = 0;
|
||||
if(tempDegC >= -170 && tempDegC < 0)
|
||||
{
|
||||
const float coeffs[11] =
|
||||
{
|
||||
0.000000000000E+00,
|
||||
0.394501280250E-01,
|
||||
0.236223735980E-04,
|
||||
-0.328589067840E-06,
|
||||
-0.499048287770E-08,
|
||||
-0.675090591730E-10,
|
||||
-0.574103274280E-12,
|
||||
-0.310888728940E-14,
|
||||
-0.104516093650E-16,
|
||||
-0.198892668780E-19,
|
||||
-0.163226974860E-22
|
||||
};
|
||||
for (i=0; i<=10; i++)
|
||||
{
|
||||
milliVolts += coeffs[i] * pow(tempDegC,i);
|
||||
}
|
||||
}
|
||||
else if(tempDegC >= 0 && tempDegC <= 1372)
|
||||
{
|
||||
const float coeffs[10] =
|
||||
{
|
||||
-0.176004136860E-01,
|
||||
0.389212049750E-01,
|
||||
0.185587700320E-04,
|
||||
-0.994575928740E-07,
|
||||
0.318409457190E-09,
|
||||
-0.560728448890E-12,
|
||||
0.560750590590E-15,
|
||||
-0.320207200030E-18,
|
||||
0.971511471520E-22,
|
||||
-0.121047212750E-25
|
||||
};
|
||||
const float a0 = 0.118597600000E+00;
|
||||
const float a1 = -0.118343200000E-03;
|
||||
const float a2 = 0.126968600000E+03;
|
||||
|
||||
for (i=0; i<=9; i++)
|
||||
{
|
||||
milliVolts += coeffs[i] * pow(tempDegC,i);
|
||||
}
|
||||
|
||||
milliVolts += a0*exp(a1*(tempDegC - a2)*(tempDegC - a2));
|
||||
}
|
||||
else
|
||||
{
|
||||
milliVolts = 99E9;
|
||||
}
|
||||
return milliVolts;
|
||||
}
|
||||
|
||||
|
||||
float NISTmilliVoltsToDegCKtype(float tcEMFmV)
|
||||
// returns temperature in deg C.
|
||||
{
|
||||
|
||||
int i, j;
|
||||
float tempDegC = 0;
|
||||
const float coeffs[11][3] =
|
||||
{
|
||||
{0.0000000E+00, 0.000000E+00, -1.318058E+02},
|
||||
{2.5173462E+01, 2.508355E+01, 4.830222E+01},
|
||||
{-1.1662878E+00, 7.860106E-02, -1.646031E+00},
|
||||
{-1.0833638E+00, -2.503131E-01, 5.464731E-02},
|
||||
{-8.9773540E-01, 8.315270E-02, -9.650715E-04},
|
||||
{-3.7342377E-01, -1.228034E-02, 8.802193E-06},
|
||||
{-8.6632643E-02, 9.804036E-04, -3.110810E-08},
|
||||
{-1.0450598E-02, -4.413030E-05, 0.000000E+00},
|
||||
{-5.1920577E-04, 1.057734E-06, 0.000000E+00},
|
||||
{0.0000000E+00, -1.052755E-08, 0.000000E+00}
|
||||
};
|
||||
if(tcEMFmV >=-5.891 && tcEMFmV <=0 )
|
||||
{
|
||||
j=0;
|
||||
}
|
||||
else if (tcEMFmV > 0 && tcEMFmV <=20.644 )
|
||||
{
|
||||
j=1;
|
||||
}
|
||||
else if (tcEMFmV > 20.644 && tcEMFmV <=54.886 )
|
||||
{
|
||||
j=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 99E9;
|
||||
}
|
||||
|
||||
for (i=0; i<=9; i++)
|
||||
{
|
||||
tempDegC += coeffs[i][j] * pow(tcEMFmV,i);
|
||||
}
|
||||
return tempDegC;
|
||||
}
|
||||
BIN
Labs/Lab_1/TwoSensorsAAR.png
Normal file
BIN
Labs/Lab_1/TwoSensorsAAR.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
567
Labs/Lab_1/UpdateStateMachineAAR.drawio
Normal file
567
Labs/Lab_1/UpdateStateMachineAAR.drawio
Normal file
@@ -0,0 +1,567 @@
|
||||
<mxfile host="app.diagrams.net" modified="2023-10-12T18:49:48.757Z" agent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0" etag="HM_HtakovVQNo2MJql50" version="22.0.4" type="device">
|
||||
<diagram name="Page-1" id="yRchuW892y1ctgYDUm2v">
|
||||
<mxGraphModel dx="2391" dy="1063" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-17" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-15" target="7HQgMKtUSoPUuWo0Vc0E-16" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-15" value="<div>get_current_state()</div><div><br></div>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.start_1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="144" y="199" width="220" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-23" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-16" target="7HQgMKtUSoPUuWo0Vc0E-20" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-29" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-16" target="7HQgMKtUSoPUuWo0Vc0E-28" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-16" value="A == 1 and B == 1" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="179" y="329" width="150" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-24" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-20" target="7HQgMKtUSoPUuWo0Vc0E-21" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-31" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-20" target="7HQgMKtUSoPUuWo0Vc0E-30" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-20" value="A == 1 and B == 0" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="179" y="449" width="150" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-25" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-21" target="7HQgMKtUSoPUuWo0Vc0E-22" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-33" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-21" target="7HQgMKtUSoPUuWo0Vc0E-32" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-21" value="A == 0 and B == 1" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="179" y="569" width="150" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-35" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-22" target="7HQgMKtUSoPUuWo0Vc0E-34" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-37" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-22" target="7HQgMKtUSoPUuWo0Vc0E-36" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-22" value="A == 0 and B == 0" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="179" y="694" width="150" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-26" value="<div>Return state</div>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="204" y="939" width="100" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-28" value="state = 3" style="whiteSpace=wrap;html=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="424" y="339" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-43" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-30" target="7HQgMKtUSoPUuWo0Vc0E-42" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-30" value="state = 2" style="whiteSpace=wrap;html=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="424" y="459" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-51" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-32" target="7HQgMKtUSoPUuWo0Vc0E-50" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-32" value="state = 4" style="whiteSpace=wrap;html=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="424" y="579" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-46" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-34" target="7HQgMKtUSoPUuWo0Vc0E-45" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-34" value="state = 1" style="whiteSpace=wrap;html=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="424" y="704" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-38" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-53" target="7HQgMKtUSoPUuWo0Vc0E-26" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-36" value="state = 1" style="whiteSpace=wrap;html=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="194" y="809" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-44" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-28" target="7HQgMKtUSoPUuWo0Vc0E-42" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="544" y="369" as="sourcePoint" />
|
||||
<mxPoint x="674" y="549" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-49" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-50" target="7HQgMKtUSoPUuWo0Vc0E-48" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-42" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="664" y="479" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-45" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="664" y="724" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-54" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-48" target="7HQgMKtUSoPUuWo0Vc0E-53" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="674" y="909" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-48" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="664" y="724" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-52" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-42" target="7HQgMKtUSoPUuWo0Vc0E-50" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="674" y="489" as="sourcePoint" />
|
||||
<mxPoint x="674" y="734" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-50" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="664" y="599" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-55" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-36" target="7HQgMKtUSoPUuWo0Vc0E-53" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="254" y="869" as="sourcePoint" />
|
||||
<mxPoint x="254" y="939" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-53" value="" style="shape=waypoint;sketch=0;size=6;pointerEvents=1;points=[];fillColor=default;resizable=0;rotatable=0;perimeter=centerPerimeter;snapToPoint=1;strokeWidth=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="244" y="899" width="20" height="20" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-57" value="<div>true</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="314" y="339" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-58" value="<div>true</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="319" y="459" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-59" value="<div>true</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="319" y="579" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-60" value="<div>true</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="314" y="704" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-61" value="<div>false</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="194" y="409" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-62" value="<div>false</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="194" y="529" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-63" value="<div>false</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="194" y="649" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-64" value="<div>false</div>" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="194" y="764" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-75" value="" style="rounded=0;html=1;jettySize=auto;orthogonalLoop=1;fontSize=11;endArrow=block;endFill=0;endSize=8;strokeWidth=1;shadow=0;labelBackgroundColor=none;edgeStyle=orthogonalEdgeStyle;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-79" target="7HQgMKtUSoPUuWo0Vc0E-78" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="100" y="1290" as="sourcePoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-76" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;verticalAlign=bottom;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-78" target="7HQgMKtUSoPUuWo0Vc0E-81" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-77" value="No" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;verticalAlign=middle;labelPosition=right;verticalLabelPosition=middle;align=left;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-78" target="7HQgMKtUSoPUuWo0Vc0E-113" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="100" y="1565" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-78" value="case State1" style="rhombus;whiteSpace=wrap;html=1;shadow=0;fontFamily=Helvetica;fontSize=12;align=center;strokeWidth=1;spacing=6;spacingTop=-4;" parent="1" vertex="1">
|
||||
<mxGeometry x="50" y="1340" width="100" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-86" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-85" target="7HQgMKtUSoPUuWo0Vc0E-79" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="326" y="1250" />
|
||||
<mxPoint x="400" y="1250" />
|
||||
<mxPoint x="400" y="1220" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-79" value="Switch State" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="414" y="1205" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-80" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-81" target="7HQgMKtUSoPUuWo0Vc0E-83" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-90" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-81" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="334" y="1380" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-81" value="new_state == 1" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="184" y="1340" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-82" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-83" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="770" y="1555" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="249" y="1555" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-83" value="do nothing" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="189" y="1480" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-85" value="new_state = get_current_state()" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="194" y="1200" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-93" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-95" target="7HQgMKtUSoPUuWo0Vc0E-97" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-94" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-95" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="480" y="1380" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-95" value="new_state == 2" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="330" y="1340" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-96" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-97" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="395" y="1560" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-97" value="increment count" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="335" y="1480" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-98" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-100" target="7HQgMKtUSoPUuWo0Vc0E-102" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-99" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-100" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="620" y="1380" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-100" value="new_state == 3" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="470" y="1340" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-101" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-102" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="535" y="1560" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-102" value="increment error" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="475" y="1480" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-103" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-105" target="7HQgMKtUSoPUuWo0Vc0E-107" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-105" value="new_state == 4" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="1340" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-106" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-107" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="685" y="1560" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-107" value="decrement count" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="625" y="1480" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-108" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="294" y="1355" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-109" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="430" y="1355" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-110" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="1355" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-111" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;verticalAlign=bottom;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-113" target="7HQgMKtUSoPUuWo0Vc0E-116" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-112" value="No" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;verticalAlign=middle;labelPosition=right;verticalLabelPosition=middle;align=left;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-113" target="7HQgMKtUSoPUuWo0Vc0E-138" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="100" y="1801" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-113" value="case State2" style="rhombus;whiteSpace=wrap;html=1;shadow=0;fontFamily=Helvetica;fontSize=12;align=center;strokeWidth=1;spacing=6;spacingTop=-4;" parent="1" vertex="1">
|
||||
<mxGeometry x="50" y="1576" width="100" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-114" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-116" target="7HQgMKtUSoPUuWo0Vc0E-118" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-115" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-116" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="334" y="1616" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-116" value="new_state == 1" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="184" y="1576" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-117" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-118" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="770" y="1791" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="249" y="1791" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-118" value="decrement" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="189" y="1716" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-119" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-121" target="7HQgMKtUSoPUuWo0Vc0E-123" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-120" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-121" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="480" y="1616" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-121" value="new_state == 2" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="330" y="1576" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-122" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-123" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="395" y="1796" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-123" value="do nothing" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="335" y="1716" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-124" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-126" target="7HQgMKtUSoPUuWo0Vc0E-128" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-125" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-126" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="620" y="1616" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-126" value="new_state == 3" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="470" y="1576" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-127" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-128" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="535" y="1796" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-128" value="increment count" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="475" y="1716" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-129" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-130" target="7HQgMKtUSoPUuWo0Vc0E-132" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-130" value="new_state == 4" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="1576" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-131" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-132" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="685" y="1796" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-132" value="increment error" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="625" y="1716" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-133" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="294" y="1591" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-134" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="430" y="1591" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-135" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="1591" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-136" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;verticalAlign=bottom;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-138" target="7HQgMKtUSoPUuWo0Vc0E-141" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-137" value="No" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;verticalAlign=middle;labelPosition=right;verticalLabelPosition=middle;align=left;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-138" target="7HQgMKtUSoPUuWo0Vc0E-163" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="100" y="2050" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-138" value="case State3" style="rhombus;whiteSpace=wrap;html=1;shadow=0;fontFamily=Helvetica;fontSize=12;align=center;strokeWidth=1;spacing=6;spacingTop=-4;" parent="1" vertex="1">
|
||||
<mxGeometry x="50" y="1825" width="100" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-139" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-141" target="7HQgMKtUSoPUuWo0Vc0E-143" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-140" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-141" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="334" y="1865" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-141" value="new_state == 1" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="184" y="1825" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-142" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-143" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="770" y="2040" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="249" y="2040" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-143" value="increment error" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="189" y="1965" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-144" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-146" target="7HQgMKtUSoPUuWo0Vc0E-148" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-145" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-146" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="480" y="1865" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-146" value="new_state == 2" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="330" y="1825" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-147" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-148" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="395" y="2045" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-148" value="decrement count" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="335" y="1965" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-149" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-151" target="7HQgMKtUSoPUuWo0Vc0E-153" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-150" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-151" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="620" y="1865" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-151" value="new_state == 3" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="470" y="1825" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-152" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-153" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="535" y="2045" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-153" value="do nothing" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="475" y="1965" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-154" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-155" target="7HQgMKtUSoPUuWo0Vc0E-157" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-155" value="new_state == 4" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="1825" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-156" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-157" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="685" y="2045" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-157" value="increment count" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="625" y="1965" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-158" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="294" y="1840" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-159" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="430" y="1840" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-160" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="1840" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-161" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;verticalAlign=bottom;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-163" target="7HQgMKtUSoPUuWo0Vc0E-166" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-163" value="case State4" style="rhombus;whiteSpace=wrap;html=1;shadow=0;fontFamily=Helvetica;fontSize=12;align=center;strokeWidth=1;spacing=6;spacingTop=-4;" parent="1" vertex="1">
|
||||
<mxGeometry x="50" y="2070" width="100" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-164" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-166" target="7HQgMKtUSoPUuWo0Vc0E-168" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-165" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-166" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="334" y="2110" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-166" value="new_state == 1" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="184" y="2070" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-167" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" target="7HQgMKtUSoPUuWo0Vc0E-193" edge="1" source="7HQgMKtUSoPUuWo0Vc0E-168">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="774.6799999999998" y="1193.24" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="249" y="2224" />
|
||||
<mxPoint x="250" y="2224" />
|
||||
<mxPoint x="250" y="2290" />
|
||||
<mxPoint x="770" y="2290" />
|
||||
<mxPoint x="770" y="1190" />
|
||||
<mxPoint x="640" y="1190" />
|
||||
</Array>
|
||||
<mxPoint x="300" y="2260" as="sourcePoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-168" value="increment count" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="189" y="2210" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-169" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-171" target="7HQgMKtUSoPUuWo0Vc0E-173" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-170" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-171" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="480" y="2110" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-171" value="new_state == 2" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="330" y="2070" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-172" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-173" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="395" y="2290" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-173" value="increment error" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="335" y="2210" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-174" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-176" target="7HQgMKtUSoPUuWo0Vc0E-178" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-175" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-176" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="620" y="2110" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-176" value="new_state == 3" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="470" y="2070" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-177" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-178" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="535" y="2290" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-178" value="decrement count" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="475" y="2210" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-179" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-180" target="7HQgMKtUSoPUuWo0Vc0E-182" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-180" value="new_state == 4" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="2070" width="130" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-181" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-182" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="685" y="2290" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-182" value="do nothing" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="625" y="2210" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-183" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="294" y="2085" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-184" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="430" y="2085" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-185" value="no" style="text;strokeColor=none;align=center;fillColor=none;html=1;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="2085" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-187" value="return" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="590" y="1280" width="100" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-191" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.25;entryDx=0;entryDy=0;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-189" target="7HQgMKtUSoPUuWo0Vc0E-85" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="95" y="1250" />
|
||||
<mxPoint x="180" y="1250" />
|
||||
<mxPoint x="180" y="1210" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-189" value="<div>updateStateMachine()</div>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="20" y="1205" width="150" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-194" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="7HQgMKtUSoPUuWo0Vc0E-193" target="7HQgMKtUSoPUuWo0Vc0E-187" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7HQgMKtUSoPUuWo0Vc0E-193" value="state = new_state" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="1210" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
BIN
Labs/Lab_1/UpdateStateMachineAAR.pdf
Normal file
BIN
Labs/Lab_1/UpdateStateMachineAAR.pdf
Normal file
Binary file not shown.
Binary file not shown.
BIN
Labs/Lab_1/res/lab_prep_sheet.pdf
Normal file
BIN
Labs/Lab_1/res/lab_prep_sheet.pdf
Normal file
Binary file not shown.
@@ -0,0 +1,57 @@
|
||||
<mxfile host="app.diagrams.net" modified="2023-09-26T11:35:06.295Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0" etag="nyKtwjN2PcaE_thxzUOw" version="21.8.0" type="device">
|
||||
<diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">
|
||||
<mxGraphModel dx="1434" dy="782" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-0" />
|
||||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-1" parent="WIyWlLk6GJQsqaUBKTNV-0" />
|
||||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-6" value="B = 1?" style="rhombus;whiteSpace=wrap;html=1;shadow=0;fontFamily=Helvetica;fontSize=12;align=center;strokeWidth=1;spacing=6;spacingTop=-4;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1">
|
||||
<mxGeometry x="170" y="240" width="100" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="Qn_TZ-Xwc6BHQTtd6nyY-0" target="Qn_TZ-Xwc6BHQTtd6nyY-5">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-0" value="InitialiseEncoderStateMachine()" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="120" y="10" width="200" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-1" value="Return" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="190" y="460" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-10" value="no" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="Qn_TZ-Xwc6BHQTtd6nyY-5">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="380" y="150" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-14" value="yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=middle;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="Qn_TZ-Xwc6BHQTtd6nyY-5" target="WIyWlLk6GJQsqaUBKTNV-6">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-5" value="A = 1?" style="rhombus;whiteSpace=wrap;html=1;shadow=0;fontFamily=Helvetica;fontSize=12;align=center;strokeWidth=1;spacing=6;spacingTop=-4;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="170" y="110" width="100" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-15" value="State = 3" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="160" y="370" width="120" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-16" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="WIyWlLk6GJQsqaUBKTNV-6" target="Qn_TZ-Xwc6BHQTtd6nyY-15">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="390" y="400" as="sourcePoint" />
|
||||
<mxPoint x="440" y="350" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-17" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="Qn_TZ-Xwc6BHQTtd6nyY-15">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="230" y="330" as="sourcePoint" />
|
||||
<mxPoint x="220" y="460" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="220" y="420" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="Qn_TZ-Xwc6BHQTtd6nyY-19" value="no" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="270" y="280" as="sourcePoint" />
|
||||
<mxPoint x="380" y="280" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
Binary file not shown.
@@ -0,0 +1,44 @@
|
||||
<mxfile host="app.diagrams.net" modified="2023-09-26T13:34:00.880Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0" etag="Tk5ex9ES5EWjcNulA8UX" version="21.8.2" type="device">
|
||||
<diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">
|
||||
<mxGraphModel dx="1434" dy="782" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-0" />
|
||||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-1" parent="WIyWlLk6GJQsqaUBKTNV-0" />
|
||||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-2" value="" style="rounded=0;html=1;jettySize=auto;orthogonalLoop=1;fontSize=11;endArrow=block;endFill=0;endSize=8;strokeWidth=1;shadow=0;labelBackgroundColor=none;edgeStyle=orthogonalEdgeStyle;" parent="WIyWlLk6GJQsqaUBKTNV-1" target="WIyWlLk6GJQsqaUBKTNV-6" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="220" y="120" as="sourcePoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="Dnt90pDJfNcNia8gVZm2-3" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;verticalAlign=bottom;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="WIyWlLk6GJQsqaUBKTNV-6" target="Dnt90pDJfNcNia8gVZm2-1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Dnt90pDJfNcNia8gVZm2-5" value="No" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;verticalAlign=middle;labelPosition=right;verticalLabelPosition=middle;align=left;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="WIyWlLk6GJQsqaUBKTNV-6">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="220" y="330" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-6" value="case State1" style="rhombus;whiteSpace=wrap;html=1;shadow=0;fontFamily=Helvetica;fontSize=12;align=center;strokeWidth=1;spacing=6;spacingTop=-4;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1">
|
||||
<mxGeometry x="170" y="170" width="100" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Dnt90pDJfNcNia8gVZm2-0" value="Switch State" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="160" y="80" width="120" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Dnt90pDJfNcNia8gVZm2-10" value="Yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=bottom;labelBackgroundColor=none;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="Dnt90pDJfNcNia8gVZm2-1" target="Dnt90pDJfNcNia8gVZm2-6">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Dnt90pDJfNcNia8gVZm2-1" value="<div>A = 1 and&nbsp;</div><div>B =0?</div>" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="370" y="170" width="80" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Dnt90pDJfNcNia8gVZm2-12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="Dnt90pDJfNcNia8gVZm2-6" target="Dnt90pDJfNcNia8gVZm2-7">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Dnt90pDJfNcNia8gVZm2-6" value="Increment count" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="350" y="310" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="Dnt90pDJfNcNia8gVZm2-7" value="State = 2" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="350" y="390" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
BIN
Labs/Lab_1/skeleton_flowcharts/UpdateStateMachineSkeleton.pdf
Normal file
BIN
Labs/Lab_1/skeleton_flowcharts/UpdateStateMachineSkeleton.pdf
Normal file
Binary file not shown.
300
Labs/Lab_1/skeleton_programs/MotorEncoderSkeleton.ino
Normal file
300
Labs/Lab_1/skeleton_programs/MotorEncoderSkeleton.ino
Normal file
@@ -0,0 +1,300 @@
|
||||
/* Example of driving servomotor and reading encoder signals in various ways */
|
||||
|
||||
#include <avr/io.h> /* Needed to set up counter on pin 47 */
|
||||
#include <SPI.h> /* Needed to communicate with LS7366R (Counter Click) */
|
||||
|
||||
/* Serial input aspects are based closely upon:
|
||||
http://forum.arduino.cc/index.php?topic=396450
|
||||
Example 4 - Receive a number as text and convert it to an int
|
||||
Modified to read a float */
|
||||
|
||||
/* LS7366R aspects very loosely based on concepts used in controlling
|
||||
the Robogaia 3-axis encoder shield though implementation is very different
|
||||
https://www.robogaia.com/3-axis-encoder-conter-arduino-shield.html */
|
||||
|
||||
/* Counting using Timer 5 (external counter input) based loosely on code from
|
||||
https://forum.arduino.cc/index.php?topic=59396.0 written by bubuldino */
|
||||
|
||||
/* Pins used for L298 driver */
|
||||
#define enA 13 /* PWM output, also visible as LED */
|
||||
#define in1 8 /* H bridge selection input 1 */
|
||||
#define in2 9 /* H bridge selection input 2 */
|
||||
#define minPercent -100.0
|
||||
#define maxPercent 100.0
|
||||
|
||||
/* Encoder input pins (used for state machine and interrupts) */
|
||||
#define channelA 2
|
||||
#define channelB 3
|
||||
|
||||
/* Used to to initiate SPI communication to LS7366R chip (Counter click) */
|
||||
#define chipSelectPin 10
|
||||
|
||||
/* Size of buffer used to store received characters */
|
||||
#define numChars 32
|
||||
|
||||
/* Intervals in milliseconds for user-defined timed loops */
|
||||
#define printInterval 1000
|
||||
|
||||
/* Global variables used in serial input */
|
||||
char receivedChars[numChars]; // an array to store the received data
|
||||
float dataNumber = 0; // new for this version
|
||||
boolean newData = false;
|
||||
|
||||
/* Global variables used for motor control and encoder reading */
|
||||
double percentSpeed;
|
||||
double encoderValue;
|
||||
|
||||
/* Used for state machine and encoder reading */
|
||||
typedef enum states{state1=1, state2, state3, state4};
|
||||
volatile long int count = 0;
|
||||
volatile long int error = 0;
|
||||
volatile states state;
|
||||
bool channelAState, channelBState;
|
||||
|
||||
/* Used for handling overflows in Timer 5 */
|
||||
volatile long int bigLaps;
|
||||
|
||||
/* Global variables used for loop timing */
|
||||
unsigned long prevMillisPrint = 0; /* stores last time values were printed */
|
||||
unsigned long prevMillisControl = 0; /* stores last time control action was updated */
|
||||
|
||||
/* Overlapping regions of memory used to convert four bytes to a long integer */
|
||||
union fourBytesToLong
|
||||
{
|
||||
long result;
|
||||
unsigned char bytes [4];
|
||||
};
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
Serial.println("Enter PWM duty cycle as a percentage (positive for forward, negative for reverse");
|
||||
|
||||
/* Set encoder pins as input but with pullup resistors to be compatible with various encoders */
|
||||
pinMode(channelA, INPUT_PULLUP);
|
||||
pinMode(channelB, INPUT_PULLUP);
|
||||
|
||||
channelAState = digitalRead(channelA);
|
||||
channelBState = digitalRead(channelB);
|
||||
|
||||
initialiseEncoderStateMachine(); /* Find initial state based on inputs */
|
||||
|
||||
/* Set up and initialise pin used for selecting LS7366R counter: hi=inactive */
|
||||
pinMode(chipSelectPin, OUTPUT);
|
||||
digitalWrite(chipSelectPin, HIGH);
|
||||
|
||||
SetUpLS7366RCounter();
|
||||
|
||||
delay(100);
|
||||
|
||||
/* Configure Timer 5 to count pulses on pin 47 */
|
||||
pinMode(47, INPUT_PULLUP); // set pin to input with pullup resistor
|
||||
|
||||
TCCR5A = 0; // No waveform generation needed.
|
||||
TCCR5B = (1<<CS50) | (1<<CS51) | (1<<CS52); // Normal mode, clock from pin T5 on rising edge. T5 is Arduinos Pin 47
|
||||
TCCR5C = 0; // No force output compare.
|
||||
TCNT5 = 0; // Initialise counter register to zero.
|
||||
TIMSK5= (1<<TOIE5); // Enable overflow interrupt
|
||||
sei(); // Enable all interrupts
|
||||
bigLaps = 0; // Initialise number of overflows
|
||||
|
||||
/* Configure control pins for L298 H bridge */
|
||||
pinMode(enA, OUTPUT);
|
||||
pinMode(in1, OUTPUT);
|
||||
pinMode(in2, OUTPUT);
|
||||
|
||||
/* Set initial rotation direction */
|
||||
digitalWrite(in1, LOW);
|
||||
digitalWrite(in2, HIGH);
|
||||
|
||||
//attachInterrupt(digitalPinToInterrupt(channelA), updateEncoderStateMachine, CHANGE);
|
||||
//attachInterrupt(digitalPinToInterrupt(channelB), updateEncoderStateMachine, CHANGE);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
if (currentMillis - prevMillisPrint >= printInterval) {
|
||||
// save the last time you printed output
|
||||
prevMillisPrint = currentMillis;
|
||||
printLoop();
|
||||
}
|
||||
|
||||
recvWithEndMarker();
|
||||
if(convertNewNumber())
|
||||
// Update value read from serial line
|
||||
{
|
||||
percentSpeed=dataNumber;
|
||||
driveMotorPercent(percentSpeed);
|
||||
}
|
||||
|
||||
updateEncoderStateMachine();
|
||||
}
|
||||
|
||||
void driveMotorPercent(double percentSpeed)
|
||||
/* Output PWM and H bridge signals based on positive or negative duty cycle % */
|
||||
{
|
||||
percentSpeed = constrain(percentSpeed, -100, 100);
|
||||
int regVal = map(percentSpeed, -100, 100, -255, 255);
|
||||
analogWrite(enA, (int)abs(regVal));
|
||||
digitalWrite(in1, regVal>0);
|
||||
digitalWrite(in2, !(regVal>0));
|
||||
}
|
||||
|
||||
void printLoop()
|
||||
/* Print count and control information */
|
||||
{
|
||||
/* Sample all counters one after the other to avoid delay-related offsets */
|
||||
long encoderCountFromLS7366R = readEncoderCountFromLS7366R();
|
||||
long encoderCountFromStateMC = count;
|
||||
long stateMCerror = error;
|
||||
long timer5Count = TCNT5 + bigLaps*65536;
|
||||
Serial.print("Count from LS7366R = ");
|
||||
Serial.print(encoderCountFromLS7366R);
|
||||
Serial.print(" from state m/c = ");
|
||||
Serial.print(encoderCountFromStateMC);
|
||||
Serial.print(" State m/c errors = ");
|
||||
Serial.print(stateMCerror);
|
||||
Serial.print(" Count from LS7366R/4 = ");
|
||||
Serial.print(encoderCountFromLS7366R/4);
|
||||
Serial.print(" from Timer 5 = ");
|
||||
Serial.print(timer5Count);
|
||||
Serial.print(" Percent speed = ");
|
||||
Serial.print(percentSpeed);
|
||||
Serial.print("\r\n");
|
||||
}
|
||||
|
||||
long readEncoderCountFromLS7366R()
|
||||
/* Reads the LS7366R chip to obtain up/down count from encoder. Reads four
|
||||
bytes separately then concverts them to a long integer using a union */
|
||||
{
|
||||
fourBytesToLong converter; /* Union of four bytes and a long integer */
|
||||
|
||||
digitalWrite(chipSelectPin,LOW); /* Make LS7366R active */
|
||||
|
||||
SPI.transfer(0x60); // Request count
|
||||
converter.bytes[3] = SPI.transfer(0x00); /* Read highest order byte */
|
||||
converter.bytes[2] = SPI.transfer(0x00);
|
||||
converter.bytes[1] = SPI.transfer(0x00);
|
||||
converter.bytes[0] = SPI.transfer(0x00); /* Read lowest order byte */
|
||||
|
||||
digitalWrite(chipSelectPin,HIGH); /* Make LS7366R inactive */
|
||||
|
||||
return converter.result;
|
||||
}
|
||||
|
||||
|
||||
void SetUpLS7366RCounter(void)
|
||||
/* Initialiseds LS7366R hardware counter on Counter Click board to read quadrature signals */
|
||||
{
|
||||
/* Control registers in LS7366R - see LS7366R datasheet for this and subsequent control words */
|
||||
unsigned char IR = 0x00, MRD0=0x00;
|
||||
|
||||
// SPI initialization
|
||||
SPI.begin();
|
||||
//SPI.setClockDivider(SPI_CLOCK_DIV16); // SPI at 1Mhz (on 16Mhz clock)
|
||||
delay(10);
|
||||
|
||||
/* Configure as free-running 4x quadrature counter */
|
||||
digitalWrite(chipSelectPin,LOW); /* Select chip and initialise transfer */
|
||||
/* Instruction register IR */
|
||||
IR |= 0x80; /* Write to register (B7=1, B6=0) */
|
||||
IR |= 0x08; /* Select register MDR0: B5=0, B4=0, B3=1 */
|
||||
SPI.transfer(IR); /* Write to instruction register */
|
||||
/* Mode register 0 */
|
||||
MRD0 |= 0x03; /* 4x quadrature count: B0=1, B1=1 */
|
||||
/* B2=B3=0: free running. B4=B5=0: disable index. */
|
||||
/* B6=0: asynchronous index. B7: Filter division factor = 1. */
|
||||
SPI.transfer(MRD0);
|
||||
digitalWrite(chipSelectPin,HIGH);
|
||||
|
||||
/* Clear the counter i.e. set it to zero */
|
||||
IR = 0x00; /* Clear the instructino register IR */
|
||||
digitalWrite(chipSelectPin,LOW); /* Select chip and initialise transfer */
|
||||
IR |= 0x20; /* Select CNTR: B5=1,B4=0,B3=0; CLR register: B7=0,B6=0 */
|
||||
SPI.transfer(IR); /* Write to instruction register */
|
||||
digitalWrite(chipSelectPin,HIGH);
|
||||
|
||||
}
|
||||
|
||||
void recvWithEndMarker()
|
||||
/* Receive data from serial port finishing with "newline" character.
|
||||
Based on http://forum.arduino.cc/index.php?topic=396450 Example 4 */
|
||||
{
|
||||
static byte ndx = 0;
|
||||
char endMarker = '\n';
|
||||
char rc;
|
||||
|
||||
if (Serial.available() > 0) {
|
||||
rc = Serial.read();
|
||||
|
||||
if (rc != endMarker) {
|
||||
receivedChars[ndx] = rc;
|
||||
ndx++;
|
||||
if (ndx >= numChars) {
|
||||
ndx = numChars - 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
receivedChars[ndx] = '\0'; // terminate the string
|
||||
ndx = 0;
|
||||
newData = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool convertNewNumber()
|
||||
/* Converts character string to floating point number only if there are new
|
||||
data to convert, otherwise returns false */
|
||||
{
|
||||
if (newData) {
|
||||
dataNumber = 0.0; // new for this version
|
||||
dataNumber = atof(receivedChars); // new for this version
|
||||
newData = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void initialiseEncoderStateMachine()
|
||||
/* User written code to initialise state of state machine code based on input states */
|
||||
{
|
||||
if (channelAState)
|
||||
{
|
||||
if(channelBState)
|
||||
{
|
||||
state = state3;
|
||||
}
|
||||
/* else.... a lot of code goes here! */
|
||||
}
|
||||
}
|
||||
|
||||
void updateEncoderStateMachine()
|
||||
/* User written code to update state and increment count of state machine */
|
||||
{
|
||||
channelAState = digitalRead(channelA);
|
||||
channelBState = digitalRead(channelB);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case state1:
|
||||
if (channelAState && !channelBState)
|
||||
{
|
||||
count++;
|
||||
state = state2;
|
||||
}
|
||||
/* else if .... a lot of code goes here! */
|
||||
/* don't forget "break" at end of each case. */
|
||||
}
|
||||
}
|
||||
|
||||
ISR(TIMER5_OVF_vect )
|
||||
{
|
||||
//when this runs, you had 65536 pulses counted.
|
||||
bigLaps++;
|
||||
}
|
||||
|
||||
87
Labs/Lab_1/skeleton_programs/TestEncoder.c
Normal file
87
Labs/Lab_1/skeleton_programs/TestEncoder.c
Normal file
@@ -0,0 +1,87 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define bool int
|
||||
#define byte unsigned char
|
||||
#define numChars 32
|
||||
|
||||
void initialiseEncoderStateMachine();
|
||||
void updateEncoderStateMachine();
|
||||
|
||||
// Here we are using global variables simply to be compatible with the Arduino program structure
|
||||
// This is REALLY bad practice so please don't do it otherwise!
|
||||
long int count = 0;
|
||||
long int error = 0;
|
||||
|
||||
enum states {state1=1, state2, state3, state4};
|
||||
bool channelAState=0;
|
||||
bool channelBState=0;
|
||||
|
||||
enum states state;
|
||||
char receivedChars[numChars]="00"; // an array to store the received data
|
||||
|
||||
int main()
|
||||
{
|
||||
// Replicates the setup in Arduino
|
||||
printf("Enter a pair of characters representing initial states of channels A and B\n");
|
||||
scanf("%s",receivedChars);
|
||||
channelAState = receivedChars[0]!='0';
|
||||
channelBState = receivedChars[1]!='0';
|
||||
|
||||
initialiseEncoderStateMachine();
|
||||
printf("State %d, count %ld, error %ld\n", state, count, error);
|
||||
printf("Enter a pair of characters representing channels A and B, enter 99 to end\n");
|
||||
|
||||
// Replicates the loop in Arduino
|
||||
do
|
||||
{
|
||||
scanf("%s",receivedChars);
|
||||
if (strcmp(receivedChars, "99")==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
channelAState = receivedChars[0]!='0';
|
||||
channelBState = receivedChars[1]!='0';
|
||||
updateEncoderStateMachine();
|
||||
printf("State %d, count %ld, error %ld\n", state, count, error);
|
||||
|
||||
}
|
||||
while(1);
|
||||
return 0;
|
||||
}
|
||||
void initialiseEncoderStateMachine()
|
||||
{
|
||||
/* If initially A is 0 and B is 0, system starts in State 1
|
||||
If initially A is 1 and B is 0, system starts in State 2
|
||||
If initially A is 1 and B is 1, system starts in State 3
|
||||
If initially A is 0 and B is 1, system starts in State 4 */
|
||||
|
||||
if (channelAState)
|
||||
{
|
||||
if(channelBState)
|
||||
{
|
||||
state = state3;
|
||||
}
|
||||
/* else .... lots of code goes here */
|
||||
}
|
||||
}
|
||||
|
||||
void updateEncoderStateMachine()
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case state1:
|
||||
/* If A is 0 and B is 0, do nothing and stay in State 1
|
||||
If A is 1 and B is 0, add 1 to main counter and go to State 2
|
||||
If A is 0 and B is 1, subtract 1 to main counter and go to State 4
|
||||
If A is 1 and B is 1, do nothing to main counter but add 1 to error counter and go to state 3 */
|
||||
|
||||
if (channelAState && !channelBState)
|
||||
{
|
||||
count++;
|
||||
state = state2;
|
||||
}
|
||||
/* else .... lots of code goes here */
|
||||
break; /* don't forget break at the end of each case! */
|
||||
}
|
||||
}
|
||||
116
Labs/Lab_1/skeleton_programs/TestEncoder.ino
Normal file
116
Labs/Lab_1/skeleton_programs/TestEncoder.ino
Normal file
@@ -0,0 +1,116 @@
|
||||
/* Test program for incremental encoder state machine code */
|
||||
/* Serial input aspects are based closely upon:
|
||||
http://forum.arduino.cc/index.php?topic=396450
|
||||
Example 4 - Receive a number as text and convert it to an int
|
||||
Modified to read a float */
|
||||
|
||||
long int count = 0;
|
||||
long int error = 0;
|
||||
enum states{state1=1, state2, state3, state4};
|
||||
bool channelAState;
|
||||
bool channelBState;
|
||||
|
||||
int state;
|
||||
const byte numChars = 32;
|
||||
char receivedChars[numChars]; // an array to store the received data
|
||||
|
||||
boolean newData = false;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Enter initial state as a 2-digit number e.g. 01 then hit return");
|
||||
do {
|
||||
recvWithEndMarker();
|
||||
} while (!newData);
|
||||
channelAState = receivedChars[0]!='0';
|
||||
channelBState = receivedChars[1]!='0';
|
||||
|
||||
initialiseEncoderStateMachine();
|
||||
Serial.print(state);
|
||||
Serial.print('\n');
|
||||
|
||||
Serial.println("Now keep entering state as a 2-digit number e.g. 01 then hit return.");
|
||||
newData = false;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
recvWithEndMarker();
|
||||
if (newData)
|
||||
{
|
||||
channelAState = receivedChars[0]!='0';
|
||||
channelBState = receivedChars[1]!='0';
|
||||
updateEncoderStateMachine();
|
||||
Serial.print("State: ");
|
||||
Serial.print((int)state);
|
||||
Serial.print(" Count: ");
|
||||
Serial.print(count);
|
||||
Serial.print(" Error: ");
|
||||
Serial.print(error);
|
||||
Serial.write('\n');
|
||||
newData = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void recvWithEndMarker() {
|
||||
static byte ndx = 0;
|
||||
char endMarker = '\n';
|
||||
char rc;
|
||||
|
||||
while (Serial.available() > 0 && newData == false) {
|
||||
rc = Serial.read();
|
||||
|
||||
if (rc != endMarker) {
|
||||
receivedChars[ndx] = rc;
|
||||
ndx++;
|
||||
if (ndx >= numChars) {
|
||||
ndx = numChars - 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
receivedChars[ndx] = '\0'; // terminate the string
|
||||
ndx = 0;
|
||||
newData = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void initialiseEncoderStateMachine()
|
||||
{
|
||||
/* If initially A is 0 and B is 0, system starts in State 1
|
||||
If initially A is 1 and B is 0, system starts in State 2
|
||||
If initially A is 1 and B is 1, system starts in State 3
|
||||
If initially A is 0 and B is 1, system starts in State 4 */
|
||||
|
||||
if (channelAState)
|
||||
{
|
||||
if(channelBState)
|
||||
{
|
||||
state = state3;
|
||||
}
|
||||
/* else .... lots of code goes here */
|
||||
}
|
||||
}
|
||||
|
||||
void updateEncoderStateMachine()
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case state1:
|
||||
/* If A is 0 and B is 0, do nothing and stay in State 1
|
||||
If A is 1 and B is 0, add 1 to main counter and go to State 2
|
||||
If A is 0 and B is 1, subtract 1 to main counter and go to State 4
|
||||
If A is 1 and B is 1, do nothing to main counter but add 1 to error counter and go to state 3 */
|
||||
|
||||
if (channelAState && !channelBState)
|
||||
{
|
||||
count++;
|
||||
state = state2;
|
||||
}
|
||||
/* else .... lots of code goes here */
|
||||
break; /* don't forget break at the end of each case! */
|
||||
/* other cases follow */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
135
Labs/Lab_1/skeleton_programs/TwoSensorsSkeleton.c
Normal file
135
Labs/Lab_1/skeleton_programs/TwoSensorsSkeleton.c
Normal file
@@ -0,0 +1,135 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
// Forward TC function
|
||||
float NISTdegCtoMilliVoltsKtype(float tempDegC); // returns EMF in millivolts
|
||||
|
||||
// Inverse TC function
|
||||
float NISTmilliVoltsToDegCKtype(float tcEMFmV); // returns temp in degC assuming 0 degC cold jcn
|
||||
|
||||
int main()
|
||||
{
|
||||
// Define VRef
|
||||
|
||||
// Define Thermistor constants
|
||||
|
||||
// User input for pins A0 and A1
|
||||
|
||||
// Calculate thermistor temperature in degrees C ( Part b, i,ii,iii & v)
|
||||
|
||||
// Calculate thermocouple temperature in degrees C ( Part c, i - iv)
|
||||
|
||||
// Output results
|
||||
printf("Thermistor temperature (deg C): %f \n", *******);
|
||||
printf("Thermocouple temperature with CJC (deg C): %f \n", ******);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write a function here to convert ADC value to voltages. (Part a, equation 1)
|
||||
Call it from the main() function above */
|
||||
|
||||
/* Write a function to convert degrees K to degrees C (Part b, (iv))
|
||||
Call it from the main() function above */
|
||||
|
||||
/* returns EMF in millivolts */
|
||||
float NISTdegCtoMilliVoltsKtype(float tempDegC)
|
||||
{
|
||||
int i;
|
||||
float milliVolts = 0;
|
||||
if(tempDegC >= -170 && tempDegC < 0)
|
||||
{
|
||||
const float coeffs[11] =
|
||||
{
|
||||
0.000000000000E+00,
|
||||
0.394501280250E-01,
|
||||
0.236223735980E-04,
|
||||
-0.328589067840E-06,
|
||||
-0.499048287770E-08,
|
||||
-0.675090591730E-10,
|
||||
-0.574103274280E-12,
|
||||
-0.310888728940E-14,
|
||||
-0.104516093650E-16,
|
||||
-0.198892668780E-19,
|
||||
-0.163226974860E-22
|
||||
};
|
||||
for (i=0; i<=10; i++)
|
||||
{
|
||||
milliVolts += coeffs[i] * pow(tempDegC,i);
|
||||
}
|
||||
}
|
||||
else if(tempDegC >= 0 && tempDegC <= 1372)
|
||||
{
|
||||
const float coeffs[10] =
|
||||
{
|
||||
-0.176004136860E-01,
|
||||
0.389212049750E-01,
|
||||
0.185587700320E-04,
|
||||
-0.994575928740E-07,
|
||||
0.318409457190E-09,
|
||||
-0.560728448890E-12,
|
||||
0.560750590590E-15,
|
||||
-0.320207200030E-18,
|
||||
0.971511471520E-22,
|
||||
-0.121047212750E-25
|
||||
};
|
||||
const float a0 = 0.118597600000E+00;
|
||||
const float a1 = -0.118343200000E-03;
|
||||
const float a2 = 0.126968600000E+03;
|
||||
|
||||
for (i=0; i<=9; i++)
|
||||
{
|
||||
milliVolts += coeffs[i] * pow(tempDegC,i);
|
||||
}
|
||||
|
||||
milliVolts += a0*exp(a1*(tempDegC - a2)*(tempDegC - a2));
|
||||
}
|
||||
else
|
||||
{
|
||||
milliVolts = 99E99;
|
||||
}
|
||||
return milliVolts;
|
||||
}
|
||||
|
||||
// returns temperature in deg C.
|
||||
float NISTmilliVoltsToDegCKtype(float tcEMFmV)
|
||||
{
|
||||
|
||||
int i, j;
|
||||
float tempDegC = 0;
|
||||
const float coeffs[11][3] =
|
||||
{
|
||||
{0.0000000E+00, 0.000000E+00, -1.318058E+02},
|
||||
{2.5173462E+01, 2.508355E+01, 4.830222E+01},
|
||||
{-1.1662878E+00, 7.860106E-02, -1.646031E+00},
|
||||
{-1.0833638E+00, -2.503131E-01, 5.464731E-02},
|
||||
{-8.9773540E-01, 8.315270E-02, -9.650715E-04},
|
||||
{-3.7342377E-01, -1.228034E-02, 8.802193E-06},
|
||||
{-8.6632643E-02, 9.804036E-04, -3.110810E-08},
|
||||
{-1.0450598E-02, -4.413030E-05, 0.000000E+00},
|
||||
{-5.1920577E-04, 1.057734E-06, 0.000000E+00},
|
||||
{0.0000000E+00, -1.052755E-08, 0.000000E+00}
|
||||
};
|
||||
if(tcEMFmV >=-5.891 && tcEMFmV <=0 )
|
||||
{
|
||||
j=0;
|
||||
}
|
||||
else if (tcEMFmV > 0 && tcEMFmV <=20.644 )
|
||||
{
|
||||
j=1;
|
||||
}
|
||||
else if (tcEMFmV > 20.644 && tcEMFmV <=54.886 )
|
||||
{
|
||||
j=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 99E9;
|
||||
}
|
||||
|
||||
for (i=0; i<=9; i++)
|
||||
{
|
||||
tempDegC += coeffs[i][j] * pow(tcEMFmV,i);
|
||||
}
|
||||
return tempDegC;
|
||||
}
|
||||
143
Labs/Lab_1/skeleton_programs/TwoSensorsSkeleton.ino
Normal file
143
Labs/Lab_1/skeleton_programs/TwoSensorsSkeleton.ino
Normal file
@@ -0,0 +1,143 @@
|
||||
/* Test program for reading of thermistor, thermocouple and LVDT.
|
||||
K-type thermocouple functions written by Arthur Jones using
|
||||
official NIST polynomial data from
|
||||
https://srdata.nist.gov/its90/download/type_k.tab */
|
||||
|
||||
#include <math.h> /* needed for exp() and pow() */
|
||||
|
||||
/* It is good practice to define things like pins used at the start
|
||||
so that you avoid hard-coded values (magic numbers) in code */
|
||||
#define TCpin A0
|
||||
#define ThermistorPin A1
|
||||
|
||||
/* Similarly, define any constant values e.g. Vref, B, R0 here to avoid
|
||||
need for "magic numbers" in code */
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
/* Put your code here to read ADCs and convert ADC voltages to
|
||||
temperatures */
|
||||
|
||||
/* Display results. Don't use printf or formatting etc., they don't work on the Arduino. Just use
|
||||
the serial print statements given here, inserting your own code as needed */
|
||||
Serial.print("Thermistor temperature (deg C): ");
|
||||
Serial.println(.........); // Replace ... with your code, it won't compile until you do.
|
||||
Serial.print(" Thermocouple temperature with CJC (deg C): ");
|
||||
Serial.println(.........); // Replace ... with your code, it won't compile until you do.
|
||||
Serial.println("\n");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
/* Write a function to convert ADC value to
|
||||
voltage: put it here and use it in your code above*/
|
||||
|
||||
/* Write a function to convert degrees K to degrees C
|
||||
Call it from the main() function above */
|
||||
|
||||
/* Under no circumstances change any of the following code, it is fine as it is */
|
||||
float NISTdegCtoMilliVoltsKtype(float tempDegC)
|
||||
/* returns EMF in millivolts */
|
||||
{
|
||||
int i;
|
||||
float milliVolts = 0;
|
||||
if(tempDegC >= -170 && tempDegC < 0)
|
||||
{
|
||||
const float coeffs[11] =
|
||||
{
|
||||
0.000000000000E+00,
|
||||
0.394501280250E-01,
|
||||
0.236223735980E-04,
|
||||
-0.328589067840E-06,
|
||||
-0.499048287770E-08,
|
||||
-0.675090591730E-10,
|
||||
-0.574103274280E-12,
|
||||
-0.310888728940E-14,
|
||||
-0.104516093650E-16,
|
||||
-0.198892668780E-19,
|
||||
-0.163226974860E-22
|
||||
};
|
||||
for (i=0; i<=10; i++)
|
||||
{
|
||||
milliVolts += coeffs[i] * pow(tempDegC,i);
|
||||
}
|
||||
}
|
||||
else if(tempDegC >= 0 && tempDegC <= 1372)
|
||||
{
|
||||
const float coeffs[10] =
|
||||
{
|
||||
-0.176004136860E-01,
|
||||
0.389212049750E-01,
|
||||
0.185587700320E-04,
|
||||
-0.994575928740E-07,
|
||||
0.318409457190E-09,
|
||||
-0.560728448890E-12,
|
||||
0.560750590590E-15,
|
||||
-0.320207200030E-18,
|
||||
0.971511471520E-22,
|
||||
-0.121047212750E-25
|
||||
};
|
||||
const float a0 = 0.118597600000E+00;
|
||||
const float a1 = -0.118343200000E-03;
|
||||
const float a2 = 0.126968600000E+03;
|
||||
|
||||
for (i=0; i<=9; i++)
|
||||
{
|
||||
milliVolts += coeffs[i] * pow(tempDegC,i);
|
||||
}
|
||||
|
||||
milliVolts += a0*exp(a1*(tempDegC - a2)*(tempDegC - a2));
|
||||
}
|
||||
else
|
||||
{
|
||||
milliVolts = 99E9;
|
||||
}
|
||||
return milliVolts;
|
||||
}
|
||||
|
||||
float NISTmilliVoltsToDegCKtype(float tcEMFmV)
|
||||
// returns temperature in deg C.
|
||||
{
|
||||
|
||||
int i, j;
|
||||
float tempDegC = 0;
|
||||
const float coeffs[11][3] =
|
||||
{
|
||||
{0.0000000E+00, 0.000000E+00, -1.318058E+02},
|
||||
{2.5173462E+01, 2.508355E+01, 4.830222E+01},
|
||||
{-1.1662878E+00, 7.860106E-02, -1.646031E+00},
|
||||
{-1.0833638E+00, -2.503131E-01, 5.464731E-02},
|
||||
{-8.9773540E-01, 8.315270E-02, -9.650715E-04},
|
||||
{-3.7342377E-01, -1.228034E-02, 8.802193E-06},
|
||||
{-8.6632643E-02, 9.804036E-04, -3.110810E-08},
|
||||
{-1.0450598E-02, -4.413030E-05, 0.000000E+00},
|
||||
{-5.1920577E-04, 1.057734E-06, 0.000000E+00},
|
||||
{0.0000000E+00, -1.052755E-08, 0.000000E+00}
|
||||
};
|
||||
if(tcEMFmV >=-5.891 && tcEMFmV <=0 )
|
||||
{
|
||||
j=0;
|
||||
}
|
||||
else if (tcEMFmV > 0 && tcEMFmV <=20.644 )
|
||||
{
|
||||
j=1;
|
||||
}
|
||||
else if (tcEMFmV > 20.644 && tcEMFmV <=54.886 )
|
||||
{
|
||||
j=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 99E9;
|
||||
}
|
||||
|
||||
for (i=0; i<=9; i++)
|
||||
{
|
||||
tempDegC += coeffs[i][j] * pow(tcEMFmV,i);
|
||||
}
|
||||
return tempDegC;
|
||||
}
|
||||
Reference in New Issue
Block a user