Latest version of my quadcopter controller with an LPC1768 and MPU9250.
Currently running on a custom PCB with 30.5 x 30.5mm mounts. There are also 2 PC apps that go with the software; one to set up the PID controller and one to balance the motors and props. If anyone is interested, send me a message and I'll upload them.
Filters/MAfilter.cpp@0:0929d3d566cf, 2018-07-09 (annotated)
- Committer:
- Anaesthetix
- Date:
- Mon Jul 09 16:31:40 2018 +0000
- Revision:
- 0:0929d3d566cf
- Child:
- 4:fab65ad01ab4
Latest version of my multicopter controller
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anaesthetix | 0:0929d3d566cf | 1 | #include "MAfilter.h" |
Anaesthetix | 0:0929d3d566cf | 2 | |
Anaesthetix | 0:0929d3d566cf | 3 | float MAfilter::run(float input) |
Anaesthetix | 0:0929d3d566cf | 4 | { |
Anaesthetix | 0:0929d3d566cf | 5 | for(i=1; i<200; i++) |
Anaesthetix | 0:0929d3d566cf | 6 | { |
Anaesthetix | 0:0929d3d566cf | 7 | filterbuff[i] = filterbuff[i-1]; |
Anaesthetix | 0:0929d3d566cf | 8 | } |
Anaesthetix | 0:0929d3d566cf | 9 | filterbuff[0] = input; |
Anaesthetix | 0:0929d3d566cf | 10 | |
Anaesthetix | 0:0929d3d566cf | 11 | for(i=0; i<200; i++) out = out + (filterbuff[i]/200); |
Anaesthetix | 0:0929d3d566cf | 12 | |
Anaesthetix | 0:0929d3d566cf | 13 | return out; |
Anaesthetix | 0:0929d3d566cf | 14 | } |
Anaesthetix | 0:0929d3d566cf | 15 | |
Anaesthetix | 0:0929d3d566cf | 16 | float MAfilter10::run(float input) |
Anaesthetix | 0:0929d3d566cf | 17 | { |
Anaesthetix | 0:0929d3d566cf | 18 | for(i=1; i<10; i++) |
Anaesthetix | 0:0929d3d566cf | 19 | { |
Anaesthetix | 0:0929d3d566cf | 20 | filterbuff[i] = filterbuff[i-1]; |
Anaesthetix | 0:0929d3d566cf | 21 | } |
Anaesthetix | 0:0929d3d566cf | 22 | filterbuff[0] = input; |
Anaesthetix | 0:0929d3d566cf | 23 | |
Anaesthetix | 0:0929d3d566cf | 24 | out = 0; |
Anaesthetix | 0:0929d3d566cf | 25 | for(i=0; i<10; i++) out = out + (filterbuff[i]*0.1); |
Anaesthetix | 0:0929d3d566cf | 26 | |
Anaesthetix | 0:0929d3d566cf | 27 | return out; |
Anaesthetix | 0:0929d3d566cf | 28 | } |
Anaesthetix | 0:0929d3d566cf | 29 |