/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 src/rc-interface/main.ino

  • Committer: Tim Marston
  • Date: 2013-01-16 23:02:32 UTC
  • Revision ID: tim@ed.am-20130116230232-d3od7r9g99n0ra0w
added test programs for all 4 IMU sensors

Show diffs side-by-side

added added

removed removed

1
 
//
2
 
// main.ino
3
 
//
4
 
// This software is intended to be run on a small Arduino (e.g., a Pro Mini),
5
 
// whose purpose is dedicated to talking to the RC system.  That is to say, it
6
 
// listens to the PPM signal from the RC receiver and produces a compatible
7
 
// single for the ESCs to control the motors.  It additionally talks to the main
8
 
// board via a trivial serial protocol.  In so doing, this software relieves the
9
 
// main board (and software running on it) of the task of interfacing with any
10
 
// of the RC system.
11
 
//
12
 
// Receiver
13
 
// --------
14
 
//
15
 
// The 8 channels (from the RC receiver) need to be combined and fed to two
16
 
// interrupts on the Arduino.  They need to be combined in such a way as to
17
 
// alternate pulses between the two interrupts (which are alternately used to
18
 
// read the pulses).  Like this:
19
 
//
20
 
//                  ch1  ch3  ch5  ch7  ch2  ch4  ch6  ch8
21
 
//                   |    |    |    |    |    |    |    |
22
 
//                   ▼    ▼    ▼    ▼    ▼    ▼    ▼    ▼
23
 
//                   ¯    ¯    ¯    ¯    ¯    ¯    ¯    ¯
24
 
//            ___    |    |    |    |    |    |    |    |     ___
25
 
//    GND ---|___|---+----+----+----+    +----+----+----+----|___|--- GND
26
 
//             R                    |    |                     R
27
 
//             ____________________ | __ | _____________________
28
 
//                                  |    |
29
 
//                           pin 2  o    o  pin 3
30
 
//                    (interrupt 0)        (interrupt 1)
31
 
//
32
 
// The two resistors in the circuit are pull-down resistors (so, say 100kΩ).
33
 
// Without them, the Arduino is unable to read the pulse wave at all.
34
 
//
35
 
// Note that your receiver may not send pulses sequentially, in "channel order".
36
 
// If this turns out to be the case, you will need to arrange for the pulses to
37
 
// wire up the channels in an order whereby the pulses alternatively alternately
38
 
// between the two interrupts and adjust the channel order below.
39
 
//
40
 
// Motor control
41
 
// -------------
42
 
//
43
 
// 
44
 
 
45
 
 
46
 
#include "config.h"
47
 
#include "receiver.h"
48
 
#include "motors.h"
49
 
#include "testing.h"
50
 
 
51
 
 
52
 
void setup()
53
 
{
54
 
        Receiver::setup();
55
 
        Motors::setup();
56
 
 
57
 
        Testing::setup();
58
 
}
59
 
 
60
 
 
61
 
void loop()
62
 
{
63
 
        unsigned long channel_values[ NUM_CHANNELS ];
64
 
 
65
 
        while( true )
66
 
        {
67
 
                if( Receiver::read_channels( channel_values ) )
68
 
                {
69
 
                        Testing::draw_receiver_channels( channel_values );
70
 
                }
71
 
//              Motors::update_channels( channel_values );
72
 
        }
73
 
}