Hi!
I'm trying to write my own ardupilot for a quadcopter (just as a hobby, not because I want it to be better than existing ones) and, even though some things worked in isolation, putting them together causes issues.
I have 4 main components:
- IMU: Communicates using SCA/SCL triggered by an interruption on pin 2
- 4 ESCs: Need to output 1000-2000us pulses each 20ms or so
- 6 RC channels: Input of 1000-2000us pulses each 20ms or so
- HC-05: "Software" serial communication (not sure on the specifics, but the lib I'm using uses timers to send pulses)
Libraries usually don't work well together because all of them wants to use TIMER1 (16 bits) and they end up conflicting.
I thought about trying to merge their timer functions together, but in the end I don't think this would be much different than just running all my measument of inputs and updating of outputs in the main loop.
This doesn't seem easy to do/debug, but the best way I thought about doing this is, for each loop, check the input pins and count how much time they stayed up; and also set the output pins on/off based on how long ago this happened before.
No interrupts at all.
Is there a better approach to this?
Thanks!