forked from goebish/nrf24_multipro
/
nRF24_multipro.ino
611 lines (556 loc) · 18.8 KB
/
nRF24_multipro.ino
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
/*
##########################################
##### MultiProtocol nRF24L01 Tx ######
##########################################
# by goebish on rcgroups #
# #
# Parts of this project are derived #
# from existing work, thanks to: #
# #
# - PhracturedBlue for DeviationTX #
# - victzh for XN297 emulation layer #
# - Hasi for Arduino PPM decoder #
# - hexfet, midelic, closedsink ... #
##########################################
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License.
If not, see <http://www.gnu.org/licenses/>.
*/
#define DEBUG 1
#if defined(ARDUINO_GENERIC_STM32F103C)
#else
#include <util/atomic.h>
#endif
#include <EEPROM.h>
#include "iface_nrf24l01.h"
#if defined(u8)
#else
#define u8 uint8_t
#define u16 uint16_t
#define u32 uint32_t
#endif
// ############ Wiring ################
#if defined(ARDUINO_AVR_PROMICRO)
#define Serial SerialUSB
#define HAS_SERIAL1 1
// ppm
#define PPM_pin 2 // PPM in
//SPI Comm.pins with nRF24L01
#define MOSI_pin 3 // MOSI - PD0
#define SCK_pin 4 // SCK - PD4
#define CE_pin 5 // CE - PC6
#define MISO_pin A0 // MISO - PF7
#define CS_pin A1 // CS - PF6
#define ledPin LED_BUILTIN_TX // LED - 30
// SPI outputs
#define MOSI_on PORTD |= _BV(0) // PD0
#define MOSI_off PORTD &= ~_BV(0)// PD0
#define SCK_on PORTD |= _BV(4) // PD4
#define SCK_off PORTD &= ~_BV(4) // PD4
#define CE_on PORTC |= _BV(6) // PC6
#define CE_off PORTC &= ~_BV(6) // PC6
#define CS_on PORTF |= _BV(6) // PF6
#define CS_off PORTF &= ~_BV(6) // PF6
// SPI input
#define MISO_on (PINF & _BV(0)) // PF7
// LED
#define LED_off digitalWrite(ledPin, LOW)
#define LED_on digitalWrite(ledPin, HIGH)
#elif defined(ARDUINO_GENERIC_STM32F103C)
// #elif defined(ARDUINO_MAPLE_MINI)
// USBSerial Serial;
#define random rand
HardwareTimer timer(1);
#define HAS_SERIAL1 1
// ppm
#define PPM_pin PA0 // PPM in, PA0
//SPI Comm.pins with nRF24L01
#define MOSI_pin PA1 // MOSI - PA1
#define SCK_pin PA2 // SCK - PA2
#define CE_pin PA3 // CE - PA3
#define MISO_pin PA4 // MISO - PA4
#define CS_pin PA5 // CS - PA5
#define ledPin LED_BUILTIN // LED - 30
// SPI outputs
#define MOSI_on digitalWrite(MOSI_pin,HIGH)
#define MOSI_off digitalWrite(MOSI_pin,LOW)
#define SCK_on digitalWrite(SCK_pin,HIGH)
#define SCK_off digitalWrite(SCK_pin,LOW)
#define CE_on digitalWrite(CE_pin,HIGH)
#define CE_off digitalWrite(CE_pin,LOW)
#define CS_on digitalWrite(CS_pin,HIGH)
#define CS_off digitalWrite(CS_pin,LOW)
// SPI input
#define MISO_on digitalRead(MISO_pin)
// LED
#define LED_off digitalWrite(ledPin, HIGH)
#define LED_on digitalWrite(ledPin, LOW)
#else
#define PPM_pin 2 // PPM in
//SPI Comm.pins with nRF24L01
#define MOSI_pin 3 // MOSI - D3
#define SCK_pin 4 // SCK - D4
#define CE_pin 5 // CE - D5
#define MISO_pin A0 // MISO - A0
#define CS_pin A1 // CS - A1
#define ledPin 13 // LED - D13
// SPI outputs
#define MOSI_on PORTD |= _BV(3) // PD3
#define MOSI_off PORTD &= ~_BV(3)// PD3
#define SCK_on PORTD |= _BV(4) // PD4
#define SCK_off PORTD &= ~_BV(4) // PD4
#define CE_on PORTD |= _BV(5) // PD5
#define CE_off PORTD &= ~_BV(5) // PD5
#define CS_on PORTC |= _BV(1) // PC1
#define CS_off PORTC &= ~_BV(1) // PC1
// SPI input
#define MISO_on (PINC & _BV(0)) // PC0
// LED
#define LED_off digitalWrite(ledPin, LOW)
#define LED_on digitalWrite(ledPin, HIGH)
#endif
#define RF_POWER TX_POWER_80mW
// tune ppm input for "special" transmitters
// #define SPEKTRUM // TAER, 1100-1900, AIL & RUD reversed
// PPM stream settings
#define CHANNELS 10 // number of channels in ppm stream, 12 ideally
enum chan_order{
AILERON,
ELEVATOR,
THROTTLE,
RUDDER,
AUX1, // (CH5) led light, or 3 pos. rate on CX-10, H7, or inverted flight on H101
AUX2, // (CH6) flip control
AUX3, // (CH7) still camera (snapshot)
AUX4, // (CH8) video camera
AUX5, // (CH9) headless
AUX6, // (CH10) calibrate Y (V2x2), pitch trim (H7), RTH (Bayang, H20), 360deg flip mode (H8-3D, H22)
AUX7, // (CH11) calibrate X (V2x2), roll trim (H7)
AUX8, // (CH12) Reset / Rebind
};
#define PPM_MIN 1000
#define PPM_SAFE_THROTTLE 1250
#define PPM_MID 1500
#define PPM_MAX 2000
#define PPM_MIN_COMMAND 1300
#define PPM_MAX_COMMAND 1700
#define GET_FLAG(ch, mask) (ppm[ch] > PPM_MAX_COMMAND ? mask : 0)
#define GET_FLAG_INV(ch, mask) (ppm[ch] < PPM_MIN_COMMAND ? mask : 0)
// supported protocols
enum {
PROTO_V2X2 = 0, // WLToys V2x2, JXD JD38x, JD39x, JJRC H6C, Yizhan Tarantula X6 ...
PROTO_CG023, // EAchine CG023, CG032, 3D X4
PROTO_CX10_BLUE, // Cheerson CX-10 blue board, newer red board, CX-10A, CX-10C, Floureon FX-10, CX-Stars (todo: add DM007 variant)
PROTO_CX10_GREEN, // Cheerson CX-10 green board
PROTO_H7, // EAchine H7, MoonTop M99xx
PROTO_BAYANG, // EAchine H8(C) mini, H10, BayangToys X6, X7, X9, JJRC JJ850, Floureon H101
PROTO_SYMAX5C1, // Syma X5C-1 (not older X5C), X11, X11C, X12
PROTO_YD829, // YD-829, YD-829C, YD-822 ...
PROTO_H8_3D, // EAchine H8 mini 3D, JJRC H20, H22
PROTO_MJX, // MJX X600 (can be changed to Weilihua WLH08, X800 or H26D)
PROTO_SYMAXOLD, // Syma X5C, X2
PROTO_HISKY, // HiSky RXs, HFP80, HCP80/100, FBL70/80/90/100, FF120, HMX120, WLToys v933/944/955 ...
PROTO_KN, // KN (WLToys variant) V930/931/939/966/977/988
PROTO_YD717, // Cheerson CX-10 red (older version)/CX11/CX205/CX30, JXD389/390/391/393, SH6057/6043/6044/6046/6047, FY326Q7, WLToys v252 Pro/v343, XinXun X28/X30/X33/X39/X40
PROTO_FQ777124, // FQ777-124 pocket drone
PROTO_E010, // EAchine E010, NiHui NH-010, JJRC H36 mini
PROTO_BAYANG_SILVERWARE, // Bayang for Silverware with frsky telemetry
PROTO_END
};
// EEPROM locationss
enum{
ee_PROTOCOL_ID = 0,
ee_TXID0,
ee_TXID1,
ee_TXID2,
ee_TXID3
};
struct {
uint16_t volt1;
uint16_t rssi;
uint8_t updated;
uint32_t lastUpdate;
} telemetry_data;
uint8_t transmitterID[4];
uint8_t current_protocol;
static volatile bool ppm_ok = false;
uint8_t packet[32];
static bool reset=true;
volatile uint16_t Servo_data[12];
static uint16_t ppm[12] = {PPM_MIN,PPM_MIN,PPM_MIN,PPM_MIN,PPM_MID,PPM_MID,
PPM_MID,PPM_MID,PPM_MID,PPM_MID,PPM_MID,PPM_MID,};
void setup()
{
Serial.begin(9600);
Serial.println("Setup");
randomSeed((analogRead(0) & 0x1F) | (analogRead(0) << 5));
pinMode(ledPin, OUTPUT);
LED_off;
pinMode(PPM_pin, INPUT_PULLUP);
pinMode(MOSI_pin, OUTPUT);
pinMode(SCK_pin, OUTPUT);
pinMode(CS_pin, OUTPUT);
pinMode(CE_pin, OUTPUT);
pinMode(MISO_pin, INPUT);
frskyInit();
// PPM ISR setup
#if defined(ARDUINO_GENERIC_STM32F103C)
attachInterrupt(PPM_pin, ISR_ppm, CHANGE);
// set timer1 to increment every 1 us
#if F_CPU == 48000000L
timer.setPrescaleFactor(48);
#elif F_CPU == 72000000L
timer.setPrescaleFactor(72);
#else
#error // F_CPU undefined
#endif
// timer.setOverflow(32768);
timer.refresh();
#else
attachInterrupt(digitalPinToInterrupt(PPM_pin), ISR_ppm, CHANGE);
TCCR1A = 0; //reset timer1
TCCR1B = 0;
TCCR1B |= (1 << CS11); //set timer1 to increment every 1 us @ 8MHz, 0.5 us @16MHz
#endif
set_txid(false);
#ifdef DEBUG
Serial.println("Setup finished");
#endif
}
void loop()
{
uint32_t timeout=0;
// reset / rebind
if(reset || ppm[AUX8] > PPM_MAX_COMMAND) {
reset = false;
selectProtocol();
NRF24L01_Reset();
NRF24L01_Initialize();
init_protocol();
}
telemetry_data.updated = 0;
// process protocol
switch(current_protocol) {
case PROTO_CG023:
case PROTO_YD829:
timeout = process_CG023();
break;
case PROTO_V2X2:
timeout = process_V2x2();
break;
case PROTO_CX10_GREEN:
case PROTO_CX10_BLUE:
timeout = process_CX10();
break;
case PROTO_H7:
timeout = process_H7();
break;
case PROTO_BAYANG:
case PROTO_BAYANG_SILVERWARE:
timeout = process_Bayang();
break;
case PROTO_SYMAX5C1:
case PROTO_SYMAXOLD:
timeout = process_SymaX();
break;
case PROTO_H8_3D:
timeout = process_H8_3D();
break;
case PROTO_MJX:
case PROTO_E010:
timeout = process_MJX();
break;
case PROTO_HISKY:
timeout = process_HiSky();
break;
case PROTO_KN:
timeout = process_KN();
break;
case PROTO_YD717:
timeout = process_YD717();
break;
case PROTO_FQ777124:
timeout = process_FQ777124();
break;
}
// updates ppm values out of ISR
update_ppm();
while(micros() < timeout) {
if(telemetry_data.updated) {
frskyUpdate();
}
}
telemetry_data.updated = 0;
}
void set_txid(bool renew)
{
uint8_t i;
for(i=0; i<4; i++)
transmitterID[i] = EEPROM.read(ee_TXID0+i);
if(renew || (transmitterID[0]==0xFF && transmitterID[1]==0x0FF)) {
for(i=0; i<4; i++) {
#if defined(ARDUINO_GENERIC_STM32F103C)
transmitterID[i] = rand() & 0xFF;
#else
transmitterID[i] = random() & 0xFF;
#endif
EEPROM.update(ee_TXID0+i, transmitterID[i]);
}
}
}
void selectProtocol()
{
#ifdef DEBUG
int i=0;
Serial.println("SelectProtocol");
#endif
// wait for multiple complete ppm frames
ppm_ok = false;
uint8_t count = 10;
while(count) {
while(!ppm_ok) {
#ifdef DEBUG
// for (i=0; i<1000000;i++) {}
print_ppm();
#endif
} // wait
update_ppm();
if(ppm[AUX8] < PPM_MAX_COMMAND) // reset chan released
count--;
ppm_ok = false;
}
#ifdef DEBUG
Serial.println("Final ppm:");
print_ppm();
#endif
// startup stick commands (protocol selection / renew transmitter ID)
if(ppm[RUDDER] < PPM_MIN_COMMAND && ppm[AILERON] < PPM_MIN_COMMAND) // rudder left + aileron left
current_protocol = PROTO_BAYANG_SILVERWARE; // Bayang protocol for Silverware with frsky telemetry
else if(ppm[RUDDER] < PPM_MIN_COMMAND) // Rudder left
set_txid(true); // Renew Transmitter ID
// Rudder right + Aileron right + Elevator down
else if(ppm[RUDDER] > PPM_MAX_COMMAND && ppm[AILERON] > PPM_MAX_COMMAND && ppm[ELEVATOR] < PPM_MIN_COMMAND)
current_protocol = PROTO_E010; // EAchine E010, NiHui NH-010, JJRC H36 mini
// Rudder right + Aileron right + Elevator up
else if(ppm[RUDDER] > PPM_MAX_COMMAND && ppm[AILERON] > PPM_MAX_COMMAND && ppm[ELEVATOR] > PPM_MAX_COMMAND)
current_protocol = PROTO_FQ777124; // FQ-777-124
// Rudder right + Aileron left + Elevator up
else if(ppm[RUDDER] > PPM_MAX_COMMAND && ppm[AILERON] < PPM_MIN_COMMAND && ppm[ELEVATOR] > PPM_MAX_COMMAND)
current_protocol = PROTO_YD717; // Cheerson CX-10 red (older version)/CX11/CX205/CX30, JXD389/390/391/393, SH6057/6043/6044/6046/6047, FY326Q7, WLToys v252 Pro/v343, XinXun X28/X30/X33/X39/X40
// Rudder right + Aileron left + Elevator down
else if(ppm[RUDDER] > PPM_MAX_COMMAND && ppm[AILERON] < PPM_MIN_COMMAND && ppm[ELEVATOR] < PPM_MIN_COMMAND)
current_protocol = PROTO_KN; // KN (WLToys variant) V930/931/939/966/977/988
// Rudder right + Elevator down
else if(ppm[RUDDER] > PPM_MAX_COMMAND && ppm[ELEVATOR] < PPM_MIN_COMMAND)
current_protocol = PROTO_HISKY; // HiSky RXs, HFP80, HCP80/100, FBL70/80/90/100, FF120, HMX120, WLToys v933/944/955 ...
// Rudder right + Elevator up
else if(ppm[RUDDER] > PPM_MAX_COMMAND && ppm[ELEVATOR] > PPM_MAX_COMMAND)
current_protocol = PROTO_SYMAXOLD; // Syma X5C, X2 ...
// Rudder right + Aileron right
else if(ppm[RUDDER] > PPM_MAX_COMMAND && ppm[AILERON] > PPM_MAX_COMMAND)
current_protocol = PROTO_MJX; // MJX X600, other sub protocols can be set in code
// Rudder right + Aileron left
else if(ppm[RUDDER] > PPM_MAX_COMMAND && ppm[AILERON] < PPM_MIN_COMMAND)
current_protocol = PROTO_H8_3D; // H8 mini 3D, H20 ...
// Elevator down + Aileron right
else if(ppm[ELEVATOR] < PPM_MIN_COMMAND && ppm[AILERON] > PPM_MAX_COMMAND)
current_protocol = PROTO_YD829; // YD-829, YD-829C, YD-822 ...
// Elevator down + Aileron left
else if(ppm[ELEVATOR] < PPM_MIN_COMMAND && ppm[AILERON] < PPM_MIN_COMMAND)
current_protocol = PROTO_SYMAX5C1; // Syma X5C-1, X11, X11C, X12
// Elevator up + Aileron right
else if(ppm[ELEVATOR] > PPM_MAX_COMMAND && ppm[AILERON] > PPM_MAX_COMMAND)
current_protocol = PROTO_BAYANG; // EAchine H8(C) mini, BayangToys X6/X7/X9, JJRC JJ850 ...
// Elevator up + Aileron left
else if(ppm[ELEVATOR] > PPM_MAX_COMMAND && ppm[AILERON] < PPM_MIN_COMMAND)
current_protocol = PROTO_H7; // EAchine H7, MT99xx
// Elevator up
else if(ppm[ELEVATOR] > PPM_MAX_COMMAND)
current_protocol = PROTO_V2X2; // WLToys V202/252/272, JXD 385/388, JJRC H6C ...
// Elevator down
else if(ppm[ELEVATOR] < PPM_MIN_COMMAND)
current_protocol = PROTO_CG023; // EAchine CG023/CG031/3D X4, (todo :ATTOP YD-836/YD-836C) ...
// Aileron right
else if(ppm[AILERON] > PPM_MAX_COMMAND)
current_protocol = PROTO_CX10_BLUE; // Cheerson CX10(blue pcb, newer red pcb)/CX10-A/CX11/CX12 ...
// Aileron left
else if(ppm[AILERON] < PPM_MIN_COMMAND)
current_protocol = PROTO_CX10_GREEN; // Cheerson CX10(green pcb)...
// read last used protocol from eeprom
else
current_protocol = constrain(EEPROM.read(ee_PROTOCOL_ID),0,PROTO_END-1);
// update eeprom
EEPROM.update(ee_PROTOCOL_ID, current_protocol);
// wait for safe throttle
while(ppm[THROTTLE] > PPM_SAFE_THROTTLE) {
delay(100);
update_ppm();
}
#ifdef DEBUG
Serial.print("protocol = ");
Serial.println(current_protocol, DEC);
#endif
}
void init_protocol()
{
#ifdef DEBUG
Serial.println("init_protocol");
#endif
switch(current_protocol) {
case PROTO_CG023:
case PROTO_YD829:
CG023_init();
CG023_bind();
break;
case PROTO_V2X2:
V2x2_init();
V2x2_bind();
break;
case PROTO_CX10_GREEN:
case PROTO_CX10_BLUE:
CX10_init();
CX10_bind();
break;
case PROTO_H7:
H7_init();
H7_bind();
break;
case PROTO_BAYANG:
case PROTO_BAYANG_SILVERWARE:
Bayang_init();
Bayang_bind();
break;
case PROTO_SYMAX5C1:
case PROTO_SYMAXOLD:
Symax_init();
break;
case PROTO_H8_3D:
H8_3D_init();
H8_3D_bind();
break;
case PROTO_MJX:
case PROTO_E010:
MJX_init();
MJX_bind();
break;
case PROTO_HISKY:
HiSky_init();
break;
case PROTO_KN:
kn_start_tx(true); // autobind
break;
case PROTO_YD717:
YD717_init();
break;
case PROTO_FQ777124:
FQ777124_init();
FQ777124_bind();
break;
}
}
// update ppm values out of ISR
void update_ppm()
{
#if defined(ARDUINO_GENERIC_STM32F103C)
noInterrupts();
for(uint8_t ch=0; ch<CHANNELS; ch++) {
ppm[ch] = Servo_data[ch];
}
interrupts();
#else
for(uint8_t ch=0; ch<CHANNELS; ch++) {
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
ppm[ch] = Servo_data[ch];
}
}
#endif
#ifdef SPEKTRUM
for(uint8_t ch=0; ch<CHANNELS; ch++) {
if(ch == AILERON || ch == RUDDER) {
ppm[ch] = 3000-ppm[ch];
}
ppm[ch] = constrain(map(ppm[ch],1120,1880,PPM_MIN,PPM_MAX),PPM_MIN,PPM_MAX);
}
#endif
}
#ifdef DEBUG2
static unsigned int pulse;
static unsigned long counterPPM;
static byte chan;
#endif
void ISR_ppm()
{
#if F_CPU == 16000000
#define PPM_SCALE 2
#elif F_CPU == 8000000
#define PPM_SCALE 1
#elif F_CPU == 48000000L
#define PPM_SCALE 1
#elif F_CPU == 72000000L
#define PPM_SCALE 1
#else
#error // 8 or 16MHz or 72MHz only !
#endif
#ifdef DEBUG2
#else
static unsigned int pulse;
static unsigned long counterPPM;
static byte chan;
#endif
#if defined(ARDUINO_GENERIC_STM32F103C)
counterPPM = timer.getCount();
timer.setCount(0);
#else
counterPPM = TCNT1;
TCNT1 = 0;
#endif
ppm_ok=false;
if(counterPPM < (510 * PPM_SCALE)) { //must be a pulse if less than 510us
pulse = counterPPM;
}
else if(counterPPM > (1910 / PPM_SCALE)) { //sync pulses over 1910us
chan = 0;
}
else{ //servo values between 510us and 2420us will end up here
if(chan < CHANNELS) {
// Servo_data[chan]= constrain((counterPPM + pulse) * PPM_SCALE, PPM_MIN, PPM_MAX);
Servo_data[chan]= counterPPM + pulse;
if(chan==3)
ppm_ok = true; // 4 first channels Ok
}
chan++;
}
}
#ifdef DEBUG
void print_ppm() {
int i;
Serial.print("PPM: ");
#ifdef DEBUG2
Serial.print(" pulse: ");
Serial.print(pulse,DEC);
Serial.print("\t");
Serial.print(" counterPPM: ");
Serial.print(counterPPM,DEC);
Serial.print("\t");
Serial.print(" chan: ");
Serial.print(chan,DEC);
Serial.print("\t");
#endif
for (i=0; i<12; i++) {
Serial.print("[");
Serial.print(i,DEC);
Serial.print("]:");
// Serial.print(ppm[i], DEC);
Serial.print(Servo_data[i], DEC);
Serial.print("\t");
}
Serial.println();
}
#endif