Testprog ADC

Dependencies:   mbed

main.cpp

Committer:
AbermetAlexander
Date:
2018-01-26
Revision:
0:0dee8d4b1d71

File content as of revision 0:0dee8d4b1d71:

#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);   
    }                              
    }
}