Testprog ADC

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
AbermetAlexander
Date:
Fri Jan 26 12:56:06 2018 +0000
Commit message:
Testprogramm

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 26 12:56:06 2018 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+
+AnalogIn Ain_PA_0(PA_0);    //A1 Messung des Stromsensors von Motor 2
+float ADCdata_PA_0;
+
+AnalogIn Ain_PA_1(PA_1);    //A0 Messung des Stromsensors von Motor 1
+float ADCdata_PA_1;
+
+AnalogIn Ain_PA_7(PA_7);    //A6 Messung der Drehzahl von Motor 2
+float ADCdata_PA_7;
+
+AnalogIn Ain_PA_3(PA_3);    //A2 Messung der Drehzahl von Motor 1 ! MOTOREN VERTAUSCHT
+float ADCdata_PA_3;
+
+float ADCdata_PA_0_10;
+float ADCdata_PA_1_10;
+float ADCdata_PA_7_10;
+float ADCdata_PA_3_10;
+
+int main() 
+{    
+    
+    while (1) 
+    {
+    
+    char input = pc.getc();
+       
+    if(input == 't')
+    {
+    
+    ADCdata_PA_0=(Ain_PA_0.read()*3.3f);                        //Umrechnung von 0.0->1.0 auf 0.0V->3.3V
+    ADCdata_PA_0_10=((ADCdata_PA_0*6.06060606f)-10.0f);         //Umrechnung von 0.0V->3.3V auf -10V->+10V            
+    pc.printf("ADC Data PA_0 PA_0_10 Values... \n\r");          //Plot Ueberschrift
+    pc.printf("%f %f Volts \n\r",ADCdata_PA_0,ADCdata_PA_0_10); //Plot Werte in Volt  
+
+    ADCdata_PA_1=(Ain_PA_1.read()*3.3f);  
+    ADCdata_PA_1_10=((ADCdata_PA_1*6.06060606f)-10.0f);            
+    pc.printf("ADC Data PA_1 PA_1_10 Values... \n\r");   
+    pc.printf("%f %fVolts \n\r",ADCdata_PA_1,ADCdata_PA_1_10);  
+
+  
+    ADCdata_PA_7=(Ain_PA_7.read()*3.3f);  
+    ADCdata_PA_7_10=((ADCdata_PA_7*6.06060606f)-10.0f);             
+    pc.printf("ADC Data PA_7 PA_7_10 Values... \n\r");   
+    pc.printf("%f %f Volts \n\r",ADCdata_PA_7,ADCdata_PA_7_10);  
+
+   
+    ADCdata_PA_3=(Ain_PA_3.read()*3.3f);
+    ADCdata_PA_3_10=((ADCdata_PA_3*6.06060606f)-10.0f);               
+    pc.printf("ADC Data PA_3 PA_3_10 Values... \n\r");   
+    pc.printf("%f %f Volts \n\r",ADCdata_PA_3,ADCdata_PA_3_10);  
+
+    wait_ms (50);   
+    }                              
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jan 26 12:56:06 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file