Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Quadrocopter by
main.cpp@10:16ca5e9ee0dc, 2017-08-08 (annotated)
- Committer:
- MarcoF89
- Date:
- Tue Aug 08 16:53:22 2017 +0000
- Revision:
- 10:16ca5e9ee0dc
- Parent:
- 9:9185d37e061f
- Child:
- 11:8457b851e3e1
Als n?chstes muss eine Funktion f?r jedes einzelne PWM Signal geschrieben werden. Das Hauptger?st ist vorerst in der main.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MarcoF89 | 6:27a09e8bebfb | 1 | #include "mbed.h" |
MarcoF89 | 6:27a09e8bebfb | 2 | #include "stdio.h" |
MarcoF89 | 6:27a09e8bebfb | 3 | #include <Timer.h> |
MarcoF89 | 6:27a09e8bebfb | 4 | #include "messen.h" |
MarcoF89 | 7:a54c97795013 | 5 | |
MarcoF89 | 6:27a09e8bebfb | 6 | static Serial pc(SERIAL_TX, SERIAL_RX); |
MarcoF89 | 6:27a09e8bebfb | 7 | static SPI spi(PE_6,PE_5,PE_2); //mosi,miso,sclk |
MarcoF89 | 6:27a09e8bebfb | 8 | static DigitalOut ncs(PE_4); //ssel |
MarcoF89 | 6:27a09e8bebfb | 9 | |
MarcoF89 | 10:16ca5e9ee0dc | 10 | static AnalogIn poti_1 (PF_3); |
MarcoF89 | 10:16ca5e9ee0dc | 11 | static AnalogIn poti_2 (PF_10); |
MarcoF89 | 10:16ca5e9ee0dc | 12 | static AnalogIn poti_3 (PF_4); |
MarcoF89 | 10:16ca5e9ee0dc | 13 | static AnalogIn poti_4 (PF_5); |
MarcoF89 | 7:a54c97795013 | 14 | |
MarcoF89 | 7:a54c97795013 | 15 | static DigitalIn taster1 (PG_7); |
MarcoF89 | 7:a54c97795013 | 16 | static DigitalIn taster2 (PD_10); |
MarcoF89 | 7:a54c97795013 | 17 | static DigitalIn taster3 (PG_14); |
MarcoF89 | 7:a54c97795013 | 18 | static DigitalIn taster4 (PF_12); |
MarcoF89 | 6:27a09e8bebfb | 19 | |
MarcoF89 | 8:769ff3814355 | 20 | static DigitalOut db0(PC_8); |
MarcoF89 | 8:769ff3814355 | 21 | static DigitalOut db1(PC_9); |
MarcoF89 | 8:769ff3814355 | 22 | static DigitalOut db2(PC_10); |
MarcoF89 | 8:769ff3814355 | 23 | static DigitalOut db3(PC_11); |
MarcoF89 | 8:769ff3814355 | 24 | static DigitalOut db4(PC_12); |
MarcoF89 | 8:769ff3814355 | 25 | static DigitalOut db5(PC_13); |
MarcoF89 | 8:769ff3814355 | 26 | static DigitalOut db6(PC_14); |
MarcoF89 | 8:769ff3814355 | 27 | static DigitalOut db7(PC_15); |
MarcoF89 | 8:769ff3814355 | 28 | |
MarcoF89 | 10:16ca5e9ee0dc | 29 | static PwmOut Motor2 (PC_9); // Weiß |
MarcoF89 | 10:16ca5e9ee0dc | 30 | static PwmOut Motor1 (PC_8); // Schwarz |
MarcoF89 | 10:16ca5e9ee0dc | 31 | static PwmOut Motor3 (PC_6); // Grau |
MarcoF89 | 10:16ca5e9ee0dc | 32 | static PwmOut Motor4 (PB_9); // Blau |
MarcoF89 | 10:16ca5e9ee0dc | 33 | // Gelb und Orange Vcc +5V |
MarcoF89 | 10:16ca5e9ee0dc | 34 | // Gnd Rot |
MarcoF89 | 9:9185d37e061f | 35 | |
MarcoF89 | 8:769ff3814355 | 36 | |
MarcoF89 | 6:27a09e8bebfb | 37 | int main() |
MarcoF89 | 6:27a09e8bebfb | 38 | { |
MarcoF89 | 9:9185d37e061f | 39 | |
MarcoF89 | 10:16ca5e9ee0dc | 40 | Motor1.period_ms(2); |
MarcoF89 | 10:16ca5e9ee0dc | 41 | Motor2.period_ms(2); |
MarcoF89 | 10:16ca5e9ee0dc | 42 | Motor3.period_ms(2); |
MarcoF89 | 10:16ca5e9ee0dc | 43 | Motor4.period_ms(2); |
MarcoF89 | 9:9185d37e061f | 44 | |
MarcoF89 | 10:16ca5e9ee0dc | 45 | |
MarcoF89 | 9:9185d37e061f | 46 | pc.printf("\n\r"); |
MarcoF89 | 6:27a09e8bebfb | 47 | while(1) |
MarcoF89 | 10:16ca5e9ee0dc | 48 | { |
MarcoF89 | 10:16ca5e9ee0dc | 49 | Motor3.pulsewidth_us(poti_1.read_u16()*0.015305732*2); |
MarcoF89 | 10:16ca5e9ee0dc | 50 | pc.printf("Poti = %2.2f\r",poti_1.read_u16()*0.015305732); |
MarcoF89 | 10:16ca5e9ee0dc | 51 | } |
MarcoF89 | 10:16ca5e9ee0dc | 52 | } |
MarcoF89 | 9:9185d37e061f | 53 | |
MarcoF89 | 10:16ca5e9ee0dc | 54 | |
MarcoF89 | 10:16ca5e9ee0dc | 55 | |
MarcoF89 | 9:9185d37e061f | 56 | |
MarcoF89 | 10:16ca5e9ee0dc | 57 | |
MarcoF89 | 10:16ca5e9ee0dc | 58 | /* |
MarcoF89 | 9:9185d37e061f | 59 | float x = aktuell_acc_x (); |
MarcoF89 | 9:9185d37e061f | 60 | float z = aktuell_acc_z (); |
MarcoF89 | 9:9185d37e061f | 61 | winkel1 = (((float)atan2(x, z))); |
MarcoF89 | 9:9185d37e061f | 62 | float y = aktuell_acc_y (); |
MarcoF89 | 9:9185d37e061f | 63 | winkel2 = (((float)atan2(y, z))); |
MarcoF89 | 10:16ca5e9ee0dc | 64 | |
MarcoF89 | 10:16ca5e9ee0dc | 65 | pc.printf("%4.2f\t\t\t%4.2f\t\r",winkel1*360/6.28, winkel2*360/6.28);*/ |