Skip to content

This Arduino code reads a PPM signal and puts the servo values into an array (called ppm), reagrdless of channel number, polarity, ppm frame length, etc...

License

Notifications You must be signed in to change notification settings

DzikuVx/PPMReader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PPM Reader

This library reads and decodes PPM (CPPM) RC signal from a radio receiver.

  • Processing is loop independent
  • Allows to use delay in loop
  • Does not conflicts with Servo library, that means you can not only passthrough decoded channels to servos, but also to process it in an easy way. For example to write a mixer

Limitations

  • Requires a pin with hardware interrupt avaliable. That mean, on majority of Arduino boards, it will be limitet to either Pin2/Interrupt0 or Pin3/Interrupt1
  • It uses micros, so any code that alters Timer0 and breaks micros function, will also break this code

Installation

  1. Download from GitHub as ZIP
  2. Using Arduino IDE use Sketch -> Include Library -> Add .ZIP Library and select downloaded ZIP

Usage

On Arduino UNO/Pro Mini with PPM signal attached to pin 2 (interrupt 0), example usage that prints PPM channel 1 over serial port will look like this:

#include "PPMReader.h"

// PPMReader(pin, interrupt)
PPMReader ppmReader(2, 0, false);

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  static int count;
  while (ppmReader.get(count) != 0) { //print out the servo values
      Serial.print(ppmReader.get(count));
      Serial.print("  ");
      count++;
  }
  count = 0;
  delay(500);
}

Timer1 mode

When PPMReader ppmReader(2, 0, true); is used, library expect Timer1 will be configured to run with prescaler 8, so than will be incremeneted every 0.5us at 16MHz and 1us at 8MHz ATmegas. It will also override TCNT1 so us use with caution. It gives better accuracy, but can cause conflicts with other libraries that uese Timer.

To initialize Timer1 use following code in setup block:

TCCR1A = 0;  //reset timer1
TCCR1B = 0;
TCCR1B |= (1 << CS11);  //set timer1 to increment every 0,5 us or 1us on 8MHz

License

This code is licensed under GNU GENERAL PUBLIC LICENSE Version 3 and is based on https://github.com/Hasi123/read-any-ppm and https://code.google.com/archive/p/read-any-ppm/

About

This Arduino code reads a PPM signal and puts the servo values into an array (called ppm), reagrdless of channel number, polarity, ppm frame length, etc...

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 100.0%