/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: dan
  • Date: 2014-04-03 00:24:06 UTC
  • Revision ID: dan-20140403002406-e9qeratw12bsmpuk
Ignore .bck files (kicads "old backup files")

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
 
//     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)
 
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.
24
28
//
25
29
// (Note that on our receiver, and contrary to the above diagram, the channels
26
30
// are not actually sent in order.  Channels 2 and 3 are reversed.  To this end,
107
111
}
108
112
 
109
113
 
110
 
static int count_ = 0, good_ = 0;
111
 
 
112
 
 
113
114
bool read_channels( unsigned long channel_values[] )
114
115
{
115
116
        static unsigned long last_pulse_down = 0;