Hey guys, I posted here recently complaining about sluggish servo control for my quadcopter, blaming it on the servo library, but now realize that my brute-force technique for reading inputs from a receiver is the bottleneck of my program. My loop runs at about 10 Hz right now, but I need it to run at like >= 30 or 40 Hz if possible. So, anybody know any really efficient and quick ways to read signals from an R/C receiver?
Right now, I’m just using the pulseIn() function four times:
void inData(){
servo_ppm[0] = map(pulseIn(channel_1 + 0, LOW), ppm_bottom, ppm_top, -1 * coefficient[0], coefficient[0]);
servo_ppm[1] = map(pulseIn(channel_1 + 1, LOW), ppm_bottom, ppm_top, -1 * coefficient[1], coefficient[1]);
servo_ppm[2] = map(pulseIn(channel_1 + 2, LOW), ppm_bottom, ppm_top, 0, coefficient[2]);
servo_ppm[3] = map(pulseIn(channel_1 + 3, LOW), ppm_bottom, ppm_top, -1 * coefficient[3], coefficient[3]);
}
Thanks in advance,
Josh