예제 #1
0
        public Form_Settings(ATIM_MainWindow calling)
        {
            //Calling Form übernehmen um später auf die Settings zuzugreifen
            callingForm = calling;

            InitializeComponent();

            //ComboBox füllen
            ComboBox_Settings_DUT_Init();
            ComboBox_Settings_Frequency_Init();
            ComboBox_Settings_Range_Init();
        }
        //**************************************************************************************************
        //                                      Konstruktor
        //**************************************************************************************************

        public Window_Sensitivity_TempStepSelect(ATIM_MainWindow callingForm)
        {
            //Referenz für calling Form
            mainForm = callingForm as ATIM_MainWindow;

            //Fenster initialisieren
            InitializeComponent();

            //Liste aus Intiallwerten berechnen
            temperaturen = Calculate_TemperatureList();

            //Graph Updaten
            Update_Graph();

            //Zeit Updaten
            Update_Time();
        }
예제 #3
0
        /// <summary>
        /// Retruns true if no error occured while sending the settings
        /// </summary>
        public override bool Measure_Sensitivity(Sensitvity_Measurement mySensitivity, ATIM_MainWindow GUI)
        {
            //Mögliche Errors mitzählen
            uint error_Sum = 0;

            //Messung starten
            error_Sum += WaitTime_for_Trigger_inf();
            error_Sum += Adopt_Settings();
            error_Sum += Start_Card();
            error_Sum += Force_Trigger();

            //Daten abholen
            error_Sum += WaitTime_for_Trigger_inf();
            error_Sum += Wait_for_all_samples();

            //Datentransfer einstellen (Datapointer enspricht der Stelle des ersten Samples im Array)
            IntPtr aktuellerPointer = new IntPtr(Daten_Pointer.ToInt64());

            error_Sum += Send_Pointer_of_Array(aktuellerPointer, mySensitivity.Nr_of_samples);
            error_Sum += Get_Data();

            //Plot in Graph RAW
            GUI.Add_Series_to_RAW(mySensitivity);

            //Auf Errors checken
            if (error_Sum != 0)
            {
                MessageBox.Show("An Error occured while measurment!\n Look at LOG: .", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #4
0
        /// <summary>
        /// Retruns true if no error occured while sending the settings
        /// </summary>
        public override bool Measure_TTA_Several_Cycles_DEMO(TTA_measurement myTTA, ATIM_MainWindow GUI)
        {
            //StatusBar anpassen
            GUI.StatusBar_TTA_Single(0, (int)myTTA.MyRack.Cycles);

            //Plot für Single Curves initialsisiern
            //AsyncChart_single_Vf_init();

            //Mögliche Errors mitzählen
            uint error_Sum = 0;

            //1. Parameter für Messlänge senden********************************************************************************

            //Sample Anzahl berechnen (Heizplus + Messpuls + Puffer[alle in ms]) * Frequenz
            long samples = Decimal.ToInt64((myTTA.MyRack.Time_Heat + myTTA.MyRack.Time_Meas + 0.5m) / 1000 * Frequency);
            //Sampels nach Trigger berechnen (100µs davor)
            long postTriggerSamples = samples - Decimal.ToInt64(0.0001m * Frequency);

            //error_Sum += Set_Sample_Count(samples);
            //error_Sum += Set_Samples_PostTrigger(postTriggerSamples);


            //2. Feld für die Messdaten generiern******************************************************************************
            //Pointer und Händler für Datenfeld
            IntPtr   daten_Pointer;
            GCHandle hBufferHandle;

            //Zugehöriges Feld in Klasse TTA measurement erzeugen
            myTTA.Creat_RowDataField(samples);

            //Speicherplatz sperren
            hBufferHandle = GCHandle.Alloc(myTTA.Binary_Raw_Files, GCHandleType.Pinned);
            //Pointer für gesperten Speicherplatz suchen
            daten_Pointer = hBufferHandle.AddrOfPinnedObject();


            //Init Stability Check (weiß nicht wozu)
            //double stability_limit = 1; //1%
            //bool[] no_stability = new bool[3];
            //int[,] values_for_stability_check = new int[3, myTTA_Measurement.param.anzahl_Zyklen];

            //3. Messung starten************************************************************************************************
            for (int i = 0; i < myTTA.MyRack.Cycles; i++)
            {
                //Falls über Cancel abgebrochen wurde --> Speicher freigeben

                if (GUI.myBackroundWorker.CancellationPending)
                {
                    hBufferHandle.Free();
                    return(false);
                }


                //error_Sum += WaitTime_for_Trigger_inf();
                //error_Sum += Adopt_Settings();
                //error_Sum += Start_Card();
                //error_Sum += Wait_to_fill_PreTrigger();
                //error_Sum += Enable_Trigger();
                //error_Sum += Force_Trigger_after_time((long)myTTA.MyRack.Time_Heat);

                //Zählvariablen in Button hochzählen
                GUI.StatusBar_TTA_Single(i + 1, (int)myTTA.MyRack.Cycles);

                //System.Threading.Thread.Sleep((int)(myTTA.MyRack.Time_Heat + myTTA.MyRack.Time_Meas));
                System.Threading.Thread.Sleep(1000);

                //Stromquelle Pulsen
                //myTTA.MyRack.SinglePuls_withoutDelay();

                //Wurde ein Trigger Event gefunden (wenn nich Rückgabewert ist 263)

                /*if (Did_Trigger_Event_occured() == 263)
                 * {
                 *  //Fehlermeldung
                 *  //SetAsyncText(Spectrum_answer, "Kein Trigger gefunden");
                 *
                 *  error_Sum += 263;
                 *  error_Sum += Force_Trigger();
                 * }*/


                //4. Daten abholen**********************************************************************************************

                //WArten bis alle Daten vorhanden sind (unendlich lang möglich)
                //error_Sum += WaitTime_for_Trigger_inf();
                //error_Sum += Wait_for_all_samples();

                //Datentransfer einstellen (Datapointer enspricht der Stelle des ersten Samples im Array)
                //Bei weiteren Zyklen muss dieser Pointer geändert werden
                //DataPointer is [0,0]
                //anzahl_samples entspricht der Länge einer Zeile
                //2 ist notwendig für short (2byte)
                //i ist die aktuelle Zeile (Zyklus)

                IntPtr aktuellerPointer = new IntPtr(daten_Pointer.ToInt64() + 2 * i * samples);

                Random rnd = new Random();

                //Daten für Demo erzeugen
                int j      = 0;
                int help_t = 0;
                for (; j < 1000; j++)
                {
                    myTTA.Binary_Raw_Files[i, j] = -32767;
                }
                for (; j < samples / 2; j++)
                {
                    help_t++;
                    myTTA.Binary_Raw_Files[i, j] = (short)(10000 + 15000 * Math.Exp(-(double)help_t / 1500000) + rnd.Next(-100, 100));
                }
                help_t = 0;
                for (; j < samples - 1000; j++)
                {
                    help_t++;
                    myTTA.Binary_Raw_Files[i, j] = (short)(-10000 - 15000 * Math.Exp(-(double)help_t / 1500000) + rnd.Next(-100, 100));
                }
                for (; j < samples; j++)
                {
                    myTTA.Binary_Raw_Files[i, j] = -32767;
                }

                //error_Sum += Send_Pointer_of_Array(aktuellerPointer, samples);
                //error_Sum += Get_Data();


                //5. Auf Fehler prüfen*****************************************************************************************

                /*
                 * (Text in Antwortfenster ändern
                 * if (error_Sum == 0) { SetAsyncText(Spectrum_answer, "Measurement correct\r\n"); }
                 * else { SetAsyncText(Spectrum_answer, "Error while measurement\r\n"); }
                 */

                //Gleich in Graph ausgeben
                GUI.Add_Series_to_RAW(myTTA, i);

                //myTTA.ErrorCode = ErrorCheck_ShortOpen(myTTA, i);
                //Wenn Short oder Open --> Abbruch (keine weiteren Zyklen)
                //if (myTTA.ErrorCode != 0)
                //  break;
            }

            //Stabilitäts-Check
            //if (myTTA.ErrorCode == 0)
            //  myTTA.ErrorCode = ErrorCheck_Instabil(myTTA);

            hBufferHandle.Free();


            //Auf Errors checken
            if (error_Sum != 0)
            {
                MessageBox.Show("An Error occured while measurment!\n Error Code: ." + myTTA.ErrorCode.ToString(), "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #5
0
 public virtual decimal Get_Constant_Voltage(TTA_measurement myTTA, ATIM_MainWindow GUI)
 {
     return(0);
 }
예제 #6
0
 public virtual bool Measure_Sensitivity(Sensitvity_Measurement mySensitivity, ATIM_MainWindow GUI)
 {
     return(false);
 }
예제 #7
0
 public virtual bool Measure_TTA_Several_Cycles_DEMO(TTA_measurement myTTA, ATIM_MainWindow GUI)
 {
     return(false);
 }
예제 #8
0
        public override decimal Get_Constant_Voltage(TTA_measurement myTTA, ATIM_MainWindow GUI)
        {
            //Konstante Spannung über mehrere Samples messen



            //1. Daten-Felder definieren***************************************************************************************

            //Übergabe-Parameter für NI-Karte definieren
            IAsyncResult uebergabe_parameter_ReadWaveform_Constant = null;

            //Ausgangsdaten
            AnalogSingleChannelReader messInfo_NI_SinglePulse_Constant = null;

            // Task für Messung erzeugen
            NationalInstruments.DAQmx.Task myTask_NI_Constant = null;


            //2. NI-Karte scharf stellen***********************************************************************************
            try
            {
                myTask_NI_Constant = new NationalInstruments.DAQmx.Task("myTask_Constant");

                // Kanal erzeugen:
                //---------------------------------------------------------------------------------
                //physicalChannelName As String: z.B. Dev1/ai3
                //nameToAssignChannel As String: sollte leer bleiben (Zweck keine Ahnung)
                //terminalConfiguration As AITerminalConfiguration: Differential oder ähnlich
                //minimumValue As Double: z.B. -10 [V] untere Grenze
                //maximumValue As Double: z.B. 10 [V]
                //customScaleName As String:
                //---------------------------------------------------------------------------------
                myTask_NI_Constant.AIChannels.CreateVoltageChannel(VISA_or_Channel_Name, "",
                                                                   AITerminalConfiguration.Differential, -Range / 1000, Range / 1000, AIVoltageUnits.Volts);


                // Timing-Parameter definieren:
                //---------------------------------------------------------------------------------
                //signalSource As string: Wenn interne Clock verwendet wird ""
                //rate As double: Abtastfrequenz in Hz (Interne Clock)
                //activeEdge As SampleClockActiveEdge: Bei welcher Flanke der Clock abgetastet wird
                //sampleMode As SampleQuantityMode: Legt fest ob dauerhaft gemessen wird, oder bis
                //                                  nur eine endliche Anzahl (nächster Parameter)
                //samplesPerChannel As int: Anzahl der Samples
                //---------------------------------------------------------------------------------
                myTask_NI_Constant.Timing.ConfigureSampleClock("", Frequency, SampleClockActiveEdge.Rising,
                                                               SampleQuantityMode.FiniteSamples, (int)Frequency / 1000);


                // Trigger definieren
                //---------------------------------------------------------------------------------
                //Kein Trigger definieren --> Sofort starten
                //---------------------------------------------------------------------------------
                myTask_NI_Constant.Triggers.StartTrigger.ConfigureNone();

                //TimeOut anpassen
                myTask_NI_Constant.Stream.Timeout = 2000;

                // Verify the Task
                myTask_NI_Constant.Control(TaskAction.Verify);

                //Messwert-Ausgabe definieren
                messInfo_NI_SinglePulse_Constant = new AnalogSingleChannelReader(myTask_NI_Constant.Stream);

                // Use SynchronizeCallbacks to specify that the object
                // marshals callbacks across threads appropriately.
                messInfo_NI_SinglePulse_Constant.SynchronizeCallbacks = true;
                uebergabe_parameter_ReadWaveform_Constant             = messInfo_NI_SinglePulse_Constant.BeginReadWaveform((int)Frequency / 1000, null, null);
            }
            catch (DaqException ex)
            {
                //Bei Daq Exception soll die Fehlermeldung ausgegeben werden (z.B. kein Kanal, ...)
                MessageBox.Show(ex.Message);
                //Task beenden
                myTask_NI_Constant.Dispose();

                return(0);
            }


            //6. Daten auswerten*******************************************************************************************
            try
            {
                // vorhandene Daten auslesen
                AnalogWaveformSampleCollection <double> test = messInfo_NI_SinglePulse_Constant.EndReadWaveform(uebergabe_parameter_ReadWaveform_Constant).Samples;

                //Durchschnitt berechnen
                double average = 0;
                for (int counter = 0; counter < test.Count; counter++)
                {
                    average += test[counter].Value;
                }

                return((decimal)average / test.Count / myTTA.MyRack.Gain + myTTA.MyRack.U_offset / 1000);
            }
            catch (DaqException ex)
            {
                //Bei Fehler -> Fehlermeldung ausgeben (hier z.B. Timeout)
                MessageBox.Show(ex.Message);

                return(0);
            }
            finally
            {
                // Task beenden
                myTask_NI_Constant.Dispose();
            }
        }
예제 #9
0
 public override bool Measure_Sensitivity(Sensitvity_Measurement mySensitivity, ATIM_MainWindow GUI)
 {
     return(true);
 }
예제 #10
0
 public override bool Measure_TTA_Several_Cycles_DEMO(TTA_measurement myTTA, ATIM_MainWindow GUI)
 {
     return(true);
 }
예제 #11
0
        public override bool Measure_TTA_Several_Cycles(TTA_measurement myTTA, ATIM_MainWindow GUI)
        {
            //StatusBar anpassen
            GUI.StatusBar_TTA_Single(0, (int)myTTA.MyRack.Cycles);

            //1. Parameter für Messlänge senden********************************************************************************
            //Sampelzahl und Abtastfrequenz definieren (Times sind in ms deswegen /1000)
            int anzahl_samples = Convert.ToInt32(Frequency) / 1000
                                 * Decimal.ToInt32(myTTA.MyRack.Time_Heat + myTTA.MyRack.Time_Meas);
            //Sample überschuss, da Umschalten derzeit nicht richtig
            int sample_ueberschuss = 2000;

            //Trigger berechnen
            double trigger = decimal.ToDouble((numericUpDown_Trigger.Value - myTTA.MyRack.U_offset / 1000) * myTTA.MyRack.Gain);

            //2. Daten-Felder definieren***************************************************************************************

            //Übergabe-Parameter für NI-Karte definieren
            IAsyncResult uebergabe_parameter_ReadWaveform = null;

            //Ausgangsdaten
            AnalogSingleChannelReader messInfo_NI_SinglePulse = null;

            //Feld für Daten definieren (mit 100x max- beginnen)
            myTTA.Creat_RowDataField(100 + anzahl_samples + sample_ueberschuss);


            //3. Loop**********************************************************************************************************
            for (int i = 0; i < myTTA.MyRack.Cycles; i++)
            {
                //4. NI-Karte scharf stellen***********************************************************************************
                try
                {
                    // Task für Messung erzeugen
                    myTask_NI = new NationalInstruments.DAQmx.Task("myTask");


                    // Kanal erzeugen:
                    //---------------------------------------------------------------------------------
                    //physicalChannelName As String: z.B. Dev1/ai3
                    //nameToAssignChannel As String: sollte leer bleiben (Zweck keine Ahnung)
                    //terminalConfiguration As AITerminalConfiguration: Differential oder ähnlich
                    //minimumValue As Double: z.B. -10 [V] untere Grenze
                    //maximumValue As Double: z.B. 10 [V]
                    //customScaleName As String:
                    //---------------------------------------------------------------------------------
                    myTask_NI.AIChannels.CreateVoltageChannel(VISA_or_Channel_Name, "",
                                                              AITerminalConfiguration.Differential, -Range / 1000, Range / 1000, AIVoltageUnits.Volts);


                    // Timing-Parameter definieren:
                    //---------------------------------------------------------------------------------
                    //signalSource As string: Wenn interne Clock verwendet wird ""
                    //rate As double: Abtastfrequenz in Hz (Interne Clock)
                    //activeEdge As SampleClockActiveEdge: Bei welcher Flanke der Clock abgetastet wird
                    //sampleMode As SampleQuantityMode: Legt fest ob dauerhaft gemessen wird, oder bis
                    //                                  nur eine endliche Anzahl (nächster Parameter)
                    //samplesPerChannel As int: Anzahl der Samples
                    //---------------------------------------------------------------------------------
                    myTask_NI.Timing.ConfigureSampleClock("", Frequency, SampleClockActiveEdge.Rising,
                                                          SampleQuantityMode.FiniteSamples, anzahl_samples + sample_ueberschuss);


                    // Trigger definieren
                    //---------------------------------------------------------------------------------
                    //source As String: Herkuft des Triggers. Hier gleich wie Daten (Dev1/ai3)
                    //slope As AnalogEdgeStartTriggerSlope: Rising or Falling
                    //level As Double: Trigger Level (vorher bestimmt
                    //---------------------------------------------------------------------------------
                    myTask_NI.Triggers.StartTrigger.ConfigureAnalogEdgeTrigger(VISA_or_Channel_Name,
                                                                               AnalogEdgeStartTriggerSlope.Rising, trigger);


                    //Hysterese festlegen (keine Ahnung ob das Wichtig ist)
                    //---------------------------------------------------------------------------------
                    //Hysteresis as Double: Wert der Hysterese
                    //---------------------------------------------------------------------------------
                    myTask_NI.Triggers.StartTrigger.AnalogEdge.Hysteresis = 0.05;

                    //TimeOut anpassen
                    myTask_NI.Stream.Timeout = (Int32)(1.2m * (myTTA.MyRack.Time_Heat + myTTA.MyRack.Time_Meas));

                    // Verify the Task
                    myTask_NI.Control(TaskAction.Verify);

                    //Messwert-Ausgabe definieren
                    messInfo_NI_SinglePulse = new AnalogSingleChannelReader(myTask_NI.Stream);

                    // Use SynchronizeCallbacks to specify that the object
                    // marshals callbacks across threads appropriately.
                    messInfo_NI_SinglePulse.SynchronizeCallbacks = true;
                    uebergabe_parameter_ReadWaveform             = messInfo_NI_SinglePulse.BeginReadWaveform(anzahl_samples + sample_ueberschuss, null, null);
                }
                catch (DaqException ex)
                {
                    //Bei Daq Exception soll die Fehlermeldung ausgegeben werden (z.B. kein Kanal, ...)
                    MessageBox.Show(ex.Message);
                    //Task beenden
                    myTask_NI.Dispose();
                }

                //5. Puls starten**********************************************************************************************
                System.Threading.Thread.Sleep(300);
                myTTA.MyRack.SinglePuls_withDelay();
                System.Threading.Thread.Sleep(1000);

                //6. Daten auswerten*******************************************************************************************
                try
                {
                    // vorhandene Daten auslesen
                    AnalogWaveformSampleCollection <double> test = messInfo_NI_SinglePulse.EndReadWaveform(uebergabe_parameter_ReadWaveform).Samples;


                    double factor = Math.Pow(2, 15) / (Range / 1000);
                    //Mit 100mal Minimalwert beginnen. (Für umschaltpunkt suche)
                    for (int counter = 0; counter < 100; counter++)
                    {
                        myTTA.Binary_Raw_Files[i, counter] = short.MinValue;
                    }
                    //Daten in Binär (short umrechnen) & TTA übergeben
                    for (int counter = 100; counter < test.Count; counter++)
                    {
                        double helping_Double = test[counter].Value * factor;
                        myTTA.Binary_Raw_Files[i, counter] = (short)(helping_Double);
                    }

                    //Gleich in Graph ausgeben
                    GUI.Add_Series_to_RAW(myTTA, i);
                }
                catch (DaqException ex)
                {
                    //Bei Fehler -> Fehlermeldung ausgeben (hier z.B. Timeout)
                    MessageBox.Show(ex.Message);

                    return(false);
                }
                finally
                {
                    // Task beenden
                    myTask_NI.Dispose();
                }

                //7. StatusBar anpassen****************************************************************************************
                GUI.StatusBar_TTA_Single(i + 1, (int)myTTA.MyRack.Cycles);
            }
            return(true);
        }