First version of my PPM library.

Dependents:   PPM_Test QuadCopter Quadcopter_mk2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Ppm.h Source File

Ppm.h

00001 #include "mbed.h"
00002 
00003 #ifndef Ppm_H
00004 #define Ppm_H
00005 
00006 class Ppm
00007 {
00008     public:
00009         //Constructor
00010         Ppm(PinName pin, int minimumOutput, int maximumOutput, int minimumPulseTime, int maximumPulseTime, int numberOfChannels, int throttleChannel);
00011         
00012     private:
00013         //Interrupt
00014         void SignalRise();
00015         
00016         //Interrupt pin
00017         InterruptIn *_ppmPin;
00018         
00019         //Timer, times length of pulses
00020         Timer _timer;
00021         //Number of channels in Ppm signal
00022         int _numberOfChannels;
00023         //Current channel
00024         char _currentChannel;  
00025         //Stores channel times
00026         int _times[100];
00027         //Stores most recent complete frame times
00028         int _completeTimes[100];
00029         //Keeps track of time between Ppm interrupts
00030         int _timeElapsed; 
00031         //Minimum time of frame
00032         int _minFrameTime;
00033         //If the pulse time for a channel is this short, something is wrong uS
00034         int _shortTime;
00035         //Minimum pulse time uS
00036         int _minimumPulseTime;
00037         //Maximum pulse time uS
00038         double _maximumPulseTime;
00039         //Minimum output
00040         double _minimumOutput;
00041         //Maximum output
00042         double _maximumOutput;
00043         //Throttle channel - used for fail safe
00044         int _throttleChannel;
00045         
00046     public:
00047         //Get channel data
00048         void GetChannelData(double* channelData);
00049         
00050     private:
00051         double Map(double input, double inputMin, double inputMax, double outputMin, double outputMax);
00052 };
00053 
00054 #endif
00055 
00056