NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.
RC/RC_Channel.h@33:fd98776b6cc7, 2013-04-04 (annotated)
- Committer:
- maetugr
- Date:
- Thu Apr 04 14:25:21 2013 +0000
- Revision:
- 33:fd98776b6cc7
- Parent:
- 27:9e546fa47c33
- Child:
- 34:3aa1cbcde59d
New version developed in eastern holidays, ported Madgwick Filter, added support for chaning PID values while flying over bluetooth, still not flying stable or even controllable
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 7:9d4313510646 | 1 | #ifndef RC_CHANNEL_H |
maetugr | 7:9d4313510646 | 2 | #define RC_CHANNEL_H |
maetugr | 7:9d4313510646 | 3 | |
maetugr | 7:9d4313510646 | 4 | #include "mbed.h" |
maetugr | 7:9d4313510646 | 5 | |
maetugr | 7:9d4313510646 | 6 | class RC_Channel |
maetugr | 7:9d4313510646 | 7 | { |
maetugr | 7:9d4313510646 | 8 | public: |
maetugr | 27:9e546fa47c33 | 9 | RC_Channel(PinName mypin, int index); // NO p19/p20!!!!, they don't support InterruptIn |
maetugr | 10:953afcbcebfc | 10 | int read(); // read the last measured data |
maetugr | 7:9d4313510646 | 11 | |
maetugr | 7:9d4313510646 | 12 | private: |
maetugr | 27:9e546fa47c33 | 13 | int index; // to know which channel of the RC an instance has |
maetugr | 27:9e546fa47c33 | 14 | int time; // last measurement data |
maetugr | 27:9e546fa47c33 | 15 | float scale; // calibration values |
maetugr | 27:9e546fa47c33 | 16 | float offset; |
maetugr | 27:9e546fa47c33 | 17 | |
maetugr | 10:953afcbcebfc | 18 | InterruptIn myinterrupt; // interrupt on the pin to react when signal falls or rises |
maetugr | 10:953afcbcebfc | 19 | void rise(); // start the time measurement when signal rises |
maetugr | 10:953afcbcebfc | 20 | void fall(); // stop the time mesurement and save the value when signal falls |
maetugr | 10:953afcbcebfc | 21 | Timer timer; // timer to measure the up time of the signal and if the signal timed out |
maetugr | 10:953afcbcebfc | 22 | |
maetugr | 10:953afcbcebfc | 23 | Ticker timeoutchecker; // Ticker to see if signal broke down |
maetugr | 10:953afcbcebfc | 24 | void timeoutcheck(); // to check for timeout, checked every second |
maetugr | 27:9e546fa47c33 | 25 | |
maetugr | 27:9e546fa47c33 | 26 | // Calibration value saving |
maetugr | 27:9e546fa47c33 | 27 | void saveCalibrationValue(float * value, char * fileextension); |
maetugr | 27:9e546fa47c33 | 28 | void loadCalibrationValue(float * value, char * fileextension); |
maetugr | 7:9d4313510646 | 29 | }; |
maetugr | 7:9d4313510646 | 30 | |
maetugr | 7:9d4313510646 | 31 | #endif |