![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Kalibriersoftware Stromwerte
Diff: Pruefprogramm_Motorteststand.cpp
- Revision:
- 0:5e35c180ed4a
- Child:
- 1:ea5f520dcdc1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Pruefprogramm_Motorteststand.cpp Mon Nov 23 16:09:54 2015 +0000 @@ -0,0 +1,158 @@ +#include "mbed.h" +#include "Matrix.h" +#include "USBSerial.h" + +//*************************************************************************************************** +//Outputs + +DigitalOut Multiplex_select_A (p26); +DigitalOut Multiplex_select_B (p25); +DigitalOut Myled (LED1); + + +//*************************************************************************************************** +//Inputs + +AnalogIn Messkanal_X (p15); +AnalogIn Messkanal_Y (p16); +AnalogIn DMS_Kanal (p17); + +//DigitalIn Start(p22); + +//*************************************************************************************************** +//PWM + +PwmOut Motor(p23); +PwmOut Bremse(p21); + + + +//*************************************************************************************************** +//Communication + +Serial pc(USBTX, USBRX); + +//USBSerial terminal; + + +volatile float Motorspannung, Bremsenspannung , Motorstrom, An_In_0, Bremsenstrom, Temperatur_0, Temperatur_1, Temperatur_2, DMS_Out, DMS_Skalierung; + + +//*************************************************************************************************** +//read sensors via multiplexer + +void read_sensors() +{ + + Multiplex_select_A = 0; + Multiplex_select_B = 0; + wait_ms(1); + An_In_0 = Messkanal_X.read_u16(); + Motorspannung = Messkanal_Y.read_u16(); //* 0.000515 - 0.05 ; Gute Näherung von 2- ~23V. Dannach zu niedrig.Z-Diode + + Multiplex_select_A = 1; + wait_ms(1); + Temperatur_0 = Messkanal_X.read_u16(); + Motorstrom = Messkanal_Y.read_u16(); //* 0.000396 - 4.15; + + Multiplex_select_A = 0; + Multiplex_select_B = 1; + wait_ms(1); + Temperatur_1 = Messkanal_X.read_u16(); + Bremsenspannung = Messkanal_Y.read_u16(); //* 0.000515 - 0.05;Gute Näherung von 2- ~23V. Dannach zu niedrig.Z-Diode + + Multiplex_select_A = 1; + wait_ms(1); + Temperatur_2 = Messkanal_X.read_u16(); // 1629; + Bremsenstrom = Messkanal_Y.read_u16(); //* 0.00032 - 15.8; + +} + +//*************************************************************************************************** +//Safety Circuit + +int safety() +{ + int Temp_max; + read_sensors(); + + if( (Temperatur_0 < Temp_max) && (Temperatur_1 < Temp_max) && (Temperatur_2 < Temp_max)) + return(0); + else + return(1); + +} + +//*************************************************************************************************** +//Checkup @ Start + +int checkup() +{ + return(1); +} + + +//*************************************************************************************************** +//send values + +void send_data(void) +{ +// pc.printf(" [Temperatur1, Motorspannung]; 0 %5.2f deg; 1 %5.2f V;", Temperatur_0, Motorspannung); +// pc.printf(" [Temperatur2, Motorstrom]; 0 %5.2f deg; 1 %5.2f A;", Temperatur_1, Motorstrom); +// pc.printf(" [Temperatur3, Bremsenspannung]; 0 %5.2f deg; 1 %5.2f V;", Temperatur_2, Bremsenspannung); +// pc.printf(" [Aux, Bremsenstrom]; 0 %5.2f ; 1 %5.2f ;", An_In_0, Bremsenstrom); +// pc.printf(" [DMS-Kanal]; 0 %5.2f ;", DMS_Out); + pc.printf(" [Motorstrom, Bremsenstrom]; 0 %5.2f ; 1 %5.2f ;", Motorstrom, Bremsenstrom); + pc.printf(" \r\n\r\n"); + wait_ms(50); +} + + +//*************************************************************************************************** +// MAIN: + + + + +int main(void) +{ +//********************* VARIABLEN ***************************** + + DMS_Skalierung = 1; + Motor.period_us(200); + Bremse.period_us(200); + + + + +// Matrix Values(1,4); + + +//************************ MAIN ******************************** + + +while(true) + { + Motor.pulsewidth_us(0); + Bremse.pulsewidth_us(0); + read_sensors(); + send_data(); + + DMS_Out = DMS_Kanal.read_u16()*DMS_Skalierung; + + //safety(); + + + Myled=!Myled; + wait_ms(500); + + +//********************* Messprozedur **************************** +//********************* + + + + +} + +} \ No newline at end of file