View Full Version : Build Log Use AVR Mega8 MCU to recognize RX signal
Kenny Fong
Feb 20, 2007, 02:48 AM
Rx servo signal is a 50Hz PWM, using high holding width to represent the Tx stick position.
Given the principle, it's easy to use MCU to recognize Rx signal.
The example is using ATMEL AVR Mega 8 MCU, with 11 LEDs showing the movement of the Tx stick.
Recognizing the Rx servo signal is the basic for RC Rx peripheral device design, such as ESC, or other ones.
Check it out if interested...
http://www.youtube.com/watch?v=aBkh3Y_MvaI
Gary Warner
Feb 20, 2007, 01:09 PM
Cool! I wish I would have thought about that. Please share more.
Acetronics
Feb 20, 2007, 02:18 PM
Hi, Gary
a look here for the bargraph ? ...
http://www.edn.com/article/CA6363904.html
or
http://www.edn.com/article/CA6399101.html?spacedesc=designideas&industryid=44217
for measuring the pulse length ( 1 - 2 ms ) ... do not need to show you !!! ;)
Alain
Endurance
Feb 20, 2007, 03:04 PM
The plans and code for a PWM decoder were recently featured in Servo magazine. You can see the article, plans, etc. here: http://www.kronosrobotics.com/Projects/RCRadioInterface.shtml
Gary Warner
Feb 20, 2007, 03:08 PM
I want to know how he got those lights to flash like that when it starts up. Do you turn the power on and off real fast or is that part of the normal way those lights turn on? Where can I buy light like that?
Endurance
Feb 20, 2007, 05:08 PM
My guess is that its just pre-programmed to do it before it enters a main loop. Microcontrollers will have a bunch of output pins, you connect an led to these pins (and other cirturty, like motors, relays, etc.) and activate the pins to light the led. I use the following C code to activate pins in my projects.
LATCbits.LATC0 = 1; //on
LATCbits.LATC0 = 0; //off
Kenny, you might want to correct me since I can only guess about how you did it.
Gary Warner
Feb 20, 2007, 06:00 PM
LOL :D
I thought I was better well known around these parts :rolleyes:
:p :p :p
(Anything to bump it to the top) ;)
Kenny Fong
Feb 20, 2007, 11:45 PM
The initial flash is programmed to indicate the Tx stick travel width setup and EEPROM data loading of last time default setups, and check out if the Tx is powered on. If can't find the Tx signal, it will blink to the Tx is turned on.
To make the LED flash, you can easily let it ON and OFF, with reasonable interval. The MCU C code method is just like Mr. Endurance's, similar.
I use HP AVR C++ Vision Complier for Mega 8 programming. Most MCU can directly drive LEDs on their PINs, plus a current-limit resistor. The Mega 8 C code to output is below. Do not forget the MCU is a digital circuit device, so the output code is so easy:
PortD = 0xFF; // LED ON
....... // time interval
PortD = 0x00; // LED OFF
I like to use an 8-bit value to set the whole port pins at a time directly, of course it can be set like PortD.0 = 1; PortD.1 = 0.......etc... Mega 8 has 8 pins at each port, except PortC(7 pins), and every port pin can be set to be Output or Input pins.
This Rx signal recognization example uses PortB0's ICP PWM capture function of Timer 1, to identify the high pulse width of Tx stick position. Mega8 can have 3 timers at the same time, with a lot of special functions plus, such as PWM input capture and PWM output. Once you get the Tx stick travel width and the current high pulse width, indicating the stick position is in your hands.
Timer1 PWM capture can be set at rising-edge interrupt and falling-edge interrupt, and give you a register value indicate the time interval. It's easier to implement the Tx stick position recognization with AVR Mega series MCU, than imagine... ... I feel it very convenient.
(I'll open a new thread to demostrate how to program an ESC, just for interest.)
Ralph Weaver
Feb 21, 2007, 08:14 AM
A few years ago I did a project that uses a 4 digit LED display. It measures the servo pulse width and displays it on the LED. I used an AVR2313. It's pretty simple - if anyone wants the asm file, let me know. It only used a handful of parts.
LEDs require current limiting resistors... unless you PWM them. My code only turns each segment on for a short enough time that the resistors are not needed. Just make sure to use the watchdog to make sure the micro doesn't get stuck with a segment on (poof!). Also, be very careful when single stepping or setting breakpoints. (poof! again)
vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.