/elec/quadcopter

To get this branch, use:
bzr branch http://bzr.ed.am/elec/quadcopter

« back to all changes in this revision

Viewing changes to test/receiver/pulse-width-x8/main.ino

  • Committer: Tim Marston
  • Date: 2013-11-20 23:59:59 UTC
  • Revision ID: tim@ed.am-20131120235959-hh2y1ickvxf2z0lt
added pulse-width reading test program that reads all 8 channels

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
// available, reading the analogue outputs is certainly more portable.  So, we
12
12
// are multiplexing the separate channels to two streams of pulses, like this:
13
13
//
14
 
//                  ch1  ch3  ch5  ch7  ch2  ch4  ch6  ch8
15
 
//                   |    |    |    |    |    |    |    |
16
 
//                   ▼    ▼    ▼    ▼    ▼    ▼    ▼    ▼
17
 
//                   ¯    ¯    ¯    ¯    ¯    ¯    ¯    ¯
18
 
//            ___    |    |    |    |    |    |    |    |     ___
19
 
//    GND ---|___|---+----+----+----+    +----+----+----+----|___|--- GND
20
 
//             R                    |    |                     R
21
 
//             ____________________ | __ | _____________________
22
 
//                                  |    |
23
 
//                           pin 2  o    o  pin 3
24
 
//                    (interrupt 0)        (interrupt 1)
25
 
//
26
 
// The two resistors in the circuit are pull-down resistors (so, say 100kΩ).
27
 
// Without them, the Arduino is unable to read the pulse wave at all.
 
14
//     ch.1  ch.3  ch.5  ch.7  ch.2  ch.4  ch.6  ch.8
 
15
//       |     |     |     |     |     |     |     |
 
16
//       ▼     ▼     ▼     ▼     ▼     ▼     ▼     ▼
 
17
//       ¯     ¯     ¯     ¯     ¯     ¯     ¯     ¯
 
18
//       |     |     |     |     |     |     |     |
 
19
//       '-----+-----+-----+     +-----+-----+-----'
 
20
//                         |     |
 
21
//    ____________________ | ___ | _____________________
 
22
//                         |     |
 
23
//         (int. 0) pin 2  o     o  pin 3 (int. 1)
28
24
//
29
25
// (Note that on our receiver, and contrary to the above diagram, the channels
30
26
// are not actually sent in order.  Channels 2 and 3 are reversed.  To this end,
111
107
}
112
108
 
113
109
 
 
110
static int count_ = 0, good_ = 0;
 
111
 
 
112
 
114
113
bool read_channels( unsigned long channel_values[] )
115
114
{
116
115
        static unsigned long last_pulse_down = 0;