Testprog ADC
Dependencies: mbed
main.cpp@0:0dee8d4b1d71, 2018-01-26 (annotated)
- Committer:
- AbermetAlexander
- Date:
- Fri Jan 26 12:56:06 2018 +0000
- Revision:
- 0:0dee8d4b1d71
Testprogramm
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AbermetAlexander | 0:0dee8d4b1d71 | 1 | #include "mbed.h" |
AbermetAlexander | 0:0dee8d4b1d71 | 2 | |
AbermetAlexander | 0:0dee8d4b1d71 | 3 | Serial pc(USBTX, USBRX); |
AbermetAlexander | 0:0dee8d4b1d71 | 4 | |
AbermetAlexander | 0:0dee8d4b1d71 | 5 | AnalogIn Ain_PA_0(PA_0); //A1 Messung des Stromsensors von Motor 2 |
AbermetAlexander | 0:0dee8d4b1d71 | 6 | float ADCdata_PA_0; |
AbermetAlexander | 0:0dee8d4b1d71 | 7 | |
AbermetAlexander | 0:0dee8d4b1d71 | 8 | AnalogIn Ain_PA_1(PA_1); //A0 Messung des Stromsensors von Motor 1 |
AbermetAlexander | 0:0dee8d4b1d71 | 9 | float ADCdata_PA_1; |
AbermetAlexander | 0:0dee8d4b1d71 | 10 | |
AbermetAlexander | 0:0dee8d4b1d71 | 11 | AnalogIn Ain_PA_7(PA_7); //A6 Messung der Drehzahl von Motor 2 |
AbermetAlexander | 0:0dee8d4b1d71 | 12 | float ADCdata_PA_7; |
AbermetAlexander | 0:0dee8d4b1d71 | 13 | |
AbermetAlexander | 0:0dee8d4b1d71 | 14 | AnalogIn Ain_PA_3(PA_3); //A2 Messung der Drehzahl von Motor 1 ! MOTOREN VERTAUSCHT |
AbermetAlexander | 0:0dee8d4b1d71 | 15 | float ADCdata_PA_3; |
AbermetAlexander | 0:0dee8d4b1d71 | 16 | |
AbermetAlexander | 0:0dee8d4b1d71 | 17 | float ADCdata_PA_0_10; |
AbermetAlexander | 0:0dee8d4b1d71 | 18 | float ADCdata_PA_1_10; |
AbermetAlexander | 0:0dee8d4b1d71 | 19 | float ADCdata_PA_7_10; |
AbermetAlexander | 0:0dee8d4b1d71 | 20 | float ADCdata_PA_3_10; |
AbermetAlexander | 0:0dee8d4b1d71 | 21 | |
AbermetAlexander | 0:0dee8d4b1d71 | 22 | int main() |
AbermetAlexander | 0:0dee8d4b1d71 | 23 | { |
AbermetAlexander | 0:0dee8d4b1d71 | 24 | |
AbermetAlexander | 0:0dee8d4b1d71 | 25 | while (1) |
AbermetAlexander | 0:0dee8d4b1d71 | 26 | { |
AbermetAlexander | 0:0dee8d4b1d71 | 27 | |
AbermetAlexander | 0:0dee8d4b1d71 | 28 | char input = pc.getc(); |
AbermetAlexander | 0:0dee8d4b1d71 | 29 | |
AbermetAlexander | 0:0dee8d4b1d71 | 30 | if(input == 't') |
AbermetAlexander | 0:0dee8d4b1d71 | 31 | { |
AbermetAlexander | 0:0dee8d4b1d71 | 32 | |
AbermetAlexander | 0:0dee8d4b1d71 | 33 | ADCdata_PA_0=(Ain_PA_0.read()*3.3f); //Umrechnung von 0.0->1.0 auf 0.0V->3.3V |
AbermetAlexander | 0:0dee8d4b1d71 | 34 | ADCdata_PA_0_10=((ADCdata_PA_0*6.06060606f)-10.0f); //Umrechnung von 0.0V->3.3V auf -10V->+10V |
AbermetAlexander | 0:0dee8d4b1d71 | 35 | pc.printf("ADC Data PA_0 PA_0_10 Values... \n\r"); //Plot Ueberschrift |
AbermetAlexander | 0:0dee8d4b1d71 | 36 | pc.printf("%f %f Volts \n\r",ADCdata_PA_0,ADCdata_PA_0_10); //Plot Werte in Volt |
AbermetAlexander | 0:0dee8d4b1d71 | 37 | |
AbermetAlexander | 0:0dee8d4b1d71 | 38 | ADCdata_PA_1=(Ain_PA_1.read()*3.3f); |
AbermetAlexander | 0:0dee8d4b1d71 | 39 | ADCdata_PA_1_10=((ADCdata_PA_1*6.06060606f)-10.0f); |
AbermetAlexander | 0:0dee8d4b1d71 | 40 | pc.printf("ADC Data PA_1 PA_1_10 Values... \n\r"); |
AbermetAlexander | 0:0dee8d4b1d71 | 41 | pc.printf("%f %fVolts \n\r",ADCdata_PA_1,ADCdata_PA_1_10); |
AbermetAlexander | 0:0dee8d4b1d71 | 42 | |
AbermetAlexander | 0:0dee8d4b1d71 | 43 | |
AbermetAlexander | 0:0dee8d4b1d71 | 44 | ADCdata_PA_7=(Ain_PA_7.read()*3.3f); |
AbermetAlexander | 0:0dee8d4b1d71 | 45 | ADCdata_PA_7_10=((ADCdata_PA_7*6.06060606f)-10.0f); |
AbermetAlexander | 0:0dee8d4b1d71 | 46 | pc.printf("ADC Data PA_7 PA_7_10 Values... \n\r"); |
AbermetAlexander | 0:0dee8d4b1d71 | 47 | pc.printf("%f %f Volts \n\r",ADCdata_PA_7,ADCdata_PA_7_10); |
AbermetAlexander | 0:0dee8d4b1d71 | 48 | |
AbermetAlexander | 0:0dee8d4b1d71 | 49 | |
AbermetAlexander | 0:0dee8d4b1d71 | 50 | ADCdata_PA_3=(Ain_PA_3.read()*3.3f); |
AbermetAlexander | 0:0dee8d4b1d71 | 51 | ADCdata_PA_3_10=((ADCdata_PA_3*6.06060606f)-10.0f); |
AbermetAlexander | 0:0dee8d4b1d71 | 52 | pc.printf("ADC Data PA_3 PA_3_10 Values... \n\r"); |
AbermetAlexander | 0:0dee8d4b1d71 | 53 | pc.printf("%f %f Volts \n\r",ADCdata_PA_3,ADCdata_PA_3_10); |
AbermetAlexander | 0:0dee8d4b1d71 | 54 | |
AbermetAlexander | 0:0dee8d4b1d71 | 55 | wait_ms (50); |
AbermetAlexander | 0:0dee8d4b1d71 | 56 | } |
AbermetAlexander | 0:0dee8d4b1d71 | 57 | } |
AbermetAlexander | 0:0dee8d4b1d71 | 58 | } |