PPM dekódolást szeretnék megvalósítani egy m128cal. a PPM jel egy Futaba FC-16os modell rádióból származik. elvileg "szabvány" PPM. Egy hangkártyából infot kiszedő program (RCAudio a neve) felismeri a PPM-jelet annak mind a 8 csatornájával (6ot használok 2 üres). Tehát a csatornák adatait szeretném megkapni a m128cal.
annyit észrevettem az RCAudio programból "táplálkozó" AudioPPMView
program képén hogy a ppm jelek nálam a lentitől eltérően igy néznek ki:
Kód: Egész kijelölése
---- --------- --------- --------- -----
| | | | | | | |
-- -- -- --
Találtam az mcselec forumán egy kódot ami hasonló célt szolgált:
Kód: Egész kijelölése
'==============================================================================
' Vex Receiver Decode Example V1
' By: Glen Aidukas 2008-08-22
' Compiler: Bascom-AVR V1.11.9.2
'
' This is an example program for decoding the pulses that com from the VEX
' robot RC receiver.
'
' Theory of operation:
'
' The VEX receiver output is a simple single wire signal using pulse width
' modulated signals for each of the 6 channels.
' There are 7 PWM pulses total. The first being a sync pulse and then
' followed by 6 more varying width pulses (one for each channel).
'
' - - - - - - -
' | | | | | | | | | | | | | | ...
' ------------ -- -- -- -- -- --
'
' | sync pulse | c1 | c2 | c3 | c4 | c5 | c6 | next sync pulse...
'
' The sync pulse varies between (about) 6 and 12 mSecs long.
' Then the other 6 pulses very between 1 to 2 mSecs long.
'
' Note: While the sync pulse varies the total for the complete cycle is always
' 20 mSecs long or 50 complete cycles per second.
'==============================================================================
$regfile = "attiny2313.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 10
$framesize = 40
$baud = 38400 ' uart speed
dim x as byte ' channel index for printing
dim z as byte ' channel index for in side the isr
dim chan(6) as word ' holds the channel values (in uSecs)
dim cnt as word ' hold the current pulse in the isr
dim sync as word ' hold the sync value for debug (not needed)
const SyncPulse = 5000 ' the sync pulse is somthing over 5000 uSecs
' configure port
config portb.6 = input ' imput from vex (ICP)
portd.6 = 1 ' turn on pullup resistor (no external parts needed)
' Configuring Timer1 for 1 uSec ticks - crystal 8000000 / 8 = 1 uSec
Config Timer1 = Timer, Capture Edge = Rising, prescale = 8
on capture1 PulseCapture_isr ' main code for getting pulse values
enable Capture1
enable interrupts
print chr(27) ; "[2J"; ' ansi clear screen...
print "starting..."
' Main loop...
do
print chr(27) ; "[2;1H"; ' move cursor to the second line
for x= 1 to 6
print "Chan"; x; ": "; chan(x); " " ' show the value of a give (x) channal
next
print "Sync : "; sync; " " ' show the leanth of the sync pulse
waitms 100
loop
' All work is handled in the following isr
PulseCapture_isr:
cnt = Capture1 ' get the current pulse value
timer1= 0 ' reset the timer for the next pulse
if cnt > SyncPulse then ' check for sync pulse
sync = cnt ' save the current pulse value for debug
z=1 ' set the index to the first channel
elseif z < 7 then ' assign 1-6 and then wait for sync pulse
chan(z) = cnt ' assign the pulse value to the proper channel
incr z ' next channel...
endif
return
Előre is köszönöm a segítséget!
Üdv: Zsolti