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.
Diff: Ppm.h
- Revision:
- 2:b67f18c84c05
- Child:
- 3:d13b9e50312f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Ppm.h Wed Mar 04 18:49:31 2015 +0000 @@ -0,0 +1,56 @@ +#include "mbed.h" + +#ifndef Ppm_H +#define Ppm_H + +class Ppm +{ + public: + //Constructor + Ppm(PinName pin, float minimumOutput, float maximumOutput, int minimumPulseTime, int maximumPulseTime, int numberOfChannels, int throttleChannel); + + private: + //Interrupt + void SignalRise(); + + //Interrupt pin + InterruptIn *_ppmPin; + + //Timer, times length of pulses + Timer _timer; + //Number of channels in Ppm signal + int _numberOfChannels; + //Current channel + char _currentChannel; + //Stores channel times + int _times[100]; + //Stores most recent complete frame times + int _completeTimes[100]; + //Keeps track of time between Ppm interrupts + int _timeElapsed; + //Minimum time of frame + int _minFrameTime; + //If the pulse time for a channel is this short, something is wrong uS + int _shortTime; + //Minimum pulse time uS + int _minimumPulseTime; + //Maximum pulse time uS + int _maximumPulseTime; + //Minimum output + float _minimumOutput; + //Maximum output + float _maximumOutput; + //Throttle channel - used for fail safe + int _throttleChannel; + + public: + //Get channel data + void GetChannelData(float * channelData); + + private: + float Map(float input, float inputMin, float inputMax, float outputMin, float outputMax); +}; + +#endif + +