/elec/quadcopter

To get this branch, use:
bzr branch http://bzr.ed.am/elec/quadcopter
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
//
// main.ino
//
// This software is intended to be run on a small Arduino (e.g., a Pro Mini),
// whose purpose is dedicated to talking to the RC system.  That is to say, it
// listens to the PPM signal from the RC receiver and produces a compatible
// single for the ESCs to control the motors.  It additionally talks to the main
// board via a trivial serial protocol.  In so doing, this software relieves the
// main board (and software running on it) of the task of interfacing with any
// of the RC system.
//
// Receiver
// --------
//
// The 8 channels (from the RC receiver) need to be combined and fed to two
// interrupts on the Arduino.  They need to be combined in such a way as to
// alternate pulses between the two interrupts (which are alternately used to
// read the pulses).  Like this:
//
//                  ch1  ch3  ch5  ch7  ch2  ch4  ch6  ch8
//                   |    |    |    |    |    |    |    |
//                   ▼    ▼    ▼    ▼    ▼    ▼    ▼    ▼
//                   ¯    ¯    ¯    ¯    ¯    ¯    ¯    ¯
//            ___    |    |    |    |    |    |    |    |     ___
//    GND ---|___|---+----+----+----+    +----+----+----+----|___|--- GND
//             R                    |    |                     R
//             ____________________ | __ | _____________________
//                                  |    |
//                           pin 2  o    o  pin 3
//                    (interrupt 0)        (interrupt 1)
//
// The two resistors in the circuit are pull-down resistors (so, say 100kΩ).
// Without them, the Arduino is unable to read the pulse wave at all.
//
// Note that your receiver may not send pulses sequentially, in "channel order".
// If this turns out to be the case, you will need to arrange for the pulses to
// wire up the channels in an order whereby the pulses alternatively alternately
// between the two interrupts and adjust the channel order below.
//
// Motor control
// -------------
//
// 


#include "config.h"
#include "receiver.h"
#include "motors.h"
#include "testing.h"


void setup()
{
	Receiver::setup();
	Motors::setup();

	Testing::setup();
}


void loop()
{
	unsigned long channel_values[ NUM_CHANNELS ];

	while( true )
	{
		if( Receiver::read_channels( channel_values ) )
		{
			Testing::draw_receiver_channels( channel_values );
		}
//		Motors::update_channels( channel_values );
	}
}