-
Notifications
You must be signed in to change notification settings - Fork 0
/
edgepi-adc.html
295 lines (286 loc) · 9.47 KB
/
edgepi-adc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<script type="text/javascript">
RED.nodes.registerType("adc", {
category: "EdgePi",
color: "#f391aa",
defaults: {
name: { value: "" },
transport: { value: "Local" },
tcpAddress: { value: "" },
tcpPort: { value: "" },
read: { value: "single" },
adcNum: { value: 1 },
adc1DataRate: { value: 38400 },
adc2DataRate: { value: 800 },
channel: { value: 1 },
diff: { value: 1 },
},
inputs: 1,
outputs: 1,
icon: "right-arrow-bracket.svg",
label: function () {
return this.name || "adc";
},
oneditprepare: function () {
const transportType = document.getElementById("node-input-transport");
const tcpTransportInputs = document.querySelector(".form-row.tcp");
const read = document.getElementById("node-input-read");
const adcNum = document.getElementById("node-input-adcNum");
const adc1 = document.getElementById("adc-option-adc1");
const dataRateField = document.querySelector(".form-row.data-rate");
const adc1DataRate = document.getElementById("node-input-adc1DataRate");
const adc2DataRate = document.getElementById("node-input-adc2DataRate");
const channelField = document.querySelector(".form-row.channel");
const diffField = document.querySelector(".form-row.diff");
function updateEditor() {
tcpTransportInputs.style.display =
transportType.value === "Network" ? "flex" : "none";
channelField.style.display = read.value === "single" ? "flex" : "none";
dataRateField.style.display = read.value === "single" ? "flex" : "none";
diffField.style.display = read.value === "diff" ? "flex" : "none";
adc1DataRate.style.display = adcNum.value === "1" ? "flex" : "none";
adc2DataRate.style.display = adcNum.value === "2" ? "flex" : "none";
if (read.value === "rtd") {
adcNum.value = "2";
adcNum.setAttribute("disabled", true);
} else {
adcNum.removeAttribute("disabled");
}
}
updateEditor();
transportType.addEventListener("change", updateEditor);
read.addEventListener("change", updateEditor);
adcNum.addEventListener("change", updateEditor);
},
});
</script>
<script type="text/html" data-template-name="adc">
<style>
* {
box-sizing: border-box !important;
}
.form-row {
display: flex;
align-items: center;
}
.form-row > label {
margin-top: auto;
margin-bottom: auto;
}
.form-row.tcp {
flex-direction: row;
align-items: center;
margin-top: -5px;
margin-bottom: 10px;
}
.tcp-address-input {
width: 160px !important;
margin-left: 100px !important;
}
.tcp-port-input {
width: 60px !important;
}
.tcp-port-label {
width: 5px !important;
margin: auto 5px;
}
</style>
<div class="form-row name">
<label for="node-input-name"><i class="fa fa-tag"></i> Name:</label>
<input type="text" id="node-input-name" placeholder="Name" />
</div>
<div class="form-row transport">
<label for="node-input-transport">RPC Server:</label>
<select id="node-input-transport">
<option value="Local">Local</option>
<option value="Network">Network</option>
</select>
</div>
<div class="form-row tcp">
<input
class="tcp-address-input"
type="text"
id="node-input-tcpAddress"
placeholder="IP Address/ Hostname"
/>
<label class="tcp-port-label" for="node-input-tcpPort">:</label>
<input
class="tcp-port-input"
type="text"
id="node-input-tcpPort"
placeholder="Port"
/>
</div>
<div class="form-row read">
<label for="node-input-read">Read:</label>
<select id="node-input-read">
<option value="single">Single-ended</option>
<option value="diff">Differential</option>
<option value="rtd">RTD</option>
</select>
</div>
<div class="form-row adcNum">
<label for="node-input-adcNum">ADC:</label>
<select id="node-input-adcNum">
<option value="1" id="adc-option-adc1">ADC1</option>
<option value="2">ADC2</option>
</select>
</div>
<div class="form-row data-rate">
<label for="node-input-adc1DataRate">Data Rate:</label>
<select id="node-input-adc1DataRate">
<option value="2.5">2.5 S/s</option>
<option value="5">5 S/s</option>
<option value="10">10 S/s</option>
<option value="16P6">16.6 S/s</option>
<option value="20">20 S/s</option>
<option value="50">50 S/s</option>
<option value="60">60 S/s</option>
<option value="100">100 S/s</option>
<option value="400">400 S/s</option>
<option value="1200">1200 S/s</option>
<option value="2400">2400 S/s</option>
<option value="4800">4800 S/s</option>
<option value="7200">7200 S/s</option>
<option value="14400">14400 S/s</option>
<option value="19200">19200 S/s</option>
<option value="38400">38400 S/s</option>
</select>
<select id="node-input-adc2DataRate">
<option value="10">10 S/s</option>
<option value="100">100 S/s</option>
<option value="400">400 S/s</option>
<option value="800">800 S/s</option>
</select>
</div>
<div class="form-row channel">
<label for="node-input-channel">Channel:</label>
<select id="node-input-channel">
<option value="1">A-IN1</option>
<option value="2">A-IN2</option>
<option value="3">A-IN3</option>
<option value="4">A-IN4</option>
<option value="5">A-IN5</option>
<option value="6">A-IN6</option>
<option value="7">A-IN7</option>
<option value="8">A-IN8</option>
</select>
</div>
<div class="form-row diff">
<label for="node-input-diff">Differential:</label>
<select id="node-input-diff">
<option value="1">DIFF1</option>
<option value="2">DIFF2</option>
<option value="3">DIFF3</option>
<option value="4">DIFF4</option>
</select>
</div>
</script>
<script type="text/html" data-help-name="adc">
<p>
Reads an analog measurement from a set of input channels on the EdgePi. The
measurement can be configured to be either a voltage, differential or RTD
temperature reading.
</p>
<h3>Details</h3>
<p>Differential Types:</p>
<ul>
<li>DIFF1: Ports 16 & 17</li>
<li>DIFF2: Ports 19 & 20</li>
<li>DIFF3: Ports 21 & 22</li>
<li>DIFF4: Ports 24 & 25</li>
</ul>
<p>Assigned ports for RTD measurements:</p>
<ul>
<li>21</li>
<li>24</li>
<li>25</li>
</ul>
<p>NOTE: Port 22 will also be disabled</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>RPC Server</dt>
<dd>
The connection to your EdgePi's RPC Server. Use <strong>Local</strong> if
node-red is running on EdgePi. Otherwise use the
<strong>Network</strong> option and enter EdgePi's IP address / Hostname.
</dd>
</dl>
<dl class="message-properties">
<dt>Read</dt>
<dd>The type of read to complete.</dd>
</dl>
<dl class="message-properties">
<dt>ADC</dt>
<dd>The ADC to use for the next read.</dd>
</dl>
<dl class="message-properties">
<p>• When configured to read single-ended:</p>
<dt>Channel</dt>
<dd>Which analog channel you read from next.</dd>
</dl>
<dl class="message-properties">
<p>• When configured to read single-ended:</p>
<dt>Data Rate</dt>
<dd>
The selected ADC's data rate. Note that data rates are different depending
on the selected ADC.
</dd>
</dl>
<dl class="message-properties">
<p>• When configured to read differential:</p>
<dt>Differential</dt>
<dd>The differential you want to read next.</dd>
</dl>
<h3>Inputs</h3>
<dd>
Initial configurations set in the editor are applied once the node is
deployed. Configurations can then be dynamically set from input.
</dd>
<dl class="message-properties">
<dt>payload <span class="property-type">number</span></dt>
<dd>
The input selection -- the channel number (1 to 8) or differential
channels number (1 to 4) depending on the read type. Ignored for read type
rtd.
</dd>
<dt>readType <span class="property-type">string</span></dt>
<dd>
<strong>single</strong>, <strong>diff</strong>, or <strong>rtd</strong>.
</dd>
<dt>dataRate <span class="property-type">number</span></dt>
<dd>
ADC data rate. Default values: <strong>38400</strong> (ADC1) and
<strong>800</strong> (ADC2).
</dd>
<dt>adc <span class="property-type">number</span></dt>
<dd>
ADC number to use for reads. Valid values are <strong>1</strong> and
<strong>2</strong>. Default is <strong>1</strong>.
</dd>
</dl>
<h3>Outputs</h3>
<p>• Read type <strong>single</strong> :</p>
<dl class="message-properties">
<dt>payload <span class="property-type">number</span></dt>
<dd>Voltage reading of the specified single-ended analog input channel.</dd>
</dl>
<p>• Read type <strong>diff</strong> :</p>
<dl class="message-properties">
<dt>payload <span class="property-type">number</span></dt>
<dd>
Differential voltage reading of the specified differential channels.
</dd>
</dl>
<p>• Read type <strong>rtd</strong> :</p>
<dl class="message-properties">
<dt>payload <span class="property-type">number</span></dt>
<dd>RTD temperature reading in Celsius.</dd>
</dl>
<h3>References</h3>
<ul>
<li>
<a href="https://github.com/edgepi-cloud/node-red-edgepi-adc">GitHub</a>
-the node's github repository
</li>
</ul>
</script>