Multiplexer lauffähig

Dependencies:   USBDevice mbed

Fork of Multiplexer-Test by H2M Teststand

Files at this revision

API Documentation at this revision

Comitter:
O_Shovah
Date:
Wed Sep 10 06:36:20 2014 +0000
Parent:
8:fd403cfcaa0a
Child:
10:e4923fb9c3c2
Commit message:
Snippet;DMS Abfrage,Grundfunktion,ohne Kalibrierung; 100920140835;JS

Changed in this revision

Multiplexer_read.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Multiplexer_read.cpp	Tue Sep 09 10:48:03 2014 +0000
+++ b/Multiplexer_read.cpp	Wed Sep 10 06:36:20 2014 +0000
@@ -1,82 +1,44 @@
+//Includes
 #include "mbed.h"
-
+//*************************************************************************
 
 //Outputs
-
+//*************************************************************************
 DigitalOut timetest_0 (p30);
 
-
 BusOut    unused(p18);
 
-
 //Inputs
-
-InterruptIn Drehzahl_lichtschranke(p29);
-
-Timer Umlaufzeit;
+//*************************************************************************
+AnalogIn DMS_sens (p17);
 
 //Communication
+//*************************************************************************
+int DMS_torque = 0;
 
 Serial pc(USBTX, USBRX);
 
-volatile int Drehzeit_counter = 0;
-#define DREHZEIT_SIZE 3
-volatile int Drehzeit[DREHZEIT_SIZE];
+//DMS-Abfrage
+//*************************************************************************
+void DMS_value()
+{
+DMS_torque =  DMS_sens.read_u16(); 
+}
+//*************************************************************************
 
 
-void Motor_drehzahl()
-{
-    timetest_0 = 1;
-    static bool first_run = true;
-    int tmp = Umlaufzeit.read_us();
-    if (first_run) {
-        Umlaufzeit.start();
-        first_run = false;
-        return;
-    }
-    if (tmp < 1000) return;
-
-    // Cache last 3 values for averaging
-    Drehzeit[Drehzeit_counter % DREHZEIT_SIZE] = tmp;
-    ++Drehzeit_counter;
-    Umlaufzeit.reset();
-    
-    timetest_0 = 0;
-}
-
+//Main
+//*************************************************************************
 int main(void)
 {
 
-
-    Drehzahl_lichtschranke.fall(&Motor_drehzahl);
-
-
     // Time counters
-    Timer timer_print;
-    timer_print.start();
-
-
-    float motor_n_cur = 0;
-
-
 
     while(true) {
 
-
-
-        // Calculate motor_n_cur by averaging
-        int drehzeit_sum = 0;
-        for (int i=0; i != DREHZEIT_SIZE; ++i)
-            drehzeit_sum += Drehzeit[i];
-
-        motor_n_cur = (drehzeit_sum ? (1.0e6/drehzeit_sum)*DREHZEIT_SIZE : 0.0)*60;
-
-
-        // Set motor_n_cur to 0 if the interrupt wasn't called for a specified time
-        if (Umlaufzeit.read_ms() > 200)
-            motor_n_cur = 0.0;
-
-        pc.printf("%f\n\r",motor_n_cur);
+DMS_value();
+      
+        pc.printf("%i\n\r",DMS_torque);
         
         wait(0.5);
     }