(SO....I have to see both codes side by side so I can learn for my mistakes)
You 've done excellent coding ...I'll give it a try although I had problems with averaging routines -keep sending '0' as result!
(SO....I have to see both codes side by side so I can learn for my mistakes)
You 've done excellent coding ...I'll give it a try although I had problems with averaging routines -keep sending '0' as result!
I agree with Walter.
All this "Software Timed" stuff just doesn't work well together.
Everything, should be Interrupt driven.
Capture (CCP) the received pulses.
Use A/D interrupt to OverSample the Altitude. (oversampling does not have to be "Blocking")
Timer interrupt to drive the servo.
No PULSIN's, no PULSOUT's, no SHIFTIN/OUT.
These PIC chips are extremely fast. (As long as the program isn't sitting in a loop somewhere waisting 90% of it's time.)
And with the Hardware doing most of the work, they "Scream".
Even if you don't use Interrupts ... Use the hardware.
<br>
DT
Hi, Alex ...
just two little "bugs" of mine ...
Code:'--------------------------------------------------------------------------- pause 3000 for x=1 to 4 high led pause 200 low led pause 100 next x
... I only forgot to clear the comments for shortening delays when using MPSIM ...
Here is the good sequence ...
AND
Forgot resetting "value" ... Boooo.Code:Average:' -=-=-=-=-=-= Average 16 X Analog values -=-=-=-=-=-=-=-=-=-= Value = 0 For x = 0 to 15 ' 16 Samples MAXI !!! shiftin ADC_DATA,ADC_SCLK,msbpost,[advalue\12] '337 µs value = value + advalue
But ... you of course had noticed it !
Alain
PS for Darrel ...
You really sure ??? ... not me, here for R/C Gadgets ...Everything, should be Interrupt driven.
Last edited by Acetronics2; - 3rd February 2010 at 09:44.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks