Sunday, March 4, 2018

An AVR ATmega R/C control signal reader - Method/02


The Radio Control (R/C or RC) is the method of controlling remote devices using radio frequencies.
Most of the time the RC signal uses RC servo signals.
Servo signal is a square PWM signal, usually with a period of 20ms and a duty time between 1ms and 2ms. More info on the wikipedia page here: https://en.wikipedia.org/wiki/Servo_control.

This library implements a method to read an RC signal and eventually map this to a 0..100 number.

There are a few methods of performing this task of course. Another alternative method i propose can be found here: http://davidegironi.blogspot.com/2017/04/an-avr-atmega-rc-control-signal-reader.html


It's developed on an ATmega8 running at 16Mhz.
It makes use of the external interrupt PIN and a timer to count the duty period time.
It's customizable to fit the user preferences. Configuration can be found in rcin2.h header file.
This is slighly less accurate than the Method/01 proposed in the link above, but it uses less resources due to the slower timing needs.
Theory of operation: each time a rising edge interrupt it is raised the timer counter is stored, When the falling edge happens the difference between the actual timer counter and the stored one it is used to compute the duty time.
Input PIN is INT0.
The RC signal it is measured, eventually filtered using an exponential moving average filter, and then mapped to a speed value from 0 to 100.


Code
Notes
  • read risk disclaimer
  • excuse my bad english

No comments:

Post a Comment