Hello,
I am making a quadcopter with my mcu called Hifive1 , i am facing an issue for a long time , i am unable to find the cause and solution for the issue.
In my main loop i call functions like reading receiver's input, gyro values, pid calculation and finally
esc outputs.
I am using arduino pro mini as a pwm to ppm converter so the output ppm pin go into the hifive1 as a rising interrupt pin.
The problem is when the sticks are at the center the values should be 1500(+/-2) but here the values are more unstable/noisy/jittery ranging from 1467-1529
i checked with gyro sensor communication fortunately it is good.
In my main loop code if i comment some lines randomly the signals are proper it is so strange !
why what is the reason
here i share my code
when the length of the code is big it gets affected! but technically what is the problem?
In my main loop code if i comment some lines randomly the signals are proper it is so strange !
Ok, but please tell us which lines you did this to, so we can reproduce the same results. This kind of thing is usually a symptom of running out of memory. Commenting out any piece of code will change the memory usage enough to shift the corruption caused by overwriting a different piece of memory.
Your code is hard to read with inconsistent indenting. Use the auto format function in Arduino. It is very good. If it appears to scramble your code then your code was wrong.
The one thing that stands out on my first read through is you are using Serial.print() inside the ISR. Take all of that out. You should never attempt to print while interrupts are disabled.
i have 4 methods of ppm decoding otherwise ISR's , in that code i used 3rd method it seems and i forgot to comment that serial print inside the isr ,it has to be pasted in the main loop instead.