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.

Ppm.h

Committer:
joe4465
Date:
2015-03-04
Revision:
2:b67f18c84c05
Child:
3:d13b9e50312f

File content as of revision 2:b67f18c84c05:

#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