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:
Mon Sep 08 12:15:43 2014 +0000
Parent:
0:42c1addaf061
Child:
2:d815250d0377
Commit message:
080920141415; cleaned up

Changed in this revision

Multiplexer_read.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Multiplexer_read.cpp	Mon Sep 08 12:11:21 2014 +0000
+++ b/Multiplexer_read.cpp	Mon Sep 08 12:15:43 2014 +0000
@@ -3,7 +3,7 @@
 #include "USBSerial.h"
 
 #include "EthernetInterface.h"
-
+//***************************************************************************************************
 //Outputs
 
 DigitalOut Multiplex_select_0 (p15);
@@ -16,7 +16,7 @@
 
 BusOut    unused(p18);
 
-
+//***************************************************************************************************
 //Inputs
 
 InterruptIn Drehzahl_lichtschranke(p14);
@@ -29,7 +29,7 @@
 AnalogIn DMS_0 (p17);
 
 
-
+//***************************************************************************************************
 //Communication
 
 Serial pc(USBTX, USBRX);
@@ -46,79 +46,10 @@
 volatile int Drehzeit_counter = 0;
 #define DREHZEIT_SIZE 3
 volatile int Drehzeit[DREHZEIT_SIZE];
-
-
-/*
-int Read_sensors(void)
-{
-
-    int  select_0 = 0, select_1 = 0, Messwert_0, Messwert_1,i = 0;
-
-    Multiplex_select_0 = 0, Multiplex_select_1 = 0;
-
-    //Selection of Multiplexer states
-
-
-//  for(i=0; i<=3; i++)
-
-    while(i<4)
-
-    {
-        select_0 = Multiplex_select_0;
-        select_1 = Multiplex_select_1;
-
-        Messwert_0 = Messkanal_0.read_u16();
-        Messwert_1 = Messkanal_1.read_u16();
-
-        switch(i) {
-            case 0: {
-                Temperatur_0 = Messwert_0;
-                Motorspannung = Messwert_1 * 0.000515 - 0.05 ; //Gute Näherung von 2- ~23V. Dannach zu niedrig.Z-Diode
-                pc.printf(" [%i,%i]; 0 %5.2f deg; 1 %5.2f V;", select_0, select_1, Temperatur_0, Motorspannung);
-                break;
-            }
+//***************************************************************************************************
 
-            case 1: {
-                Temperatur_1 = Messwert_0;
-                Motorstrom = Messwert_1 * 0.000396 - 4.15;
-                pc.printf(" [%i,%i]; 0 %5.2f deg; 1 %5.2f A;", select_0, select_1, Temperatur_1, Motorstrom);
-                break;
-            }
-
-            case 2: {
-                Temperatur_2 = Messwert_0;
-                Bremsenspannung = Messwert_1 * 0.000515 - 0.05;//Gute Näherung von 2- ~23V. Dannach zu niedrig.Z-Diode
-                pc.printf(" [%i,%i]; 0 %5.2f deg; 1 %5.2f V;", select_0, select_1, Temperatur_2, Bremsenspannung);
-                break;
-            }
-
-            case 3: {
-                Aux = Messwert_0;
-                Bremsenstrom = Messwert_1;// * 0.00032 - 15.8;
-                pc.printf(" [%i,%i]; 0 %5.2f NA; 1 %5.2f A;", select_0, select_1, Aux, Bremsenstrom);
-                break;
-            }
-
-            default: {
-                //i =0;
-                pc.printf("\n\r");
-                break;
-            }
-
-
-
-        }
-
-        wait(0.001);
-        i++;
-        Multiplex_select_0 = i&0x01;
-        Multiplex_select_1 = (i>>1)&0x01;
-
-    }
-
-    return 1;
-}
-*/
+//***************************************************************************************************
+//read sensors via multiplexer
 
 void interr_read_sensors()
 {
@@ -181,8 +112,10 @@
     }
     
 }
+//***************************************************************************************************
 
-
+//***************************************************************************************************
+//Control Motor rpm 
 
 int rpm_control(float motor_n_cmd, float motor_n_cur)
 {
@@ -214,7 +147,10 @@
     return 1;
 
 }
+//***************************************************************************************************
 
+//***************************************************************************************************
+//Control MOSFET pwm
 int brk_mosfet_control(float mosfet_pwm_cmd, float mosfet_pwm_cur)
 {
       
@@ -244,7 +180,10 @@
 
     return 1;
 }
+//***************************************************************************************************
 
+//***************************************************************************************************
+//Calculate rpm
 void Motor_drehzahl()
 {
     static bool first_run = true;
@@ -258,7 +197,10 @@
     ++Drehzeit_counter;
     Umlaufzeit.reset();
 }
+//***************************************************************************************************
 
+//***************************************************************************************************
+// MAIN:
 int main(void)
 {
     // Init networking