Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
gramo said:Hi Kiko, I did a small video tutorial for you, hopefully it helps you out
https://www.box.net/shared/shsk5b7091
Is that what you’re looking for?
gramo said:It is a rather hairy task, a friend and I made a GPS 'auto pilot' for his RC Plane, and ran into some similar issues.
Basically you know that the RC signal will be sent every 50Hz, and usually has a maximum 2mS pulse(nominal figure for most RC Receivers). That means the PIC can record the time in mS, and have up to 18mS to do what ever it wants.
An 18F PIC micro can perform 180000 instructions in 18mS, so perhaps you see where this is heading.
Before I go further, why do you need multiple RC signals?
Sceadwian said:If you need to log large amounts of data like that learn how to interface to SD/MMC cards. They're one of the more common flash memory storage devices out there and you can get them in sizes up to 4gig currently, and interface well with any micro controller which can use the SPI bus.
If you're recording servo signals and the readings are 8 bit in resolution and typically they don't go more than 8 channels at 50hz. That's 3200 bytes per second. On a 4 gig SD card that'd be 20,800+ hours of recording time. You can process the data to get the acceleration vector aftwards, or do it on the pic itself only storing the accleration vector based on a few buffer bytes.
Sceadwian said:There's one problem with record and playback for flight data at that length. It doesn't work over that length of time. Air currents and other flight characotoristics will distort the recorded movement on playback and result in different end movements. It might work for pattern flying on a finely tuned aircraft over 5 seconds or so, but not for flight path reproduction with any degree of accuracy over a few minutes.
Hank Fletcher said:Cool video, gramo. Bit of a problem adding up to 20ms PWM period until you got to the 19ms + 1ms part, though. Still, it's just 1ms - who's gonna miss it?
gramo said:Putting so many ideas into one project might be a bad way to go about this!
Start simple, learn how to intercept and monitor RC servo signals, then take on the recording side of things separately.
There are a lot of variables with this 'simple' concept, and it will probably not be worth the effort, perhaps a simple RC buddy system would be a simpler option
Pulsin acts as a fast clock that is triggered by a change in state (0 or 1) on the specified pin. When the state on the pin changes to the state specified, the clock starts counting. When the state on the pin changes again, the clock stops. If the state of the pin doesn't change (even if it is already in the state specified in the Pulsin instruction), the clock won't trigger. Pulsin waits a maximum of 0.65535 seconds for a trigger, then returns with 0 in variable. The variable can be either a word or a byte . If the variable is a word, the value returned by Pulsin can range from 1 to 65535 units.
The units are dependant on the frequency of the crystal used. If a 4MHz crystal is used, then each unit is 10us, while a 20MHz crystal produces a unit length of 2us.
If the variable is a byte and the crystal is 4MHz, the value returned can range from 1 to 255 units of 10µs. Internally, Pulsin always uses a 16-bit timer. When your program specifies a byte, Pulsin stores the lower 8 bits of the internal counter into it. Pulse widths longer than 2550µs will give false, low readings with a byte variable. For example, a 2560µs pulse returns a reading of 256 with a word variable and 0 with a byte variable.
Device = 16F877A
XTAL = 20
Dim Result As Word
While True
Result = PulsIn, PORTC.0, 1
Result = Result * 2 ' Scale to uS (20Mhz Clock = 2uS increments)
PrintAt 1, 1, DEC5 Result, " uS" ' Display result on an LCD
Wend
gramo said:If your still using Proton, what about the PulsIn command?
From the help file;
So you could use something like
Code:Device = 16F877A XTAL = 20 Dim Result As Word While True Result = PulsIn, PORTC.0, 1 Result = Result * 2 ' Scale to uS (20Mhz Clock = 2uS increments) PrintAt 1, 1, DEC5 Result, " uS" ' Display result on an LCD Wend
Kiko said:I'm using Proton and I have made some experience using Pulsin and servo commands with good results, but I'm a little confusing in writing data to eeprom (internal and external), so if you have any exemple with explanation I'll apreciate.
Tks
Variable = [B]EREAD [/B]Address
[B]EWRITE [/B]Address , [Variable, Variable]
Dim Large_Variable[B] As DWord
EWRITE[/B] 00, [Large_Variable]
[B]Device [/B]= 16F877
[B]Xtal [/B]= 4
[B]Dim [/B]DWord_Var as DWord
[B]Dim [/B]Word_Var as Word
[B]Dim [/B]Temp_DWord as DWord
[B] Dim [/B]Temp_Word as Word
LCD_DTPIN = PORTB.4
LCD_RSPIN = PORTB.2
LCD_ENPIN = PORTB.3
LCD_INTERFACE = 4
LCD_LINES = 2
LCD_TYPE = 0
[B]All_Digital[/B] = True
[B]Delayms [/B]150
[B]Cls[/B]
DWord_Var = 1000000
Word_Var = 1000
Main:
[B]EWrite [/B]00, [DWord_Var, Word_Var]
Temp_DWord = [B]ERead [/B]00
Temp_Word = [B]ERead [/B]04
[B]Print At[/B] 1, 1, DEC7 Temp_DWord
[B]Print At[/B] 2, 1, DEC5 Temp_Word
[B]Inc [/B]DWord_Var
[B]Inc [/B]Word_Var
[B]DelaymS [/B]1000
[B]Goto [/B]Main
Kiko said:Gramo thank you.
Let me ask something, as I did not have any class about programming pics I can't understand when you say 1 byte, 2 bytes, etc... I know 1 Byte is 8 bits but I can't make a relationship between a real number or word as bit/byte. For example: Let's say I have a number (1345) or a word (test). How many bits or bytes does it have?
I know it's a basic of programming and perhaps is a stupid question.
Thank you again