First version of my PPM library.

Dependents:   PPM_Test QuadCopter Quadcopter_mk2

Have a look at PPM_Test to see how this library is used.

Import programPPM_Test

Test program for my PPM library.

Committer:
joe4465
Date:
Wed Mar 04 18:49:31 2015 +0000
Revision:
2:b67f18c84c05
Child:
3:d13b9e50312f
Modified library so that the InterruptIn pin is passed into constructor instead of the InterruptIn object

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joe4465 2:b67f18c84c05 1 #include "mbed.h"
joe4465 2:b67f18c84c05 2
joe4465 2:b67f18c84c05 3 #ifndef Ppm_H
joe4465 2:b67f18c84c05 4 #define Ppm_H
joe4465 2:b67f18c84c05 5
joe4465 2:b67f18c84c05 6 class Ppm
joe4465 2:b67f18c84c05 7 {
joe4465 2:b67f18c84c05 8 public:
joe4465 2:b67f18c84c05 9 //Constructor
joe4465 2:b67f18c84c05 10 Ppm(PinName pin, float minimumOutput, float maximumOutput, int minimumPulseTime, int maximumPulseTime, int numberOfChannels, int throttleChannel);
joe4465 2:b67f18c84c05 11
joe4465 2:b67f18c84c05 12 private:
joe4465 2:b67f18c84c05 13 //Interrupt
joe4465 2:b67f18c84c05 14 void SignalRise();
joe4465 2:b67f18c84c05 15
joe4465 2:b67f18c84c05 16 //Interrupt pin
joe4465 2:b67f18c84c05 17 InterruptIn *_ppmPin;
joe4465 2:b67f18c84c05 18
joe4465 2:b67f18c84c05 19 //Timer, times length of pulses
joe4465 2:b67f18c84c05 20 Timer _timer;
joe4465 2:b67f18c84c05 21 //Number of channels in Ppm signal
joe4465 2:b67f18c84c05 22 int _numberOfChannels;
joe4465 2:b67f18c84c05 23 //Current channel
joe4465 2:b67f18c84c05 24 char _currentChannel;
joe4465 2:b67f18c84c05 25 //Stores channel times
joe4465 2:b67f18c84c05 26 int _times[100];
joe4465 2:b67f18c84c05 27 //Stores most recent complete frame times
joe4465 2:b67f18c84c05 28 int _completeTimes[100];
joe4465 2:b67f18c84c05 29 //Keeps track of time between Ppm interrupts
joe4465 2:b67f18c84c05 30 int _timeElapsed;
joe4465 2:b67f18c84c05 31 //Minimum time of frame
joe4465 2:b67f18c84c05 32 int _minFrameTime;
joe4465 2:b67f18c84c05 33 //If the pulse time for a channel is this short, something is wrong uS
joe4465 2:b67f18c84c05 34 int _shortTime;
joe4465 2:b67f18c84c05 35 //Minimum pulse time uS
joe4465 2:b67f18c84c05 36 int _minimumPulseTime;
joe4465 2:b67f18c84c05 37 //Maximum pulse time uS
joe4465 2:b67f18c84c05 38 int _maximumPulseTime;
joe4465 2:b67f18c84c05 39 //Minimum output
joe4465 2:b67f18c84c05 40 float _minimumOutput;
joe4465 2:b67f18c84c05 41 //Maximum output
joe4465 2:b67f18c84c05 42 float _maximumOutput;
joe4465 2:b67f18c84c05 43 //Throttle channel - used for fail safe
joe4465 2:b67f18c84c05 44 int _throttleChannel;
joe4465 2:b67f18c84c05 45
joe4465 2:b67f18c84c05 46 public:
joe4465 2:b67f18c84c05 47 //Get channel data
joe4465 2:b67f18c84c05 48 void GetChannelData(float * channelData);
joe4465 2:b67f18c84c05 49
joe4465 2:b67f18c84c05 50 private:
joe4465 2:b67f18c84c05 51 float Map(float input, float inputMin, float inputMax, float outputMin, float outputMax);
joe4465 2:b67f18c84c05 52 };
joe4465 2:b67f18c84c05 53
joe4465 2:b67f18c84c05 54 #endif
joe4465 2:b67f18c84c05 55
joe4465 2:b67f18c84c05 56