0% found this document useful (0 votes)
28 views15 pages

Modbus To Print

Uploaded by

smegcustoms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views15 pages

Modbus To Print

Uploaded by

smegcustoms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1 // Modbus Arduino slave for Mach3 by Ben Bouwer

2 // The purpose of this scetch is to link the Arduino digital and analog pins to
Mach3 using the Modbus Protocol.
3 // To keep things simple I used a register for each pin in the arduino.
4 // Each register can be a Digital input, Digital output, Analog input or PWM
output register
5 // Choose what you want each Arduino Pin to be (Digital input, Digital output,
Analog input, PWM output or MPG input) then:
6 // Edit the list below.
7 // Ensure that you do not use one Arduino pin twice.
8
9 // Recommended Modbus Master: QModbus or Mach3
10 // QModbus http://qmodbus.sourceforge.net/ or
11 // Mach3
12
13 // Mach 3 settings:
14 // See: www.machsupport.com/
15 // Check out www.youtube.com
16 // See: Using Modbus with Mach3 By Peter Homann
17
18
19 // Write a Brain in Mach3 for each register you want to use
20 // To use a button on Arduino to start something in Mach3 use:
21 // Modbus Register --> Pass through --> Output (eg. Cycle start)
22 // To use a LED in Mach3 to switch on a LED on Arduino use:
23 // LED --> Pass through --> Modbus Register
24
25 // Analog Input Pins
26 // The Atmega controllers used for the Arduino contain an onboard 6 channel
analog-to-digital (A/D) converter. The converter has 10 bit resolution,
27 // returning integers from 0 to 1023. If the analog pins are used to detect sensor
values, these values must be maped to a range that is usable (eg. 0 to 255).
28 // While the main function of the analog pins for most Arduino users is to read
analog sensors, the analog pins also
29 // have all the functionality of general purpose input/output (GPIO) pins (the
same as digital pins 0 - 13).
30 // Consequently, if a user needs more general purpose input output pins, and all
the analog pins are not in use, the analog pins may be used for GPIO.
31
32 // Pin mapping
33 // The analog pins can be used identically to the digital pins, using the
aliases A0 (for analog input 0), A1, etc. For example, the code would look like
this
34 // to set analog pin 0 to an output, and to set it HIGH:
35 // pinMode(A0, OUTPUT);
36 // digitalWrite(A0, HIGH);
37
38 // Pullup resistors
39 // The analog pins also have pullup resistors, which work identically to pullup
resistors on the digital pins. They are enabled by issuing a command such as
40 // digitalWrite(A0, INPUT_PULLUP); // set pullup on analog pin 0
41 // Be aware however that turning on a pullup will affect the values reported by
analogRead().
42
43 // Details and Caveats
44 // The analogRead command will not work correctly if a pin has been previously
set to an output, so if this is the case, set it back to an input before using
45 // analogRead. Similarly if the pin has been set to HIGH as an output, the
pullup resistor will be set, when switched back to an input.
46 // The Atmega datasheet also cautions against switching analog pins in close
temporal proximity to making A/D readings (analogRead) on other analog pins.
47 // This can cause electrical noise and introduce jitter in the analog system. It
may be desirable, after manipulating analog pins (in digital mode),
48 // to add a short delay before using analogRead() to read other analog pins.
49
50 // Note
51 // == comparison operator
52 // = assignment operator (sets it equal to)
53
54 // Comparison Operators:
55 // x == y (x is equal to y)
56 // x != y (x is not equal to y)
57 // x < y (x is less than y)
58 // x > y (x is greater than y)
59 // x <= y (x is less than or equal to y)
60 // x >= y (x is greater than or equal to y)
61
62 // LCD
63 // The circuit:
64 // ArduinoPinA4 is the SDA pin for LCD display
65 // ArduinoPinA5 is the SCL pin for LCD display
66
67
68 #include <ModbusRtu.h> // Ensure that the
ModbusRtu library is included (under libraries)
69 #include <Wire.h> // Ensure that the
Wire library is included (under libraries)
70 #include <LiquidCrystal_I2C.h> // Ensure that the
LiquidCrystal_I2C library is included (under libraries)
71 #include <Encoder.h> // MPG encoder
included
72
73
74 LiquidCrystal_I2C lcd(0x27,20,4); // Set the LCD
address to 0x3F for a 16 chars and 2 line display
75 // Check the address
of the LCD by using
I2C Scanner
76
77 #define ID 1 // Slave ID no (1 to
276)
78
79 Modbus slave(ID, 0, 0); // This is the slave
ID for RS-232 or USB-FTDI
80
81 int8_t state = 0; // This is the status
according to au16data (is needed)
82 unsigned long tempus;
83
84 int au16data[27]; // Data array
(integers) for modbus network sharing (Register 00 to Register 26)
85
86
87 // Variables to store Register names
88
89 // Pin 0 reserved for RX
90 // Pin 1 reserved for TX
91
92 const byte Register00 = 0; // Holding
Register for Pin 2
93 const byte Register01 = 1; // Holding
Register for Pin 3
94 const byte Register02 = 2; // Holding
Register for Pin 4
95 const byte Register03 = 3; // Holding
Register for Pin 5
96 const byte Register04 = 4; // Holding
Register for Pin 6
97 const byte Register05 = 5; // Holding
Register for Pin 7
98 const byte Register06 = 6; // Holding
Register for Pin 8
99 const byte Register07 = 7; // Holding
Register for Pin 9
100 const byte Register08 = 8; // Holding
Register for Pin 10
101 const byte Register09 = 9; // Holding
Register for Pin 11
102 const byte Register10 = 10; // Holding
Register for Pin 12
103 const byte Register11 = 11; // Arduino
Register for Pin 13
104
105 const byte Register12 = 12; // Holding
Register for Pin A0
106 const byte Register13 = 13; // Holding
Register for Pin A1
107 const byte Register14 = 14; // Holding
Register for Pin A2
108 const byte Register15 = 15; // Holding
Register for Pin A3
109 const byte Register16 = 16; // Holding
Register for Pin A4
110 const byte Register17 = 17; // Holding
Register for Pin A5
111
112 const byte Register18 = 18; // Holding
Register for LCD values interger X
113 const byte Register19 = 19; // Holding
Register for LCD values decimal X
114 const byte Register20 = 20; // Holding
Register for LCD values interger Y
115 const byte Register21 = 21; // Holding
Register for LCD values decimal Y
116 const byte Register22 = 22; // Holding
Register for LCD values interger Z
117 const byte Register23 = 23; // Holding
Register for LCD values decimal Z
118
119 const byte Register24 = 24; // Holding
Register for MPG1 values
120 const byte Register25 = 25; // Holding
Register for MPG2 values
121 const byte Register26 = 26; // Holding
Register for MPG3 values
122
123 // const byte Register27 = 27; //
Holding Register for InCount
124 // const byte Register28 = 28; //
Holding Register for OutCount
125 // const byte Register29 = 29; //
Holding Register for ErrorCount
126
127
128 // Variables to store input or output types
129 const byte DigitalInput = 0; // Digital
Input
130 const byte DigitalOutput = 1; // Digital
Output
131 const byte AnalogInput = 2; // Analog
Input
132 const byte PWMOutput = 3; // Pulse
Width Modulation Output
133 const byte LCDOutput = 4; // Liquid
Cristal Display Output
134 const byte MPGInput = 5; // Manual
Pulse Generator Input
135
136
137 // Variables to store arduino pin types
138 // Choose what you want each Arduino Pin to be then:
139 // Edit the list below:
140 // Ensure that you do not use one Arduino pin twice.
141 // ***************** Change these to be either DigitalInputs, DigitalOuputs,
AnalogInputs, PWMOutputs or MPGInput *******************
142
143 // Arduino pin 0 is reserved for RX
144 // Arduino pin 1 is reserved for TX
145 int ArduinoPin02Type = DigitalInput; // Use DigitalInput,
DigitalOutput or *******MPGInput*******
146 int ArduinoPin03Type = DigitalInput; // Use DigitalInput,
DigitalOutput, PWMOutput or *******MPGInput*******
147 int ArduinoPin04Type = DigitalInput; // Use DigitalInput,
DigitalOutput or MPGInput
148 int ArduinoPin05Type = DigitalInput; // Use DigitalInput,
DigitalOutput, PWMOutput or MPGInput
149 int ArduinoPin06Type = DigitalInput; // Use DigitalInput,
DigitalOutput, PWMOutput or MPGInput
150 int ArduinoPin07Type = DigitalInput; // Use DigitalInput,
DigitalOutput or MPGInput
151 int ArduinoPin08Type = DigitalInput; // Use DigitalInput,
DigitalOutput or MPGInput
152 int ArduinoPin09Type = DigitalInput; // Use DigitalInput,
DigitalOutput, PWMOutput or MPGInput
153 int ArduinoPin10Type = DigitalInput; // Use DigitalInput,
DigitalOutput, PWMOutput or MPGInput
154 int ArduinoPin11Type = DigitalInput; // Use DigitalInput,
DigitalOutput, PWMOutput or MPGInput
155 int ArduinoPin12Type = DigitalInput; // Use DigitalInput,
DigitalOutput or MPGInput
156 int ArduinoPin13Type = DigitalInput; // Use DigitalInput,
DigitalOutput or MPGInput
157
158 int ArduinoPinA0Type = DigitalOutput; // Use DigitalInput,
DigitalOutput, AnalogInput or MPGInput
159 int ArduinoPinA1Type = DigitalOutput; // Use DigitalInput,
DigitalOutput, AnalogInput or MPGInput
160 int ArduinoPinA2Type = DigitalOutput; // Use DigitalInput,
DigitalOutput, AnalogInput or MPGInput
161 int ArduinoPinA3Type = DigitalOutput; // Use DigitalInput,
DigitalOutput, AnalogInput or MPGInput
162
163 int ArduinoPinA4Type = LCDOutput; // Use DigitalInput,
DigitalOutput, AnalogInput or LCDOutput // A4 is shared with SDA if the LCD is
used
164 int ArduinoPinA5Type = LCDOutput; // Use DigitalInput,
DigitalOutput, AnalogInput or LCDOutput // A5 is shared with SCL if the LCD is
used
165
166
167 // Variable to store LCD Available
168 // *********** Change this to be either true or false *******************
169 boolean LCDAvailable = true ; // Use true if LCD is
available,or false if not available
170
171
172 // Variables to store pin names
173 // Do not change these
174 // Arduino Pin 0 is reserved for RX
175 // Arduino Pin 1 is reserved for TX
176 const byte ArduinoPin02 = 2; // Arduino Pin 2 Z-
177 const byte ArduinoPin03 = 3; // Arduino Pin 3 Z+
178 const byte ArduinoPin04 = 4; // Arduino Pin 4 X-
179 const byte ArduinoPin05 = 5; // Arduino Pin 5 X+
180 const byte ArduinoPin06 = 6; // Arduino Pin 6
Index
181 const byte ArduinoPin07 = 7; // Arduino Pin 7
Stop
182 const byte ArduinoPin08 = 8; // Arduino Pin 8 Fwd
183 const byte ArduinoPin09 = 9; // Arduino Pin 9
Rev
184 const byte ArduinoPin10 = 10; // Arduino Pin 10
Manual
185 const byte ArduinoPin11 = 11; // Arduino Pin 11
Cycle start
186 const byte ArduinoPin12 = 12; // Arduino Pin 12
Singleblock
187 const byte ArduinoPin13 = 13; // Arduino Pin 13
Feedhold
188
189 const byte ArduinoPinA0 = A0; // Arduino Pin A0
190 const byte ArduinoPinA1 = A1; // Arduino Pin A1
191 const byte ArduinoPinA2 = A2; // Arduino Pin A2
192 const byte ArduinoPinA3 = A3; // Arduino Pin A3
193 const byte ArduinoPinA4 = A4; // Arduino Pin A4
194 const byte ArduinoPinA5 = A5; // Arduino Pin A5
195
196
197 // Register Bits
198 // Arranged from right(Bit 0) to left(Bit 15)
199 const byte Bit0 = 0;
200
201
202 // Varables to store sensor values
203 int SensorValueA0 = 0;
204 int SensorValueA1 = 0;
205 int SensorValueA2 = 0;
206 int SensorValueA3 = 0;
207 int SensorValueA4 = 0;
208 int SensorValueA5 = 0;
209
210
211 // Varables to store output values
212 int MappedSensorValueA0 = 0;
213 int MappedSensorValueA1 = 0;
214 int MappedSensorValueA2 = 0;
215 int MappedSensorValueA3 = 0;
216 int MappedSensorValueA4 = 0;
217 int MappedSensorValueA5 = 0;
218
219
220 // Change these two numbers to the pins connected to your encoder.
221 // Best Performance: both pins have interrupt capability
222 // Good Performance: only the first pin has interrupt capability
223 // Low Performance: neither pin has interrupt capability
224 Encoder MPG1(2, 3); // Use 2 and 3 for MPG1
225 // Encoder MPG2(4, 5); // Use 4 and 5 for MPG2
226 // Encoder MPG3(6, 7); // Use 6 and 7 for MPG3
227 // Avoid using pins with LEDs attached
228
229
230 // MPG Old Positions
231 int MPG1oldPosition = 0;
232 // int MPG2oldPosition = 0;
233 // int MPG3oldPosition = 0;
234
235
236 void setup() {
237
238 // Pin modes for Inputs and outputs
239
240 // Arduino pin 0 is reserved for RX
241
242 // Arduino pin 1 is reserved for TX
243
244 // Arduino pin 2
245 if (ArduinoPin02Type == DigitalInput) { pinMode(ArduinoPin02, INPUT_PULLUP); }
246 else if (ArduinoPin02Type == DigitalOutput) { pinMode(ArduinoPin02, OUTPUT); }
247 // ArduinoPin02Type can not be an AnalogInput
248 // ArduinoPin02Type can not be an PWMOutput
249 else if (ArduinoPin02Type == MPGInput) { pinMode(ArduinoPin02, INPUT_PULLUP); }
250
251 // Arduino pin 3
252 if (ArduinoPin03Type == DigitalInput) { pinMode(ArduinoPin03, INPUT_PULLUP); }
253 else if (ArduinoPin03Type == DigitalOutput) { pinMode(ArduinoPin03, OUTPUT); }
254 // ArduinoPin03Type can not be an AnalogInput
255 else if (ArduinoPin03Type == PWMOutput) { pinMode(ArduinoPin03, OUTPUT); }
256 else if (ArduinoPin03Type == MPGInput) { pinMode(ArduinoPin03, INPUT_PULLUP); }
257
258 // Arduino pin 4
259 if (ArduinoPin04Type == DigitalInput) { pinMode(ArduinoPin04, INPUT_PULLUP); }
260 else if (ArduinoPin04Type == DigitalOutput) { pinMode(ArduinoPin04, OUTPUT); }
261 // ArduinoPin04Type can not be an AnalogInput
262 // ArduinoPin04Type can not be an PWMOutput
263 else if (ArduinoPin04Type == MPGInput) { pinMode(ArduinoPin04, INPUT_PULLUP); }
264
265 // Arduino pin 5
266 if (ArduinoPin05Type == DigitalInput) { pinMode(ArduinoPin05, INPUT_PULLUP); }
267 else if (ArduinoPin05Type == DigitalOutput) { pinMode(ArduinoPin05, OUTPUT); }
268 // ArduinoPin05Type can not be an AnalogInput
269 else if (ArduinoPin05Type == PWMOutput) { pinMode(ArduinoPin05, OUTPUT); }
270 else if (ArduinoPin05Type == MPGInput) { pinMode(ArduinoPin05, INPUT_PULLUP); }
271
272 // Arduino pin 6
273 if (ArduinoPin06Type == DigitalInput) { pinMode(ArduinoPin06, INPUT_PULLUP); }
274 else if (ArduinoPin06Type == DigitalOutput) { pinMode(ArduinoPin06, OUTPUT); }
275 // ArduinoPin06Type can not be an AnalogInput
276 else if (ArduinoPin06Type == PWMOutput) { pinMode(ArduinoPin06, OUTPUT); }
277 else if (ArduinoPin06Type == MPGInput) { pinMode(ArduinoPin06, INPUT_PULLUP);
}
278
279 // Arduino pin 7
280 if (ArduinoPin07Type == DigitalInput) { pinMode(ArduinoPin07, INPUT_PULLUP); }
281 else if (ArduinoPin07Type == DigitalOutput) { pinMode(ArduinoPin07, OUTPUT); }
282 // ArduinoPin07Type can not be an AnalogInput
283 // ArduinoPin07Type can not be an PWMOutput
284 else if (ArduinoPin07Type == MPGInput) { pinMode(ArduinoPin07, INPUT_PULLUP); }
285
286 // Arduino pin 8
287 if (ArduinoPin08Type == DigitalInput) { pinMode(ArduinoPin08, INPUT_PULLUP); }
288 else if (ArduinoPin08Type == DigitalOutput) { pinMode(ArduinoPin08, OUTPUT); }
289 // ArduinoPin08Type can not be an AnalogInput
290 // ArduinoPin08Type can not be an PWMOutput
291 else if (ArduinoPin08Type == MPGInput) { pinMode(ArduinoPin08, INPUT_PULLUP); }
292
293 // Arduino pin 9
294 if (ArduinoPin09Type == DigitalInput) { pinMode(ArduinoPin09, INPUT_PULLUP); }
295 else if (ArduinoPin09Type == DigitalOutput) { pinMode(ArduinoPin09, OUTPUT); }
296 // ArduinoPin09Type can not be an AnalogInput
297 else if (ArduinoPin09Type == PWMOutput) { pinMode(ArduinoPin09, OUTPUT); }
298 else if (ArduinoPin09Type == MPGInput) { pinMode(ArduinoPin09, INPUT_PULLUP); }
299
300 // Arduino pin 10
301 if (ArduinoPin10Type == DigitalInput) { pinMode(ArduinoPin10, INPUT_PULLUP); }
302 else if (ArduinoPin10Type == DigitalOutput) { pinMode(ArduinoPin10, OUTPUT); }
303 // ArduinoPin10Type can not be an AnalogInput
304 else if (ArduinoPin10Type == PWMOutput) { pinMode(ArduinoPin10, OUTPUT); }
305 else if (ArduinoPin10Type == MPGInput) { pinMode(ArduinoPin10, INPUT_PULLUP); }
306
307 // Arduino pin 11
308 if (ArduinoPin11Type == DigitalInput) { pinMode(ArduinoPin11, INPUT_PULLUP); }
309 else if (ArduinoPin11Type == DigitalOutput) { pinMode(ArduinoPin11, OUTPUT); }
310 // ArduinoPin11Type can not be an AnalogInput
311 else if (ArduinoPin11Type == PWMOutput) { pinMode(ArduinoPin11, OUTPUT); }
312 else if (ArduinoPin11Type == MPGInput) { pinMode(ArduinoPin11, INPUT_PULLUP); }
313
314 // Arduino pin 12
315 if (ArduinoPin12Type == DigitalInput) { pinMode(ArduinoPin12, INPUT_PULLUP); }
316 else if (ArduinoPin12Type == DigitalOutput) { pinMode(ArduinoPin12, OUTPUT); }
317 // ArduinoPin12Type can not be an AnalogInput
318 // ArduinoPin12Type can not be an PWMOutput
319 else if (ArduinoPin12Type == MPGInput) { pinMode(ArduinoPin12, INPUT_PULLUP); }
320
321 // Arduino pin 13
322 if (ArduinoPin13Type == DigitalInput) { pinMode(ArduinoPin13, INPUT_PULLUP); }
323 else if (ArduinoPin13Type == DigitalOutput) { pinMode(ArduinoPin13, OUTPUT); }
324 // ArduinoPin13Type can not be an AnalogInput
325 // ArduinoPin13Type can not be an PWMOutput
326 else if (ArduinoPin13Type == MPGInput) { pinMode(ArduinoPin13, INPUT_PULLUP); }
327
328
329 // Arduino pin A0
330 if (ArduinoPinA0Type == DigitalInput) { pinMode(ArduinoPinA0, INPUT_PULLUP); }
331 else if (ArduinoPinA0Type == DigitalOutput) { pinMode(ArduinoPinA0, OUTPUT); }
332 else if (ArduinoPinA0Type == AnalogInput) { pinMode(ArduinoPinA0, INPUT); }
333 // ArduinoPinA0Type can not be a PWMOutput
334 else if (ArduinoPinA0Type == MPGInput) { pinMode(ArduinoPinA0, INPUT_PULLUP); }
335
336 // Arduino pin A1
337 if (ArduinoPinA1Type == DigitalInput) { pinMode(ArduinoPinA1, INPUT_PULLUP); }
338 else if (ArduinoPinA1Type == DigitalOutput) { pinMode(ArduinoPinA1, OUTPUT); }
339 else if (ArduinoPinA1Type == AnalogInput) { pinMode(ArduinoPinA1, INPUT); }
340 // ArduinoPinA1Type can not be a PWMOutput
341 else if (ArduinoPinA1Type == MPGInput) { pinMode(ArduinoPinA1, INPUT_PULLUP); }
342
343 // Arduino pin A2
344 if (ArduinoPinA2Type == DigitalInput) { pinMode(ArduinoPinA2, INPUT_PULLUP); }
345 else if (ArduinoPinA2Type == DigitalOutput) { pinMode(ArduinoPinA2, OUTPUT); }
346 else if (ArduinoPinA2Type == AnalogInput) { pinMode(ArduinoPinA2, INPUT); }
347 // ArduinoPinA2Type can not be a PWMOutput
348 else if (ArduinoPinA2Type == MPGInput) { pinMode(ArduinoPinA2, INPUT_PULLUP); }
349
350 // Arduino pin A3
351 if (ArduinoPinA3Type == DigitalInput) { pinMode(ArduinoPinA3, INPUT_PULLUP); }
352 else if (ArduinoPinA3Type == DigitalOutput) { pinMode(ArduinoPinA3, OUTPUT); }
353 else if (ArduinoPinA3Type == AnalogInput) { pinMode(ArduinoPinA3, INPUT); }
354 // ArduinoPinA3Type can not be a PWMOutput
355 else if (ArduinoPinA3Type == MPGInput) { pinMode(ArduinoPinA3, INPUT_PULLUP); }
356
357 // Arduino pin A4
358 if (ArduinoPinA4Type == DigitalInput) { pinMode(ArduinoPinA4, INPUT_PULLUP); }
359 else if (ArduinoPinA4Type == DigitalOutput) { pinMode(ArduinoPinA4, OUTPUT); }
360 else if (ArduinoPinA4Type == AnalogInput) { pinMode(ArduinoPinA4, INPUT); }
361 // ArduinoPinA4Type can not be a PWMOutput
362 else if (ArduinoPinA4Type == MPGInput) { pinMode(ArduinoPinA4, INPUT_PULLUP); }
363
364 // Arduino pin A5
365 if (ArduinoPinA5Type == DigitalInput) { pinMode(ArduinoPinA5, INPUT_PULLUP); }
366 else if (ArduinoPinA5Type == DigitalOutput) { pinMode(ArduinoPinA5, OUTPUT); }
367 else if (ArduinoPinA5Type == AnalogInput) { pinMode(ArduinoPinA5, INPUT); }
368 // ArduinoPinA5Type can not be a PWMOutput
369 else if (ArduinoPinA5Type == MPGInput) { pinMode(ArduinoPinA5, INPUT_PULLUP); }
370
371
372 // Reset all output pins to Low or Zero
373
374 // Arduino pin 0 is reserved for RX
375
376 // Arduino pin 1 is reserved for TX
377
378 // Arduino pin 2
379 if (ArduinoPin02Type == DigitalOutput) { digitalWrite(ArduinoPin02, LOW ); }
380 // Arduino pin 02 is not an PWM output pin
381
382 // Arduino pin 3
383 if (ArduinoPin03Type == DigitalOutput) { digitalWrite(ArduinoPin03, LOW ); }
384 else if (ArduinoPin03Type == PWMOutput) { analogWrite(ArduinoPin03, 0 );
} // use Zero
385
386 // Arduino pin 4
387 if (ArduinoPin04Type == DigitalOutput) { digitalWrite(ArduinoPin04, LOW ); }
388 // Arduino pin 04 is not an PWM output pin
389
390 // Arduino pin 5
391 if (ArduinoPin05Type == DigitalOutput) { digitalWrite(ArduinoPin05, LOW ); }
392 else if (ArduinoPin05Type == PWMOutput) { analogWrite(ArduinoPin05, 0 ); }
393
394 // Arduino pin 6
395 if (ArduinoPin06Type == DigitalOutput) { digitalWrite(ArduinoPin06, LOW ); }
396 else if (ArduinoPin06Type == PWMOutput) { analogWrite(ArduinoPin06, 0 ); }
397
398 // Arduino pin 7
399 if (ArduinoPin07Type == DigitalOutput) { digitalWrite(ArduinoPin07, LOW ); }
400 // Arduino pin 07 is not an PWM output pin
401
402 // Arduino pin 8
403 if (ArduinoPin08Type == DigitalOutput) { digitalWrite(ArduinoPin08, LOW ); }
404 // Arduino pin 08 is not an PWM output pin
405
406 // Arduino pin 9
407 if (ArduinoPin09Type == DigitalOutput) { digitalWrite(ArduinoPin09, LOW ); }
408 else if (ArduinoPin09Type == PWMOutput) { analogWrite(ArduinoPin09, 0 ); }
409
410 // Arduino pin 10
411 if (ArduinoPin10Type == DigitalOutput) { digitalWrite(ArduinoPin10, LOW ); }
412 else if (ArduinoPin10Type == PWMOutput) { analogWrite(ArduinoPin10, 0 ); }
413
414 // Arduino pin 11
415 if (ArduinoPin11Type == DigitalOutput) { digitalWrite(ArduinoPin11, LOW ); }
416 else if (ArduinoPin11Type == PWMOutput) { analogWrite(ArduinoPin11, 0 ); }
417
418 // Arduino pin 12
419 if (ArduinoPin12Type == DigitalOutput) { digitalWrite(ArduinoPin12, LOW ); }
420 // Arduino pin 12 is not an PWM output pin
421
422 // Arduino pin 13
423 if (ArduinoPin13Type == DigitalOutput) { digitalWrite(ArduinoPin13, LOW ); }
424 // Arduino pin 13 is not an PWM output pin
425
426
427 // Arduino pin A0
428 if (ArduinoPinA0Type == DigitalOutput) { digitalWrite(ArduinoPinA0, LOW ); }
429 // ArduinoPinA0Type can not be an PWMOutput
430
431 // Arduino pin A1
432 if (ArduinoPinA1Type == DigitalOutput) { digitalWrite(ArduinoPinA1, LOW ); }
433 // ArduinoPinA1Type can not be an PWMOutput
434
435 // Arduino pin A2
436 if (ArduinoPinA2Type == DigitalOutput) { digitalWrite(ArduinoPinA2, LOW ); }
437 // ArduinoPinA2Type can not be an PWMOutput
438
439 // Arduino pin A3
440 if (ArduinoPinA3Type == DigitalOutput) { digitalWrite(ArduinoPinA3, LOW ); }
441 // ArduinoPinA3Type can not be an PWMOutput
442
443 // Arduino pin A4
444 if (ArduinoPinA4Type == DigitalOutput) { digitalWrite(ArduinoPinA4, LOW ); }
445 // ArduinoPinA4Type can not be an PWMOutput
446
447 // Arduino pin A5
448 if (ArduinoPinA5Type == DigitalOutput) { digitalWrite(ArduinoPinA5, LOW ); }
449 // ArduinoPinA5Type can not be an PWMOutput
450
451
452 // Start communication
453 slave.begin( 19200 ); // Start cmmunication
as a slave Modbus
454
455
456 // Liquid Cristal Display
457 if (LCDAvailable = true) {
458
459 lcd.init(); // Initialize the lcd
460 lcd.setBacklight(50); // Switch the
backlight on (0 to 255)
461 lcd.setCursor(1,0); // Set cursor to
(Colum 1, Row 0)
462 lcd.print("March3 Pendant"); // Print a message to
the LCD.
463 lcd.setCursor(1,1); // Set cursor to
(Colum 1, Row 1)
464 lcd.print("using Arduino"); // Print a message to
the LCD.
465 lcd.setCursor(1,2); // Set cursor to
(Colum 1, Row 2)
466 lcd.print(" by: B Bouwer"); // Print a message to
the LCD.
467 lcd.setCursor(1,3); // Set cursor to
(Colum 1, Row 3)
468 lcd.print(" 2018"); // Print a message to
the LCD.
469
470 lcd.noBlink(); // Set the cursor not
to blink
471 lcd.noCursor(); // Remove the cursor
472 delay (2000); // Wait a bit
473
474 // Scroll 20 positions (string length + display length) to the right to
move it offscreen right:
475 for (int positionCounter = 0; positionCounter < 20; positionCounter++) {
476 lcd.scrollDisplayRight(); // Scroll one position
right:
477 delay(250); // Wait a bit
478 } // End of for
479
480 delay(250);
481 lcd.clear (); // Clears the LCD
482
483 } // End of if (LCDAvailable = true) {
484
485
486 } // End of void setup() {
487
488
489
490 void loop() {
491
492 state = slave.poll( au16data, 27 ); // Poll the state from
the master (is needed)
493
494 // Note - bracets{} are used in this section after the if (Variable == Amount){do
something; do something}
495
496 // Arduino pin 0 is reserved for RX
497
498 // Arduino pin 1 is reserved for TX
499
500 // Arduino pin 2
501 if (ArduinoPin02Type == DigitalInput){ bitWrite( au16data[Register00], Bit0,
not digitalRead(ArduinoPin02)); } // Use NOT to invert the value
502 else if (ArduinoPin02Type == DigitalOutput) { digitalWrite( ArduinoPin02,
bitRead( au16data[Register00], Bit0 )); }
503 // ArduinoPin02Type can not be an analog input
504 // ArduinoPin02Type can not be an PWM output
505
506 // Arduino pin 3
507 if (ArduinoPin03Type == DigitalInput){ bitWrite( au16data[Register01], Bit0,
not digitalRead(ArduinoPin03)); }
508 else if (ArduinoPin03Type == DigitalOutput) { digitalWrite( ArduinoPin03,
bitRead( au16data[Register01], Bit0 )); }
509 // ArduinoPin03Type can not be an analog input
510 else if (ArduinoPin03Type == PWMOutput) { analogWrite( ArduinoPin03,
au16data[Register01] ); }
511
512 // Arduino pin 4
513 if (ArduinoPin04Type == DigitalInput){ bitWrite( au16data[Register02], Bit0,
not digitalRead(ArduinoPin04)); }
514 else if (ArduinoPin04Type == DigitalOutput) { digitalWrite( ArduinoPin04,
bitRead( au16data[Register02], Bit0 )); }
515 // ArduinoPin04Type can not be an analog input
516 // ArduinoPin04Type can not be an PWM output
517
518 // Arduino pin 5
519 if (ArduinoPin05Type == DigitalInput){ bitWrite( au16data[Register03], Bit0,
not digitalRead(ArduinoPin05)); }
520 else if (ArduinoPin05Type == DigitalOutput) { digitalWrite( ArduinoPin05,
bitRead( au16data[Register03], Bit0 )); }
521 // ArduinoPin05Type can not be an analog input
522 else if (ArduinoPin05Type == PWMOutput) { analogWrite( ArduinoPin05,
au16data[Register03] ); }
523
524 // Arduino pin 6
525 if (ArduinoPin06Type == DigitalInput){ bitWrite( au16data[Register04], Bit0,
not digitalRead(ArduinoPin06)); }
526 else if (ArduinoPin06Type == DigitalOutput) { digitalWrite( ArduinoPin06,
bitRead( au16data[Register04], Bit0 )); }
527 // ArduinoPin06Type can not be an analog input
528 else if (ArduinoPin06Type == PWMOutput) { analogWrite( ArduinoPin06,
au16data[Register04] ); }
529
530 // Arduino pin 7
531 if (ArduinoPin07Type == DigitalInput){ bitWrite( au16data[Register05], Bit0,
not digitalRead(ArduinoPin07)); }
532 else if (ArduinoPin07Type == DigitalOutput) { digitalWrite( ArduinoPin07,
bitRead( au16data[Register05], Bit0 )); }
533 // ArduinoPin07Type can not be an analog input
534 // ArduinoPin07Type can not be an PWM output
535
536 // Arduino pin 8
537 if (ArduinoPin08Type == DigitalInput){ bitWrite( au16data[Register06], Bit0,
not digitalRead(ArduinoPin08)); }
538 else if (ArduinoPin08Type == DigitalOutput) { digitalWrite( ArduinoPin08,
bitRead( au16data[Register06], Bit0 )); }
539 // ArduinoPin08Type can not be an analog input
540 // ArduinoPin08Type can not be an PWM output
541
542 // Arduino pin 9
543 if (ArduinoPin09Type == DigitalInput){ bitWrite( au16data[Register07], Bit0,
not digitalRead(ArduinoPin09)); }
544 else if (ArduinoPin09Type == DigitalOutput) { digitalWrite( ArduinoPin09,
bitRead( au16data[Register07], Bit0 )); }
545 // ArduinoPin09Type can not be an analog input
546 else if (ArduinoPin09Type == PWMOutput) { analogWrite( ArduinoPin09,
au16data[Register07] ); }
547
548 // Arduino pin 10
549 if (ArduinoPin10Type == DigitalInput){ bitWrite( au16data[Register08], Bit0,
not digitalRead(ArduinoPin10)); }
550 else if (ArduinoPin10Type == DigitalOutput) { digitalWrite( ArduinoPin10,
bitRead( au16data[Register08], Bit0 )); }
551 // ArduinoPin10Type can not be an analog input
552 else if (ArduinoPin10Type == PWMOutput) { analogWrite( ArduinoPin10,
au16data[Register08] ); }
553
554 // Arduino pin 11
555 if (ArduinoPin11Type == DigitalInput){ bitWrite( au16data[Register09], Bit0,
not digitalRead(ArduinoPin11)); }
556 else if (ArduinoPin11Type == DigitalOutput) { digitalWrite( ArduinoPin11,
bitRead( au16data[Register09], Bit0 )); }
557 // ArduinoPin11Type can not be an analog input
558 else if (ArduinoPin11Type == PWMOutput) { analogWrite( ArduinoPin11,
au16data[Register09] ); }
559
560 // Arduino pin 12
561 if (ArduinoPin12Type == DigitalInput){ bitWrite( au16data[Register10], Bit0,
not digitalRead(ArduinoPin12)); }
562 else if (ArduinoPin12Type == DigitalOutput) { digitalWrite( ArduinoPin12,
bitRead( au16data[Register10], Bit0 )); }
563 // ArduinoPin12Type can not be an analog input
564 // ArduinoPin12Type can not be an PWM output
565
566 // Arduino pin 13
567 if (ArduinoPin13Type == DigitalInput){ bitWrite( au16data[Register11], Bit0,
not digitalRead(ArduinoPin13)); }
568 else if (ArduinoPin13Type == DigitalOutput) { digitalWrite( ArduinoPin13,
bitRead( au16data[Register11], Bit0 )); }
569 // ArduinoPin13Type can not be an analog input
570 // ArduinoPin13Type can not be an PWM output
571
572 // On the analog inputs the sensor values must be maped to usable values for PWM
outputs (eg. 0 to 255)
573 // Arduino pin A0
574 if (ArduinoPinA0Type == DigitalInput){ bitWrite( au16data[Register12], Bit0,
not digitalRead(ArduinoPinA0)); }
575 else if (ArduinoPinA0Type == DigitalOutput) { digitalWrite( ArduinoPinA0,
bitRead( au16data[Register12], Bit0 )); }
576 else if (ArduinoPinA0Type == AnalogInput) { SensorValueA0 =
analogRead(ArduinoPinA0); MappedSensorValueA0 = map(SensorValueA0, 0, 1023, 0,
255); au16data[Register12] = MappedSensorValueA0; }
577 // ArduinoPinA0Type can not be an PWM output
578
579 // Arduino pin A1
580 if (ArduinoPinA1Type == DigitalInput){ bitWrite( au16data[Register13], Bit0,
not digitalRead(ArduinoPinA1)); }
581 else if (ArduinoPinA1Type == DigitalOutput) { digitalWrite( ArduinoPinA1,
bitRead( au16data[Register13], Bit0 )); }
582 else if (ArduinoPinA1Type == AnalogInput) { SensorValueA1 =
analogRead(ArduinoPinA1); MappedSensorValueA1 = map(SensorValueA1, 0, 1023, 0,
255); au16data[Register13] = MappedSensorValueA1; }
583 // ArduinoPinA1Type can not be an PWM output
584
585 // Arduino pin A2
586 if (ArduinoPinA2Type == DigitalInput){ bitWrite( au16data[Register14], Bit0,
not digitalRead(ArduinoPinA2)); }
587 else if (ArduinoPinA2Type == DigitalOutput) { digitalWrite( ArduinoPinA2,
bitRead( au16data[Register14], Bit0 )); }
588 else if (ArduinoPinA2Type == AnalogInput) { SensorValueA2 =
analogRead(ArduinoPinA2); MappedSensorValueA2 = map(SensorValueA2, 0, 1023, 0,
255); au16data[Register14] = MappedSensorValueA2; }
589 // ArduinoPinA2Type can not be an PWM output
590
591 // Arduino pin A3
592 if (ArduinoPinA3Type == DigitalInput){ bitWrite( au16data[Register15], Bit0,
not digitalRead(ArduinoPinA3)); }
593 else if (ArduinoPinA3Type == DigitalOutput) { digitalWrite( ArduinoPinA3,
bitRead( au16data[Register15], Bit0 )); }
594 else if (ArduinoPinA3Type == AnalogInput) { SensorValueA3 =
analogRead(ArduinoPinA3); MappedSensorValueA3 = map(SensorValueA3, 0, 1023, 0,
255); au16data[Register15] = MappedSensorValueA3; }
595 // ArduinoPinA3Type can not be an PWM output
596
597 // Arduino pin A4
598 if (ArduinoPinA4Type == DigitalInput){ bitWrite( au16data[Register16], Bit0,
not digitalRead(ArduinoPinA4)); }
599 else if (ArduinoPinA4Type == DigitalOutput) { digitalWrite( ArduinoPinA4,
bitRead( au16data[Register16], Bit0 )); }
600 else if (ArduinoPinA4Type == AnalogInput) { SensorValueA4 =
analogRead(ArduinoPinA4); MappedSensorValueA4 = map(SensorValueA4, 0, 1023, 0,
255); au16data[Register16] = MappedSensorValueA4; }
601 // ArduinoPinA4Type can not be an PWM output
602
603 // Arduino pin A5
604 if (ArduinoPinA5Type == DigitalInput){ bitWrite( au16data[Register17], Bit0,
not digitalRead(ArduinoPinA5)); }
605 else if (ArduinoPinA5Type == DigitalOutput) { digitalWrite( ArduinoPinA5,
bitRead( au16data[Register17], Bit0 )); }
606 else if (ArduinoPinA5Type == AnalogInput) { SensorValueA5 =
analogRead(ArduinoPinA5); MappedSensorValueA5 = map(SensorValueA5, 0, 1023, 0,
255); au16data[Register17] = MappedSensorValueA5; }
607 // ArduinoPinA5Type can not be an PWM output
608
609
610 // Liquid Cristal Display
611 // The 16 bits in the registers are only big enough to store Binary:
1111111111111111 or Decimal: 65535 max
612 // The numbers in the Mach3 DRO's consists of intergers and decimals (eg:
9999.6666)
613 // To solve this we use two registers for each axis DRO.
614 // One register for everything to the left of the decimal point (the interger
9999)
615 // One register for everything to the right of the decimal point (the decimal
6666)
616
617 // Use a brain in Mach3 to split the DRO position of each axis into two
portions
618 // DRO --> Formula --> Modbus Register
619 // Formula1 = int(A) // This is the interger
(left part)
620 // Formula2 = (A * 10000) - (int(A) * 10000) // This is the decimal
(right part)
621 // Use arduino to combine the values again
622
623 if (LCDAvailable == true) {
624 lcd.noBlink(); // Set the cursor not to
blink
625 lcd.noCursor(); // Remove the cursor
626
627 // LCD X position
628 lcd.setCursor(0, 0); // (Colum, Line)
629 lcd.print("X:");
630
631 // Interger position X
632
633 int IntergerXpos = au16data[Register18];
634
635 if (IntergerXpos >= 0 and IntergerXpos <= 9 ) {lcd.print(" +");}
636 if (IntergerXpos >= 10 and IntergerXpos <= 99 ) {lcd.print(" +")
;}
637 if (IntergerXpos >= 100 and IntergerXpos <= 999 ) {lcd.print(" +") ;}
638 if (IntergerXpos >= 1000 and IntergerXpos <= 9999 ){lcd.print("+")
;}
639
640 if (IntergerXpos <= -1 and IntergerXpos >= -9 ) {lcd.print(" ") ;}
641 if (IntergerXpos <= -10 and IntergerXpos >= -99 ) {lcd.print(" ")
;}
642 if (IntergerXpos <= -100 and IntergerXpos >= -999 ){lcd.print(" ")
;}
643
644 lcd.print(IntergerXpos);
645
646
647 // Decimal Point X
648 lcd.print(".");
649
650 // Decimal position X
651
652 int DecimalXpos = au16data[Register19];
653
654 if (DecimalXpos < 0 and IntergerXpos == 0 ) {lcd.setCursor(2, 0);
lcd.print(" -");}
655
656 lcd.setCursor(8, 0);
657
658 if (DecimalXpos < 0) {DecimalXpos = DecimalXpos * -1 ;}
659 if (DecimalXpos >= 0 and DecimalXpos <= 9 ) {lcd.print("000");}
660 if (DecimalXpos >= 10 and DecimalXpos <= 99 ) {lcd.print("00") ;}
661 if (DecimalXpos >= 100 and DecimalXpos <= 999 ){lcd.print("0") ;}
662
663 lcd.print(DecimalXpos);
664 lcd.print(" ");
665
666
667 // LCD Y position
668 lcd.setCursor(0, 1); // (Colum, Line)
669 lcd.print("Y:");
670
671 // Interger position Y
672
673 int IntergerYpos = au16data[Register20];
674
675 if (IntergerYpos >= 0 and IntergerYpos <= 9 ) {lcd.print(" +");}
676 if (IntergerYpos >= 10 and IntergerYpos <= 99 ) {lcd.print(" +")
;}
677 if (IntergerYpos >= 100 and IntergerYpos <= 999 ) {lcd.print(" +") ;}
678 if (IntergerYpos >= 1000 and IntergerYpos <= 9999 ){lcd.print("+") ;}
679
680 if (IntergerYpos <= -1 and IntergerYpos >= -9 ) {lcd.print(" ") ;}
681 if (IntergerYpos <= -10 and IntergerYpos >= -99 ) {lcd.print(" ")
;}
682 if (IntergerYpos <= -100 and IntergerYpos >= -999 ){lcd.print(" ")
;}
683
684 lcd.print(IntergerYpos);
685
686 // Decimal Point Y
687 lcd.print(".");
688
689 // Decimal position Y
690 int DecimalYpos = au16data[Register21];
691
692 if (DecimalYpos < 0 and IntergerYpos == 0 ) {lcd.setCursor(2, 1);
lcd.print(" -");}
693
694 lcd.setCursor(8, 1);
695
696 if (DecimalYpos < 0) {DecimalYpos = DecimalYpos * -1 ;}
697 if (DecimalYpos >= 0 and DecimalYpos <= 9 ) {lcd.print("000");}
698 if (DecimalYpos >= 10 and DecimalYpos <= 99 ) {lcd.print("00") ;}
699 if (DecimalYpos >= 100 and DecimalYpos <= 999 ){lcd.print("0") ;}
700
701 lcd.print(DecimalYpos);
702 lcd.print(" ");
703
704
705 // LCD Z position
706 lcd.setCursor(0, 2); // (Colum, Line)
707 lcd.print("Z:");
708
709 // Interger position Z
710 int IntergerZpos = au16data[Register22];
711
712 if (IntergerZpos >= 0 and IntergerZpos <= 9 ) {lcd.print(" +");}
713 if (IntergerZpos >= 10 and IntergerZpos <= 99 ) {lcd.print(" +")
;}
714 if (IntergerZpos >= 100 and IntergerZpos <= 999 ) {lcd.print(" +") ;}
715 if (IntergerZpos >= 1000 and IntergerZpos <= 9999 ){lcd.print("+") ;}
716
717 if (IntergerZpos <= -1 and IntergerZpos >= -9 ) {lcd.print(" ") ;}
718 if (IntergerZpos <= -10 and IntergerZpos >= -99 ) {lcd.print(" ")
;}
719 if (IntergerZpos <= -100 and IntergerZpos >= -999 ){lcd.print(" ")
;}
720
721 lcd.print(IntergerZpos);
722
723 // Decimal Point Z
724 lcd.print(".");
725
726 // Decimal position Z
727 int DecimalZpos = au16data[Register23];
728
729 if (DecimalZpos < 0 and IntergerZpos == 0 ) {lcd.setCursor(2, 2);
lcd.print(" -");}
730
731 lcd.setCursor(8, 2);
732
733 if (DecimalZpos < 0) {DecimalZpos = DecimalZpos * -1 ;}
734 if (DecimalZpos >= 0 and DecimalZpos <= 9 ) {lcd.print("000");}
735 if (DecimalZpos >= 10 and DecimalZpos <= 99 ) {lcd.print("00") ;}
736 if (DecimalZpos >= 100 and DecimalZpos <= 999 ){lcd.print("0") ;}
737 lcd.print(DecimalZpos);
738 lcd.print(" ");
739
740
741
742 } // End of if(LCDAvailable == true) {
743
744
745
746 // Manual Pulse Generator 1: Register24
747 if (ArduinoPin02Type == MPGInput and ArduinoPin03Type == MPGInput) {
748 int MPG1newPosition = MPG1.read();
749
750 if (MPG1newPosition != MPG1oldPosition) {
751 MPG1oldPosition = MPG1newPosition;
752 int MPG1displayedPosition = MPG1newPosition/-4;
753 au16data[Register24] = MPG1displayedPosition;
754 } // End of if
755
756 } // End of if
757
758 /*
759 // Manual Pulse Generator 2: Register25
760 if (ArduinoPin04Type == MPGInput and ArduinoPin05Type == MPGInput) {
761 int MPG2newPosition = MPG2.read();
762
763 if (MPG2newPosition != MPG2oldPosition) {
764 MPG2oldPosition = MPG2newPosition;
765 int MPG2displayedPosition = MPG2newPosition/-4;
766 au16data[Register25] = MPG2displayedPosition;
767 } // End of if
768
769 } // End of if
770 */
771
772
773 /*
774 // Manual Pulse Generator 3: Register26
775 if (ArduinoPin06Type == MPGInput and ArduinoPin07Type == MPGInput) {
776 int MPG3newPosition = MPG3.read();
777
778 if (MPG3newPosition != MPG3oldPosition) {
779 MPG3oldPosition = MPG3newPosition;
780 int MPG3displayedPosition = MPG3newPosition/-4;
781 au16data[Register26] = MPG3displayedPosition;
782 } // End of if
783
784 } // End of if
785 */
786
787 /*
788 // Diagnose communication
789 au16data[Register27] = slave.getInCnt(); // Not used
now
790 au16data[Register28] = slave.getOutCnt(); // Not used
now
791 au16data[Register29] = slave.getErrCnt(); // Not used
now
792 */
793
794
795 // Print all of the register values to the serial monitor
796
797 Serial.begin(19200); // To make Serial Monitor work
798
799 Serial.print("0:"); Serial.print(au16data[Register00]); Serial.print(" ");
800 Serial.print("1:"); Serial.print(au16data[Register01]); Serial.print(" ");
801 Serial.print("2:"); Serial.print(au16data[Register02]); Serial.print(" ");
802 Serial.print("3:"); Serial.print(au16data[Register03]); Serial.print(" ");
803 Serial.print("4:"); Serial.print(au16data[Register04]); Serial.print(" ");
804 Serial.print("5:"); Serial.print(au16data[Register05]); Serial.print(" ");
805 Serial.print("6:"); Serial.print(au16data[Register06]); Serial.print(" ");
806 Serial.print("7:"); Serial.print(au16data[Register07]); Serial.print(" ");
807 Serial.print("8:"); Serial.print(au16data[Register08]); Serial.print(" ");
808 Serial.print("9:"); Serial.print(au16data[Register09]); Serial.print(" ");
809 Serial.print("10:"); Serial.print(au16data[Register10]); Serial.print(" ");
810 Serial.print("11:"); Serial.print(au16data[Register11]); Serial.print(" ");
811 Serial.print("12:"); Serial.print(au16data[Register12]); Serial.print(" ");
812 Serial.print("13:"); Serial.print(au16data[Register13]); Serial.print(" ");
813 Serial.print("14:"); Serial.print(au16data[Register14]); Serial.print("
");
814 Serial.print("15:"); Serial.print(au16data[Register15]); Serial.print(" ");
815 Serial.print("16:"); Serial.print(au16data[Register16]); Serial.print(" ");
816 Serial.print("17:"); Serial.print(au16data[Register17]); Serial.print(" ");
817 Serial.print("18:"); Serial.print(au16data[Register18]); Serial.print(" ");
818 Serial.print("19:"); Serial.print(au16data[Register19]); Serial.print(" ");
819 Serial.print("20:"); Serial.print(au16data[Register20]); Serial.print(" ");
820 Serial.print("21:"); Serial.print(au16data[Register21]); Serial.print(" ");
821 Serial.print("22:"); Serial.print(au16data[Register22]); Serial.print(" ");
822 Serial.print("23:"); Serial.print(au16data[Register23]); Serial.print(" ");
823 Serial.print("24:"); Serial.print(au16data[Register24]); Serial.print(" ");
824 Serial.print("25:"); Serial.print(au16data[Register25]); Serial.print(" ");
825 Serial.print("26:"); Serial.print(au16data[Register26]); Serial.print(" ");
826 // Serial.print("27:"); Serial.print(au16data[Register27]); Serial.print(" ");
827 // Serial.print("28:"); Serial.print(au16data[Register28]); Serial.print(" ");
828 // Serial.print("29:"); Serial.print(au16data[Register29]); Serial.print(" ");
829
830 Serial.println();
831
832
833 } // End of void loop
834
835
836 // End of program
837

You might also like