— , FPV , , , - .
, . , PPM USB-, . , . , ? :
-, ,
FPV Freerider, Phoenix RC Aerofly RC 7. FPV Freerider - , -.
— !
:
- RC- , PPM (Pulse Position Modulation) . PPM-c , .
PPM :
PPM ( : , ).
:
AlexeyStn PPM-to-USB STM32F3Discovery, Arduino Pro Micro (Leonardo) USB, .
, USB . , .
rc-leonardo-joy, , : — . , , !
, : PPM
micros():
void rxInt(void) {
uint16_t now,diff;
static uint16_t last = 0;
static uint8_t chan = 0;
now = micros();
sei();
diff = now - last;
last = now;
if(diff>3000) chan = 0;
else {
if(900<diff && diff<2200 && chan<RC_CHANS ) {
rcValue[chan] = adjust(diff,chan);
}
chan++;
}
}
micros() Arduino:
Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 70 minutes. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds.
, 4 , 70 , - . . .
: (0-255):
byte stickValue(int rcVal) {
return map( constrain(rcVal - 1000, 0, 1000), 0, 1000, 0, 255);
}
, . HID .
— !
, PPM :
void initTimer(void) {
TCCR1A = 0;
TCCR1B = (0<<ICNC1) | (1<<ICES1) | (1<<CS11);
TCCR1C = 0;
TIFR1 = (1<<ICF1);
TIMSK1 = (1<<ICIE1);
}
...
ISR(TIMER1_CAPT_vect) {
union twoBytes {
uint16_t word;
uint8_t byte[2];
} timeValue;
uint16_t now, diff;
static uint16_t last = 0;
static uint8_t chan = 0;
timeValue.byte[0] = ICR1L;
timeValue.byte[1] = ICR1H;
now = timeValue.word;
diff = now - last;
last = now;
if(diff > (NEWFRAME_PULSE_WIDTH * TIMER_COUNT_DIVIDER)) {
chan = 0;
}
else {
if(diff > (MIN_PULSE_WIDTH * TIMER_COUNT_DIVIDER - THRESHOLD)
&& diff < (MAX_PULSE_WIDTH * TIMER_COUNT_DIVIDER + THRESHOLD)
&& chan < RC_CHANNELS_COUNT)
{
rcValue[chan] = adjust(diff, chan);
}
chan++;
}
}
0-1000 HID descriptor:
0x05, 0x01,
0x09, 0x04,
0xa1, 0x01,
0x85, JOYSTICK_REPORT_ID,
...
0xA1, 0x00,
0x09, 0x30,
0x09, 0x31,
0x09, 0x33,
0x09, 0x34,
0x15, 0x00,
0x26, 0xE8, 0x03,
0x75, 0x10,
0x95, 0x04,
0x81, 0x02,
0xc0,
0xc0
uint8_t uint16_t .
, #define , PPM-USB.
:
github.com/voroshkov/Leonardo-USB-RC-Adapter:
, :
#define FUTABA
- , :
#define STICK_HALFWAY 500
#define STICK_CENTER 1500
#define THRESHOLD 100
:
, USB Arduino, .
Arduino
...\Arduino\hardware\arduino\cores\arduino\,
usbapi.h hid.cpp,
ArduinoLibs . , Arduino Leonardo .
:
: USB, c – ( Digital Pin 4 ) PPM . - :
Windows 7 (, , ) Arduino Leonardo.
. - -, - ( Futaba 7C) – :
«»- . «» , , , , , . , , , . , :
( 4 , .)
. , , .
P.S.
Arduino Leonardo, Minimum Development Board STM32F103C8T6?

, . , ,
.
:
github.com/voroshkov/STM32-RC-USB-Adapter.
.
!