#include #include #include #include #include #include "Stepsweep.h" /* FUNKTIES */ void StartComInstr (void); // Start GPIB & initialiseer scoop en funktiegenerator void StopComInstr (void); // Stop GPIB communicatie void SetupLeCroy (void); // Instellingen schrijven naar scoop void SetupAgilent (void); // Instellingen schrijven naar funktiegenerator void FreqExp (void); // Bereken eerste frequentie exponent genoteerde waarde void FreqNext (void); // Bereken volgende frequentie void CustPara (int, int, int, int); // Instellen custom parameters void CustMath (int, int, int, int); // Instellen math traces void Check_actief (void); // Bepaal actieve kanalen en traces void Check_para (int, int, int); // Actieve kanalen en traces -record parameters- void Check_math (int, int, int); // Actieve kanalen en traces -math traces- void RunMeting (void); // De meting void Acquisition (void); // Acquisition en Autorange int Autorange_x1 (int, int); // Autorange scoopkanaal voor onbekende 1:1 probe int Autorange_PP006 (int, int); // Autorange scoopkanaal voor PP006 1:10 probe int Autorange_ADP305 (int, int);// Autorange scoopkanaal voor ADP305 differential probe int Autorange_AP015 (int, int); // Autorange scoopkanaal voor AP015 stroomprobe /* PANELS */ static int connpanel; static int steppanel; static int scooppanel; static int funkpanel; static int meetpanel; /* GLOBAL VARIABELEN */ char *pp; char *pq; char *pverz; double e_freq; // exponent meetfrequentie int CH1probesoort; int CH2probesoort; int CH3probesoort; int CH4probesoort; // identiteit probes int CH1verz; int CH2verz; int CH3verz; int CH4verz; // probes verzwakking int CH1actief; int CH2actief; int CH3actief; int CH4actief; // actieve kanalen int TRAactief; int TRBactief; int TRCactief; int TRDactief; // actieve traces ViSession defaultRM, Agilent; // Kweetniet (err. routines) ViSession defaultRM, LeCroy; // Kweetniet (err. routines) // Files int filerij; int filecol; static char filenaam[MAX_PATHNAME_LEN]; static double filedata[10000]; static int ferr; // hu? static char ftemp[40]; // hu? // Macros (Mooi jatwerk, maar waar het voor dient?) error_check(char *ftemp, int ferr); /***************************************************************/ /* MAIN STEPSWEEP */ /***************************************************************/ int main (int argc, char *argv[]) { if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if ((steppanel = LoadPanel (0, "Stepsweep.uir", STEPPANEL)) < 0) return -1; if ((connpanel = LoadPanel (0, "Stepsweep.uir", CONNPANEL)) < 0) return -1; if ((scooppanel = LoadPanel (0, "Stepsweep.uir", SCOPEPANEL)) < 0) return -1; if ((funkpanel = LoadPanel (0, "Stepsweep.uir", FUNKPANEL)) < 0) return -1; if ((meetpanel = LoadPanel (0, "Stepsweep.uir", MEETPANEL)) < 0) return -1; DisplayPanel (steppanel); InstallPopup (connpanel); RunUserInterface (); DiscardPanel (steppanel); return 0; } /***************************************************************/ /* FUNKTIES */ /***************************************************************/ /*-----------*/ /* DE METING */ /*-----------*/ void RunMeting () { char *time_div[] = {"1E-9","2E-9","5E-9","1E-8","2E-8","5E-8","1E-7","2E-7","5E-7","1E-6","2E-6","5E-6", "1E-5","2E-5","5E-5","1E-4","2E-4","5E-4","1E-3","2E-3","5E-3","1E-2","2E-2","5E-2","1E-1", "2E-1","5E-1","1E0","2E0","5E0","1E1","2E1","5E1","1E2","2E2","5E2","1E3","2E3","5E3"}; double decimaal; double voorvoegsel; double frequentie; double freqmeet; double T_div; int ptdiv; char antwoord[100]; char textline[100]; int firstm; int pararec; double param1; double param2; double param3; double param4; char statusline[40]; strcpy (textline, "\n"); ResetTextBox (meetpanel, MEETPANEL_TEXTBOX, textline); strcpy (statusline, "\n"); ResetTextBox (meetpanel, MEETPANEL_CONTROLE, statusline); // Status sprintf (statusline, "Start meting\n"); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); sprintf (statusline, "Actief\n CH1:%d\n CH2:%d\n CH3:%d\n CH4:%d\n", CH1actief, CH2actief, CH3actief, CH4actief); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); sprintf (statusline, "Actief\n TRA:%d\n TRB:%d\n TRC:%d\n TRD:%d\n", TRAactief, TRBactief, TRCactief, TRDactief); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); filerij = 0; // Elementteller voor file op nul firstm = 0; do { filecol = 0; // Kollomteller voor file op nul /*** Frequentie instelling funktiegenerator ***/ if (firstm != 0) FreqNext (); firstm++; frequentie = pow (10, e_freq); if (frequentie > 80E6) frequentie = 80E6; viPrintf (Agilent, "FREQ %lf\n", frequentie); // Status sprintf (statusline, "%d Set freq. %g\n", firstm, frequentie); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); /*** Tijdbasis instelling scoop ***/ ptdiv = 0; do { sscanf (time_div[ptdiv], "%lf", &T_div); ptdiv++; }while (5/(10*frequentie) > T_div); // Aantal perioden op scoop scherm viPrintf (LeCroy, "Time_DIV %s\n",time_div[--ptdiv]); // Status sprintf (statusline, "%d Set timebase %s\n", firstm, time_div[--ptdiv]); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); /*** Contoleer frequentie setting generator ***/ do { viQueryf (Agilent, "FREQ?\n","%t",antwoord); pp = antwoord; sscanf (pp, "%lf", &freqmeet); freqmeet = frequentie / freqmeet; }while (freqmeet > 1.001 || freqmeet < 0.999); /*** Acquisition en Autorange ***/ Acquisition (); /*** Lees meetwaarden ***/ /* Frequentie */ GetCtrlVal (steppanel, STEPPANEL_BUTGENFREQ, ¶rec); if (pararec == 1) { // Vraag meetwaarde viQueryf (Agilent, "FREQ?\n","%t",antwoord); pp = antwoord; sscanf (pp, "%lf", &freqmeet); // Meetwaarde naar tekstvak sprintf (textline,"%11.2f ", freqmeet); SetCtrlVal (meetpanel, MEETPANEL_TEXTBOX, textline); // Meetwaarde naar outputfile filedata[filerij] = freqmeet; filerij++; filecol++; // Status sprintf (statusline, "%d Meet freq. %g\n", firstm, freqmeet); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); } /* Parameter 1 */ GetCtrlVal (steppanel, STEPPANEL_PARAMETER1, ¶rec); if (pararec != 0) { // Vraag meetwaarde viQueryf (LeCroy, "PAVA? CUST1\n","%t",antwoord); pp = strstr (antwoord, ","); sscanf (pp+1, "%lf", ¶m1); // Meetwaarde naar tekstvak sprintf (textline,"%8.4f ", param1); SetCtrlVal (meetpanel, MEETPANEL_TEXTBOX, textline); // Meetwaarde naar outputfile filedata[filerij] = param1; filerij++; filecol++; // Status sprintf (statusline, "%d Meet para1 %g\n", firstm, param1); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); } /* Parameter 2 */ GetCtrlVal (steppanel, STEPPANEL_PARAMETER2, ¶rec); if (pararec != 0) { // Vraag meetwaarde viQueryf (LeCroy, "PAVA? CUST2\n","%t",antwoord); pp = strstr (antwoord, ","); sscanf (pp+1, "%lf", ¶m2); // Meetwaarde naar tekstvak sprintf (textline,"%8.4f ", param2); SetCtrlVal (meetpanel, MEETPANEL_TEXTBOX, textline); // Meetwaarde naar outputfile filedata[filerij] = param2; filerij++; filecol++; // Status sprintf (statusline, "%d Meet para2 %g\n", firstm, param2); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); } /* Parameter 3 */ GetCtrlVal (steppanel, STEPPANEL_PARAMETER3, ¶rec); if (pararec != 0) { // Vraag meetwaarde viQueryf (LeCroy, "PAVA? CUST3\n","%t",antwoord); pp = strstr (antwoord, ","); sscanf (pp+1, "%lf", ¶m3); // Meetwaarde naar tekstvak sprintf (textline,"%8.4f ", param3); SetCtrlVal (meetpanel, MEETPANEL_TEXTBOX, textline); // Meetwaarde naar outputfile filedata[filerij] = param3; filerij++; filecol++; // Status sprintf (statusline, "%d Meet para3 %g\n", firstm, param3); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); } /* Parameter 4 */ GetCtrlVal (steppanel, STEPPANEL_PARAMETER4, ¶rec); if (pararec != 0) { // Vraag meetwaarde viQueryf (LeCroy, "PAVA? CUST4\n","%t",antwoord); pp = strstr (antwoord, ","); sscanf (pp+1, "%lf", ¶m4); // Meetwaarde naar tekstvak sprintf (textline,"%8.4f ", param4); SetCtrlVal (meetpanel, MEETPANEL_TEXTBOX, textline); // Meetwaarde naar outputfile filedata[filerij] = param4; filerij++; filecol++; // Status sprintf (statusline, "%d Meet para4 %g\n", firstm, param4); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); } /*** Eind regel tekstvak ***/ SetCtrlVal (meetpanel, MEETPANEL_TEXTBOX, "\n"); /*** Controle: eindfrequentie bereikt? ***/ GetCtrlVal (steppanel, STEPPANEL_STOPDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_STOPDVV, &voorvoegsel); } while (pow (10, e_freq) < (decimaal * voorvoegsel)); // Status sprintf (statusline, "Eind Meting\n"); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); SetCtrlAttribute (meetpanel, MEETPANEL_SAVEBUTTON, ATTR_DIMMED, 0); return; } /*-------------------------*/ /* ACQUISITION & AUTORANGE */ /*-------------------------*/ void Acquisition () /* Singel triggering acquisition en autorange */ { int inr_nummer; // Scoop status int inr_add; // Bijhouden scoop status int inr_cont; // Controlegetal scoop status int overflow; // Overflow teller int oud; // Oude instelling char antwoord[100]; // Antwoord scoop static int pCH1 = 8; // pointer gevoeligheid CH1 static int pCH2 = 8; // pointer gevoeligheid CH2 static int pCH3 = 8; // pointer gevoeligheid CH3 static int pCH4 = 8; // pointer gevoeligheid CH4 char statusline[40]; // Status sprintf (statusline, " Start Acquisition\n"); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); do { /*** Reset Average ***/ //viPrintf (LeCroy, "TA:Funktion_ReSeT\n"); //viPrintf (LeCroy, "TB:Funktion_ReSeT\n"); //viPrintf (LeCroy, "TC:Funktion_ReSeT\n"); //viPrintf (LeCroy, "TD:Funktion_ReSeT\n"); /*** Arm oscilloscoop ***/ // Status sprintf (statusline, " Arm triggering\n"); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); viPrintf (LeCroy, "ARM_acquisition\n"); /*** Scoop acquisition afgerond? ***/ inr_add =0; inr_cont = 1; if (TRAactief == 1) inr_cont |= 2; if (TRBactief == 1) inr_cont |= 4; if (TRCactief == 1) inr_cont |= 8; if (TRDactief == 1) inr_cont |= 16; do { viQueryf (LeCroy, "INR?\n","%t",antwoord); // Vraag scoop-status (INR) pp = strstr (antwoord, "INR"); // Extract de status pp = pp + 4; sscanf (pp, "%d", &inr_nummer); if ((inr_nummer & 1) != 0) inr_add |= 1; // check: acquisitie if ((inr_nummer & 256) != 0 && TRAactief == 1) inr_add |= 2; // check: filedataform processing TA if ((inr_nummer & 512) != 0 && TRBactief == 1) inr_add |= 4; // check: filedataform processing TB if ((inr_nummer & 1024) != 0 && TRCactief == 1) inr_add |= 8; // check: filedataform processing TC if ((inr_nummer & 2048) != 0 && TRDactief == 1) inr_add |= 16; // check: filedataform processing TD // Begin Status sprintf (statusline, " INR controle: %d %d\n", inr_add, inr_cont); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); if ((inr_add & 1) != 0) {sprintf (statusline, " Acqusition OK\n"); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline);} if ((inr_add & 2) != 0) {sprintf (statusline, " TRA filedataform pross. OK\n"); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline);} if ((inr_add & 4) != 0) {sprintf (statusline, " TRB filedataform pross. OK\n"); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline);} if ((inr_add & 8) != 0) {sprintf (statusline, " TRB filedataform pross. OK\n"); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline);} if ((inr_add & 16) != 0) {sprintf (statusline, " TRB filedataform pross. OK\n"); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline);} // Eind Status }while (inr_add != inr_cont); /*** Veranderd autorange gevoeligheid instelling? ***/ overflow = 0; if (CH1actief == 1) { oud = pCH1; switch (CH1probesoort) { case 0: pCH1 = Autorange_x1 (1, pCH1); break; case 1: pCH1 = Autorange_PP006 (1, pCH1); break; case 2: pCH1 = Autorange_ADP305 (1, pCH1); break; case 3: pCH1 = Autorange_AP015 (1, pCH1); break; } if (oud != pCH1) overflow++; // Als instelling veranderd: Verhoog overflow. // Status sprintf (statusline, " CH1 sense pointer: %d %d\n", oud, pCH1); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); } if (CH2actief == 1) { oud = pCH2; switch (CH2probesoort) { case 0: pCH2 = Autorange_x1 (2, pCH2); break; case 1: pCH2 = Autorange_PP006 (2, pCH2); break; case 2: pCH2 = Autorange_ADP305 (2, pCH2); break; case 3: pCH2 = Autorange_AP015 (2, pCH2); break; } if (oud != pCH2) overflow++; // Als instelling veranderd: Verhoog overflow. // Status sprintf (statusline, " CH2 sense pointer: %d %d\n", oud, pCH2); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); } if (CH3actief == 1) { oud = pCH3; switch (CH3probesoort) { case 0: pCH3 = Autorange_x1 (3, pCH3); break; case 1: pCH3 = Autorange_PP006 (3, pCH3); break; case 2: pCH3 = Autorange_ADP305 (3, pCH3); break; case 3: pCH3 = Autorange_AP015 (3, pCH3); break; } if (oud != pCH3) overflow++; // Als instelling veranderd: Verhoog overflow. // Status sprintf (statusline, " CH3 sense pointer: %d %d\n", oud, pCH3); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); } if (CH4actief == 1) { oud = pCH4; switch (CH4probesoort) { case 0: pCH4 = Autorange_x1 (4, pCH4); break; case 1: pCH4 = Autorange_PP006 (4, pCH4); break; case 2: pCH4 = Autorange_ADP305 (4, pCH4); break; case 3: pCH4 = Autorange_AP015 (4, pCH4); break; } if (oud != pCH4) overflow++; // Als instelling veranderd: Verhoog overflow. // Status sprintf (statusline, " CH4 sense pointer: %d %d\n", oud, pCH4); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); } }while (overflow != 0); return; } /*-------------------------------------------*/ /* AUTORANGE SCOOPKANAAL ONBEKENDE 1:1 PROBE */ /*-------------------------------------------*/ int Autorange_x1 (kan, yarr) /* Stel de ingangsgevoeligheid van het gegeven scoopkanaal aan de hand van de laatste meting optimaal in. Tijdens het instellen mogen geen nieuwe triggeringen voorkomen. Deze routine stelt de verzwakker slechts één stap verder in. De nieuwe verzwakker array pointer wordt teruggegeven */ //int kan; Scoop kanaal: (1, 2, 3, 4) //int yarr; Pointer werkelijke gevoeligheid V/div { char *yd[] = {"2E-3","5E-3","1E-2","2E-2","5E-2","1E-1","2E-1","5E-1","1E0","2E0","5E0","1E1"}; // Array instelling verzwakker char antwoord[100]; // Antwoord scoop char *psaw; // Pointer antwoord scoop double ymax; // Ontvangen maximum waarde double ymin; // Ontvangen minimum waarde double ydiv; // floatwaarde verzwakkerinstelling char statusline[40]; viQueryf (LeCroy, "C%d:PAVA? MAX,MIN\n","%t",kan, antwoord); // Vraag gemeten minimum en maximum waarde psaw = strstr (antwoord, "MAX"); // Zoek "MAX" sscanf (psaw+4, "%lf", &ymax); // Lees maximum waarde die achter "MAX staat psaw = strstr (antwoord, "OK,"); // Zoek "OK" if (psaw == 0) // Als "OK" niet is gevonden: Overflow { if (yarr < 11) yarr++; // Indien ongevoeligste bereik nog niet ingesteld: ongevoeliger instellen } else // Als "OK" wel is gevonden (geen overflow) { psaw = strstr (antwoord, "MIN"); // Zoek "MIN" sscanf (psaw+4, "%lf", &ymin); // Lees minimum waarde die achter "MIN" staat if (yarr > 0) // Is gevoeligste bereik al ingesteld? { sscanf (yd[yarr-1], "%lf", &ydiv); // Lees volgende gevoeliger verzwakkerstand in als floatwaarde if ((ydiv * 3.5) > ymax && (ydiv * -3.5) < ymin) yarr--; // Als gevoeligheid groter wordt ingesteld zou dan een overflow kunnen ontstaan? } } viPrintf (LeCroy, "C%d:Volt_DIV %s\n",kan, yd[yarr]); // stuur naar scoop. // Status sprintf (statusline, " Probe 1op1 CH%d: %s V/div\n", kan, yd[yarr]); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); return yarr; // Nieuwe verzwakkerinstelling terugsturen. } /*----------------------------------------*/ /* AUTORANGE SCOOPKANAAL 1:10 PROBE PP006 */ /*----------------------------------------*/ int Autorange_PP006 (kan, yarr) /* Stel de ingangsgevoeligheid van het gegeven scoopkanaal aan de hand van de laatste meting optimaal in. Tijdens het instellen mogen geen nieuwe triggeringen voorkomen. Deze routine stelt de verzwakker slechts één stap verder in. De nieuwe verzwakker array pointer wordt teruggegeven */ //int kan; Scoop kanaal: (1, 2, 3, 4) //int yarr; Pointer werkelijke gevoeligheid V/div { char *yd[] = {"2E-3","5E-3","1E-2","2E-2","5E-2","1E-1","2E-1","5E-1","1E0","2E0","5E0","1E1","2E1","5E1","1E2"}; // Array instelling verzwakker char antwoord[100]; // Antwoord scoop char *psaw; // Pointer antwoord scoop double ymax; // Ontvangen maximum waarde double ymin; // Ontvangen minimum waarde double ydiv; // floatwaarde verzwakkerinstelling char statusline[40]; double test; viQueryf (LeCroy, "C%d:PAVA? MAX,MIN\n","%t",kan, antwoord); // Vraag gemeten minimum en maximum waarde psaw = strstr (antwoord, "MAX"); // Zoek "MAX" sscanf (psaw+4, "%lf", &ymax); // Lees maximum waarde die achter "MAX staat psaw = strstr (antwoord, "OK,"); // Zoek "OK" if (psaw == 0) // Als "OK" niet is gevonden: Overflow { if (yarr < 14) yarr++; // Indien ongevoeligste bereik nog niet ingesteld: ongevoeliger instellen } else // Als "OK" wel is gevonden (geen overflow) { psaw = strstr (antwoord, "MIN"); // Zoek "MIN" sscanf (psaw+4, "%lf", &ymin); // Lees minimum waarde die achter "MIN" staat if (yarr > 3) // Is gevoeligste bereik al ingesteld? { sscanf (yd[yarr-1], "%lf", &ydiv); // Lees volgende gevoeliger verzwakkerstand in als floatwaarde if ((ydiv * 3.5) > ymax && (ydiv * -3.5) < ymin) // Als gevoeligheid groter wordt ingesteld zou dan een overflow kunnen ontstaan? { yarr--; // Zo nee, gevoeligheid vergroten... } } } viPrintf (LeCroy, "C%d:Volt_DIV %s\n",kan, yd[yarr-3]); // ...en stuur naar scoop // Status sprintf (statusline, " Probe PP006, CH%d: %s V/div\n", kan, yd[yarr]); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); //sscanf (yd[yarr], "%lf", &test); //sprintf (statusline, ">MIN: %g\n>MAX: %g\n>Vdiv %g\n", ymin, ymax, test); //SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); return yarr; // Nieuwe verzwakkerinstelling terugsturen. } /*------------------------------------------------*/ /* AUTORANGE SCOOPKANAAL DIFFERENTIALPROBE ADP305 */ /*------------------------------------------------*/ int Autorange_ADP305 (kan, yarr) /* Stel de ingangsgevoeligheid van het gegeven scoopkanaal aan de hand van de laatste meting optimaal in. Tijdens het instellen mogen geen nieuwe triggeringen voorkomen. Deze routine stelt de gevoeligheid slechts één stap verder in. De nieuwe gevoeligheids array pointer wordt teruggegeven */ //int kan; Scoop kanaal: (1, 2, 3, 4) //int yarr; Pointer werkelijke gevoeligheid V/div { char *yd[] = {"2E-3","5E-3","1E-2","2E-2","5E-2","1E-1","2E-1","5E-1","1E0","2E0","5E0","1E1","2E1","5E1","1E2","2E2","350","350E-3"}; // Array instelling gevoeligheid char antwoord[100]; // Antwoord scoop char *psaw; // Pointer antwoord scoop double ymax; // Ontvangen maximum waarde double ymin; // Ontvangen minimum waarde double ydiv; // floatwaarde gevoeligheidinstelling int verzwakker; // verzwakker instelling int gevoeligheid; // pointer gevoeligheid char statusline[40]; viQueryf (LeCroy, "C%d:PAVA? MAX,MIN\n","%t",kan, antwoord); // Vraag Cx minimum en maximum waarde psaw = strstr (antwoord, "MAX"); // Zoek "MAX" sscanf (psaw+4, "%lf", &ymax); // Lees maximum waarde die achter "MAX staat psaw = strstr (antwoord, "OK,"); // Zoek "OK" if (psaw == 0) // Als "OK" niet is gevonden: Overflow /*** Schakel naar ongevoeliger bereik ***/ { if (yarr < 16) yarr++; // Als ongevoeligste bereik nog niet is bereikt: ongevoeliger instellen. } else // Als "OK" wel is gevonden (geen overflow) /*** Test gevoeliger bereik ***/ { psaw = strstr (antwoord, "MIN"); // Zoek "MIN" sscanf (psaw+4, "%lf", &ymin); // Lees minimum waarde die achter "MIN" staat if (yarr > 6) // Is gevoeligste bereik al ingesteld? { sscanf (yd[yarr-1], "%lf", &ydiv); // Lees volgende gevoeliger stand in als floatwaarde if ((ydiv * 3.5) > ymax && (ydiv * -3.5) < ymin) yarr--; // Indien test geen overflow veroorzaakt: gevoeliger instellen. } } /*** Schrijf gevoeligheid en verzwakkerstand naar scoop ***/ if (yarr <= 10) {gevoeligheid = yarr - 6; verzwakker = 100;} else if (yarr <= 16) {gevoeligheid = yarr - 9; verzwakker = 1000;} else {gevoeligheid = 17; verzwakker = 1000;} viPrintf (LeCroy, "C%d:ATTeNuation %d\n",kan, verzwakker); // Stuur verzwakker en viPrintf (LeCroy, "C%d:Volt_DIV %s\n",kan, yd[gevoeligheid]); // gevoeligheidinstelling naar scoop. // Status sprintf (statusline, " Probe ADP305, CH%d: %s V/div\n", kan, yd[yarr]); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); return yarr; // Nieuwe gevoeligheid instelling terugsturen. } /*-----------------------------------------*/ /* AUTORANGE SCOOPKANAAL STROOMPROBE AP015 */ /*-----------------------------------------*/ int Autorange_AP015 (kan, yarr) /* Stel de ingangsgevoeligheid van het gegeven scoopkanaal aan de hand van de laatste meting optimaal in. Tijdens het instellen mogen geen nieuwe triggeringen voorkomen. Deze routine stelt de gevoeligheid slechts één stap verder in. De nieuwe gevoeligheids array pointer wordt teruggegeven */ //int kan; Scoop kanaal: (1, 2, 3, 4) //int yarr; Pointer werkelijke gevoeligheid A/div { char *yd[] = {"1E-2","2E-2","5E-2","1E-1","2E-1","5E-1","1E0","2E0","5E0","1E1","2E1","5E1"}; // Array instelling gevoeligheid char antwoord[100]; // Antwoord scoop char *psaw; // Pointer antwoord scoop double ymax; // Ontvangen maximum waarde double ymin; // Ontvangen minimum waarde double ydiv; // floatwaarde gevoeligheidinstelling int verzwakker; // verzwakker instelling int gevoeligheid; // pointer gevoeligheid char statusline[40]; viQueryf (LeCroy, "C%d:PAVA? MAX,MIN\n","%t",kan, antwoord); // Vraag Cx minimum en maximum waarde psaw = strstr (antwoord, "MAX"); // Zoek "MAX" sscanf (psaw+4, "%lf", &ymax); // Lees maximum waarde die achter "MAX staat psaw = strstr (antwoord, "OK,"); // Zoek "OK" if (psaw == 0) // Als "OK" niet is gevonden: Overflow { if (yarr < 11) yarr++; // Is ongevoeligste bereik al ingesteld? } else // Als "OK" wel is gevonden (geen overflow) { psaw = strstr (antwoord, "MIN"); // Zoek "MIN" sscanf (psaw+4, "%lf", &ymin); // Lees minimum waarde die achter "MIN" staat if (yarr > 0) // Is gevoeligste bereik al ingesteld? { sscanf (yd[yarr-1], "%lf", &ydiv); // Lees volgende gevoeliger stand in als floatwaarde if ((ydiv * 3.5) > ymax && (ydiv * -3.5) < ymin) yarr--; // Als gevoeligheid groter wordt ingesteld zou dan een overflow kunnen ontstaan? } } if (yarr < 6) {gevoeligheid = yarr; verzwakker = 1;} else {gevoeligheid = yarr-3; verzwakker = 10;} viPrintf (LeCroy, "C%d:ATTeNuation %d\n", kan, verzwakker); // Stuur verzwakker instelling en... viPrintf (LeCroy, "C%d:Volt_DIV %s\n",kan, yd[gevoeligheid]); // ...gevoeligheidinstelling naar scoop. // Status sprintf (statusline, " Probe AP015, CH%d: %s A/div\n", kan, yd[yarr]); SetCtrlVal (meetpanel, MEETPANEL_CONTROLE, statusline); return yarr; // Nieuwe gevoeligheid instelling terugsturen. } /*---------------------------------*/ /* CHECK ACTIEVE KANALEN EN TRACES */ /*---------------------------------*/ void Check_actief () { int SPmeter; int SPbron; int SPref; int SMath; int SMx; int SMy; /*** Reset status kanalen en traces ***/ CH1actief = 0; CH2actief = 0; CH3actief = 0; CH4actief = 0; TRAactief = 0; TRBactief = 0; TRCactief = 0; TRDactief = 0; /*** Scan -Record Parameters- ***/ GetCtrlVal (steppanel, STEPPANEL_PARAMETER1, &SPmeter); GetCtrlVal (steppanel, STEPPANEL_PARABRON1, &SPbron); GetCtrlVal (steppanel, STEPPANEL_PARAREF1, &SPref); Check_para (SPmeter, SPbron, SPref); GetCtrlVal (steppanel, STEPPANEL_PARAMETER2, &SPmeter); GetCtrlVal (steppanel, STEPPANEL_PARABRON2, &SPbron); GetCtrlVal (steppanel, STEPPANEL_PARAREF2, &SPref); Check_para (SPmeter, SPbron, SPref); GetCtrlVal (steppanel, STEPPANEL_PARAMETER3, &SPmeter); GetCtrlVal (steppanel, STEPPANEL_PARABRON3, &SPbron); GetCtrlVal (steppanel, STEPPANEL_PARAREF3, &SPref); Check_para (SPmeter, SPbron, SPref); GetCtrlVal (steppanel, STEPPANEL_PARAMETER4, &SPmeter); GetCtrlVal (steppanel, STEPPANEL_PARABRON4, &SPbron); GetCtrlVal (steppanel, STEPPANEL_PARAREF4, &SPref); Check_para (SPmeter, SPbron, SPref); /*** Scan -Display kanalen- ***/ GetCtrlVal (scooppanel, SCOPEPANEL_CH1VIS, &SPmeter); if (SPmeter == 1) CH1actief = 1; GetCtrlVal (scooppanel, SCOPEPANEL_CH2VIS, &SPmeter); if (SPmeter == 1) CH2actief = 1; GetCtrlVal (scooppanel, SCOPEPANEL_CH3VIS, &SPmeter); if (SPmeter == 1) CH3actief = 1; GetCtrlVal (scooppanel, SCOPEPANEL_CH4VIS, &SPmeter); if (SPmeter == 1) CH4actief = 1; /*** Scan -Display traces- ***/ GetCtrlVal (scooppanel, SCOPEPANEL_TRAVIS, &SPmeter); if (SPmeter == 1) TRAactief = 1; GetCtrlVal (scooppanel, SCOPEPANEL_TRBVIS, &SPmeter); if (SPmeter == 1) TRBactief = 1; GetCtrlVal (scooppanel, SCOPEPANEL_TRCVIS, &SPmeter); if (SPmeter == 1) TRCactief = 1; GetCtrlVal (scooppanel, SCOPEPANEL_TRDVIS, &SPmeter); if (SPmeter == 1) TRDactief = 1; /*** Scan -math traces- ***/ GetCtrlVal (scooppanel, SCOPEPANEL_TRAMATH, &SMath); GetCtrlVal (scooppanel, SCOPEPANEL_TRABRONX, &SMx); GetCtrlVal (scooppanel, SCOPEPANEL_TRABRONY, &SMy); Check_math (SMath, SMx, SMy); GetCtrlVal (scooppanel, SCOPEPANEL_TRBMATH, &SMath); GetCtrlVal (scooppanel, SCOPEPANEL_TRBBRONX, &SMx); GetCtrlVal (scooppanel, SCOPEPANEL_TRBBRONY, &SMy); Check_math (SMath, SMx, SMy); GetCtrlVal (scooppanel, SCOPEPANEL_TRCMATH, &SMath); GetCtrlVal (scooppanel, SCOPEPANEL_TRCBRONX, &SMx); GetCtrlVal (scooppanel, SCOPEPANEL_TRCBRONY, &SMy); Check_math (SMath, SMx, SMy); GetCtrlVal (scooppanel, SCOPEPANEL_TRDMATH, &SMath); GetCtrlVal (scooppanel, SCOPEPANEL_TRDBRONX, &SMx); GetCtrlVal (scooppanel, SCOPEPANEL_TRDBRONY, &SMy); Check_math (SMath, SMx, SMy); return; } /*-----------------------------------------------*/ /* CHECK ACTIEVE KANALEN EN TRACES -Math traces- */ /*-----------------------------------------------*/ void Check_math (Msoort, Mbron, Maanvul) { if (Msoort > 0) { switch (Mbron) { case 1: CH1actief = 1; break; case 2: CH2actief = 1; break; case 3: CH3actief = 1; break; case 4: CH4actief = 1; break; case 5: TRAactief = 1; break; case 6: TRBactief = 1; break; case 7: TRCactief = 1; break; case 8: TRDactief = 1; break; } } if (Msoort > 2) { switch (Maanvul) { case 1: CH1actief = 1; break; case 2: CH2actief = 1; break; case 3: CH3actief = 1; break; case 4: CH4actief = 1; break; case 5: TRAactief = 1; break; case 6: TRBactief = 1; break; case 7: TRCactief = 1; break; case 8: TRDactief = 1; break; } } return; } /*-----------------------------------------------------*/ /* CHECK ACTIEVE KANALEN EN TRACES -Record parameters- */ /*-----------------------------------------------------*/ void Check_para (Pmeter, Pbron, Pref) { if (Pmeter > 0) { switch (Pbron) { case 1: CH1actief = 1; break; case 2: CH2actief = 1; break; case 3: CH3actief = 1; break; case 4: CH4actief = 1; break; case 5: TRAactief = 1; break; case 6: TRBactief = 1; break; case 7: TRCactief = 1; break; case 8: TRDactief = 1; break; } } if (Pmeter == 8) { switch (Pref) { case 1: CH1actief = 1; break; case 2: CH2actief = 1; break; case 3: CH3actief = 1; break; case 4: CH4actief = 1; break; case 5: TRAactief = 1; break; case 6: TRBactief = 1; break; case 7: TRCactief = 1; break; case 8: TRDactief = 1; break; } } return; } /*-----------------------*/ /* LEES IDENTITEIT PROBE */ /*-----------------------*/ int Probe_id (char *rijtje, char *probe) { int getal; if (strstr (rijtje, "x10")) { getal = 1; strcpy (probe, "PP006"); } else if (strstr (rijtje, "ADP305")) { getal = 2; strcpy (probe, "ADP305"); } else if (strstr (rijtje, "AP015")) { getal = 3; strcpy (probe, "AP015"); } else { getal = 0; strcpy (probe, "onbekend"); } return getal; } /*-----------------------------*/ /* INSTELLEN CUSTOM PARAMETERS */ /*-----------------------------*/ void CustPara (Pmeter, Pbron, Pref, Pline) { char *Ptrace[] = {"C1","C2","C3","C4","TA","TB","TC","TD"}; switch (Pmeter) { case 0: viPrintf (LeCroy, "PArameter_DeLete %d\n", Pline); break; // geen parameter case 1: viPrintf (LeCroy, "PACU %d,MEAN,%s\n", Pline, Ptrace[Pbron-1]); break; // mean case 2: viPrintf (LeCroy, "PACU %d,CMEAN,%s\n", Pline, Ptrace[Pbron-1]); break; // cmean case 3: viPrintf (LeCroy, "PACU %d,RMS,%s\n", Pline, Ptrace[Pbron-1]); break; // rms case 4: viPrintf (LeCroy, "PACU %d,CRMS,%s\n", Pline, Ptrace[Pbron-1]); break; // crms case 5: viPrintf (LeCroy, "PACU %d,SDEV,%s\n", Pline, Ptrace[Pbron-1]); break; // sdev case 6: viPrintf (LeCroy, "PACU %d,CSDEV,%s\n", Pline, Ptrace[Pbron-1]); break; // csdev case 7: viPrintf (LeCroy, "PACU %d,FREQ,%s\n", Pline, Ptrace[Pbron-1]); break; // frequentie case 8: viPrintf (LeCroy, "PACU %d,PHASE,%s,POS,0,%s,POS,0,1,DEG\n", Pline, Ptrace[Pbron-1], Ptrace[Pref-1]); break; // fase } return; } /*------------------------------*/ /* INSTELLEN CUSTOM MATH TRACES */ /*------------------------------*/ void CustMath (Msoort, Mbron, Maanvul, Mtrace) { char *Ptrace[] = {"C1","C2","C3","C4","TA","TB","TC","TD"}; char *Pbits[] = {"0.5","1.0","1.5","2.0","2.5","3.0"}; char *Psweeps[] = {"1","3","7","15","31","63"}; int Mpoints; Mpoints = 100000; // Aantal meetpunten gebruiken voor math switch (Msoort) { case 0: viPrintf (LeCroy, "%s:DEFine EQN,'%s',MAXPTS,%d\n", Ptrace[Mtrace+3], Ptrace[Mbron-1], Mpoints); break; // Geen math case 1: viPrintf (LeCroy, "%s:DEFine EQN,'ERES(%s)',MAXPTS,%d,BITS,%s\n", Ptrace[Mtrace+3], Ptrace[Mbron-1], Mpoints, Pbits[Maanvul-1]); break; // Enh. resolution case 2: viPrintf (LeCroy, "%s:DEFine EQN,'AVGS(%s)',MAXPTS,%d,SWEEPS,%s\n", Ptrace[Mtrace+3], Ptrace[Mbron-1], Mpoints, Psweeps[Maanvul-1]); break; // Average case 3: viPrintf (LeCroy, "%s:DEFine EQN,'%s+%s',MAXPTS,%d\n", Ptrace[Mtrace+3], Ptrace[Mbron-1], Ptrace[Maanvul-1], Mpoints); break; // Sum case 4: viPrintf (LeCroy, "%s:DEFine EQN,'%s-%s',MAXPTS,%d\n", Ptrace[Mtrace+3], Ptrace[Mbron-1], Ptrace[Maanvul-1], Mpoints); break; // Difference case 5: viPrintf (LeCroy, "%s:DEFine EQN,'%s*%s',MAXPTS,%d\n", Ptrace[Mtrace+3], Ptrace[Mbron-1], Ptrace[Maanvul-1], Mpoints); break; // Product case 6: viPrintf (LeCroy, "%s:DEFine EQN,'%s/%s',MAXPTS,%d\n", Ptrace[Mtrace+3], Ptrace[Mbron-1], Ptrace[Maanvul-1], Mpoints); break; // Ratio } return; } /*-----------------------------------------------*/ /* BEREKEN EERSTE FREQUENTIE, EXPONENT GENOTEERD */ /*-----------------------------------------------*/ void FreqExp () { double decimaal; double voorvoegsel; double f_start; double f_spatie; int f125; int linlog; int decstap; double e_stap; // Lees startfrequentie GetCtrlVal (steppanel, STEPPANEL_STARTDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_STARTDVV, &voorvoegsel); f_start = decimaal * voorvoegsel; GetCtrlVal (steppanel, STEPPANEL_LINLOG, &linlog); // Lineair if (linlog == 0) { GetCtrlVal (steppanel, STEPPANEL_FSPATDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_FSPATDVV, &voorvoegsel); f_spatie = decimaal * voorvoegsel; if (f_start > f_spatie) // Bereken de dichtsbij gelegen lagere frequentie die deelbaar is door de frequentiespatie { f_start = fabs (f_start / f_spatie); f_spatie = f_start * f_spatie; } // anders: frequentiespatie is de eerste frequentie e_freq = log10 (f_spatie); } // Logaritmisch else { // Bereken de dichtsbij gelegen hogere (of gelijke) hele exponent frequentie e_freq = 0; while (pow (10, e_freq) > f_start) {e_freq--;} while (pow (10, e_freq) < f_start) {e_freq++;} // Bereken de dichtsbij gelegen lagere (of gelijke) frequentie ... GetCtrlVal (steppanel, STEPPANEL_FREQ125, &f125); if (f125 == 1) { // ...volgens de 1-2-5 frequentie afstanden. e_stap = 0; if (pow (10, e_freq) > f_start) { e_freq -= 1; e_stap = 0.699; if (pow (10, (e_freq + e_stap)) > f_start) { e_stap = 0.301; if (pow (10, (e_freq + e_stap)) > f_start) e_stap = 0; } } e_freq += e_stap; } else { // ...volgens logaritmische frequentie afstanden. GetCtrlVal (steppanel, STEPPANEL_NSTEPS, &decstap); while (pow (10, e_freq) > f_start) {e_freq -= (1 / decstap);} } } return; } /*-------------------------------------------------*/ /* BEREKEN VOLGENDE FREQUENTIE, EXPONENT GENOTEERD */ /*-------------------------------------------------*/ void FreqNext () { int linlog; int f125; int decstap; double decstapf; int e_heel; double e_rest; double e_nieuw; double decimaal; double voorvoegsel; // Bereken de volgende frequentie ... GetCtrlVal (steppanel, STEPPANEL_LINLOG, &linlog); // Lineair if (linlog == 0) { GetCtrlVal (steppanel, STEPPANEL_FSPATDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_FSPATDVV, &voorvoegsel); decstapf = pow (10, e_freq) + (decimaal * voorvoegsel); e_freq = log10 (decstapf); } // Logaritmisch else { GetCtrlVal (steppanel, STEPPANEL_FREQ125, &f125); if (f125 == 1) { // ...volgens de 1-2-5 frequentie afstanden. e_heel = fabs (e_freq); e_rest = e_freq - e_heel; //e_nieuw = 0; // dummy if (e_rest > 0.2 && e_rest < 0.4) e_nieuw = 0.69897; else if (e_rest > 0.6 && e_rest < 0.8) {e_nieuw = 0; e_heel += 1;} else e_nieuw = 0.30103; e_freq = e_heel + e_nieuw; } else { // ...volgens logaritmische frequentie afstanden. GetCtrlVal (steppanel, STEPPANEL_NSTEPS, &decstap); decstapf = decstap; e_freq += (1 / decstapf); } } return; } /*-----------------------------------------------*/ /* START GPIB SESSIE & INITIALISEER INSTRUMENTEN */ /*-----------------------------------------------*/ void StartComInstr () { int adres; char antwoord [100]; // Antwoord string van scoop // Algemeen intitialisatie viOpenDefaultRM (&defaultRM); // Create and Open a Device Session //GetCtrlVal (connpanel, CONNPANEL_GPIBFUNK, &adres); viOpen (defaultRM, "GPIB0::10::INSTR", VI_NULL, VI_NULL, &Agilent); // Arb. Func. Gen. heeft GPIB address 10 viSetAttribute (Agilent,VI_ATTR_TMO_VALUE, 10000); // Set de communicatie timeout //GetCtrlVal (connpanel, CONNPANEL_GPIBSCOOP, &adres); viOpen (defaultRM, "GPIB0::5::INSTR", VI_NULL, VI_NULL, &LeCroy); // Scoop LT344L heeft GPIB address 5 viSetAttribute (LeCroy,VI_ATTR_TMO_VALUE, 10000); // Set de communicatie timeout // Funktiegenerator: Agilent 33250A viPrintf (Agilent, "OUTP OFF\n"); // Uitgang afgekoppeld viPrintf (Agilent, "FUNC SIN\n"); // Sinus spanning // Oscilloscoop: LeCroy LT344L viPrintf (LeCroy, "Comm_HeaDeR SHORT\n"); // Kort header respons formaat viPrintf (LeCroy, "TRig_MoDe STOP\n"); // Stop triggeren viQueryf (LeCroy, "INR?\n","%t",antwoord); // Vraag scoop-status (INR): deze actie cleared het register) return; } /*------------------*/ /* STOP GPIB SESSIE */ /*------------------*/ void StopComInstr () { viClose (LeCroy); viClose (Agilent); viClose (defaultRM); return; } /*------------------------------------------*/ /* INSTELLINGEN SCHRIJVEN NAAR OSCILLOSCOOP */ /*------------------------------------------*/ void SetupLeCroy () { int Tbron; int Tkop; int Timp; int Tslope; int Smemory; int Sinterl; int Sgrid; int Sdisplay; int Skop; int Sbwl; int SPmeter; int SPbron; int SPref; int SMath; int SMx; int SMy; double Tlevel; char *TBron[] = {"C1","C2","C3","C4","EX","EX10"}; // Triggerbron codes char *SKoppeling[] = {"GND","D50","D1M","A1M"}; // Koppelings codes char *TKoppeling[] = {"DC","AC","HFREJ","LFREJ"}; // Trigger koppeling codes char *TSlope[] = {"POS","NEG"}; // Trigger slope char *Sswitsh[] = {"OFF","ON"}; // ON/OFF algemeen char *SGrid[] = {"SINGLE","DUAL","QUAD","OCTAL"}; // Grid char *SBWL[] = {"OFF","ON","200MHZ"}; // BandWidth Limit (ON = 25 MHz) /*** Triggering ***/ GetCtrlVal (scooppanel, SCOPEPANEL_TRIGBRON, &Tbron); // Instelling Extern triggering // Trigger koppeling GetCtrlVal (scooppanel, SCOPEPANEL_TRIGKOP, &Tkop); viPrintf (LeCroy, "%s:TRig_CouPling %s\n", TBron[Tbron-1], TKoppeling[Tkop-1]); // Trigger Ingangs Impedantie GetCtrlVal (scooppanel, SCOPEPANEL_TRIGEXTK, &Timp); if (Tbron != 5 && Tbron != 6) Timp = 1; // DC 1 Mohm indien niet EXT trigger viPrintf (LeCroy, "%s:CouPLing %s\n", TBron[Tbron-1] ,SKoppeling[Timp+1]); // Trigger koppeling GetCtrlVal (scooppanel, SCOPEPANEL_TRIGSLOPE, &Tslope); viPrintf (LeCroy, "%s:TRig_SLope %s\n", TBron[Tbron-1] ,TSlope[Tslope]); // Trigger Select viPrintf (LeCroy, "TRig_SElect STD,SR,EX,HT,OFF\n"); // Standaard EDGE trigger, hold OFF // Trigger Delay (0 %) viPrintf (LeCroy, "TRig_DeLay 0 PCT\n"); // Trigger level GetCtrlVal (scooppanel, SCOPEPANEL_TRIGNIVO, &Tlevel); viPrintf (LeCroy, "%s:TRig_LeVel %gV\n", TBron[Tbron-1], Tlevel); /*** Acquisition ***/ // Memory GetCtrlVal (scooppanel, SCOPEPANEL_ACQUISMEM, &Smemory); viPrintf (LeCroy, "Memory_SIZe %d\n", Smemory); // Sequence (OFF) viPrintf (LeCroy, "SEQuence OFF\n"); // Interleaved viPrintf (LeCroy, "TDIV 1E-6\n"); // Nodig om RIS in te stellen GetCtrlVal (scooppanel, SCOPEPANEL_INTERLEAVED, &Sinterl); viPrintf (LeCroy, "InterLeaVeD %s\n", Sswitsh[Sinterl]); //Global Bandwidth Limit (ON) viPrintf (LeCroy, "Global_BWL ON\n"); /*** Cursors ***/ /*** Display ***/ // Grid GetCtrlVal (scooppanel, SCOPEPANEL_GRIDSETUP, &Sgrid); viPrintf (LeCroy, "GRID %s\n", SGrid[Sgrid]); // Traces GetCtrlVal (scooppanel, SCOPEPANEL_TRDVIS, &Sdisplay); viPrintf (LeCroy, "TD:TRAce %s\n", Sswitsh[Sdisplay]); GetCtrlVal (scooppanel, SCOPEPANEL_TRCVIS, &Sdisplay); viPrintf (LeCroy, "TC:TRAce %s\n", Sswitsh[Sdisplay]); GetCtrlVal (scooppanel, SCOPEPANEL_TRBVIS, &Sdisplay); viPrintf (LeCroy, "TB:TRAce %s\n", Sswitsh[Sdisplay]); GetCtrlVal (scooppanel, SCOPEPANEL_TRAVIS, &Sdisplay); viPrintf (LeCroy, "TA:TRAce %s\n", Sswitsh[Sdisplay]); // Kanalen GetCtrlVal (scooppanel, SCOPEPANEL_CH4VIS, &Sdisplay); viPrintf (LeCroy, "C4:TRAce %s\n", Sswitsh[Sdisplay]); GetCtrlVal (scooppanel, SCOPEPANEL_CH3VIS, &Sdisplay); viPrintf (LeCroy, "C3:TRAce %s\n", Sswitsh[Sdisplay]); GetCtrlVal (scooppanel, SCOPEPANEL_CH2VIS, &Sdisplay); viPrintf (LeCroy, "C2:TRAce %s\n", Sswitsh[Sdisplay]); GetCtrlVal (scooppanel, SCOPEPANEL_CH1VIS, &Sdisplay); viPrintf (LeCroy, "C1:TRAce %s\n", Sswitsh[Sdisplay]); /*** Kanaal instellingen ***/ // Gevoeligheid (defauld 1 V/div) viPrintf (LeCroy, "C1:Volt_DIV 1V\n", Sswitsh[Sdisplay]); viPrintf (LeCroy, "C2:Volt_DIV 1V\n", Sswitsh[Sdisplay]); viPrintf (LeCroy, "C3:Volt_DIV 1V\n", Sswitsh[Sdisplay]); viPrintf (LeCroy, "C4:Volt_DIV 1V\n", Sswitsh[Sdisplay]); // Koppeling GetCtrlVal (scooppanel, SCOPEPANEL_CH1KOP, &Skop); viPrintf (LeCroy, "C1:CouPLing %s\n", SKoppeling[Skop]); GetCtrlVal (scooppanel, SCOPEPANEL_CH2KOP, &Skop); viPrintf (LeCroy, "C2:CouPLing %s\n", SKoppeling[Skop]); GetCtrlVal (scooppanel, SCOPEPANEL_CH3KOP, &Skop); viPrintf (LeCroy, "C3:CouPLing %s\n", SKoppeling[Skop]); GetCtrlVal (scooppanel, SCOPEPANEL_CH4KOP, &Skop); viPrintf (LeCroy, "C4:CouPLing %s\n", SKoppeling[Skop]); // Bandbreedte GetCtrlVal (scooppanel, SCOPEPANEL_BWLSETUP, &Sbwl); viPrintf (LeCroy, "BandWidth_Limit %s\n", SBWL[Sbwl]); /*** Math instellingen ***/ // Parameters GetCtrlVal (steppanel, STEPPANEL_PARAMETER1, &SPmeter); GetCtrlVal (steppanel, STEPPANEL_PARABRON1, &SPbron); GetCtrlVal (steppanel, STEPPANEL_PARAREF1, &SPref); CustPara (SPmeter, SPbron, SPref, 1); GetCtrlVal (steppanel, STEPPANEL_PARAMETER2, &SPmeter); GetCtrlVal (steppanel, STEPPANEL_PARABRON2, &SPbron); GetCtrlVal (steppanel, STEPPANEL_PARAREF2, &SPref); CustPara (SPmeter, SPbron, SPref, 2); GetCtrlVal (steppanel, STEPPANEL_PARAMETER3, &SPmeter); GetCtrlVal (steppanel, STEPPANEL_PARABRON3, &SPbron); GetCtrlVal (steppanel, STEPPANEL_PARAREF3, &SPref); CustPara (SPmeter, SPbron, SPref, 3); GetCtrlVal (steppanel, STEPPANEL_PARAMETER4, &SPmeter); GetCtrlVal (steppanel, STEPPANEL_PARABRON4, &SPbron); GetCtrlVal (steppanel, STEPPANEL_PARAREF4, &SPref); CustPara (SPmeter, SPbron, SPref, 4); // Math GetCtrlVal (scooppanel, SCOPEPANEL_TRAMATH, &SMath); GetCtrlVal (scooppanel, SCOPEPANEL_TRABRONX, &SMx); GetCtrlVal (scooppanel, SCOPEPANEL_TRABRONY, &SMy); CustMath (SMath, SMx, SMy, 1); GetCtrlVal (scooppanel, SCOPEPANEL_TRBMATH, &SMath); GetCtrlVal (scooppanel, SCOPEPANEL_TRBBRONX, &SMx); GetCtrlVal (scooppanel, SCOPEPANEL_TRBBRONY, &SMy); CustMath (SMath, SMx, SMy, 2); GetCtrlVal (scooppanel, SCOPEPANEL_TRCMATH, &SMath); GetCtrlVal (scooppanel, SCOPEPANEL_TRCBRONX, &SMx); GetCtrlVal (scooppanel, SCOPEPANEL_TRCBRONY, &SMy); CustMath (SMath, SMx, SMy, 3); GetCtrlVal (scooppanel, SCOPEPANEL_TRDMATH, &SMath); GetCtrlVal (scooppanel, SCOPEPANEL_TRDBRONX, &SMx); GetCtrlVal (scooppanel, SCOPEPANEL_TRDBRONY, &SMy); CustMath (SMath, SMx, SMy, 4); // Zoom en positie traces return; } /*----------------------------------------------*/ /* INSTELLINGEN SCHRIJVEN NAAR FUNKTIEGENERATOR */ /*----------------------------------------------*/ void SetupAgilent () { double umeet; double uoffset; double frequentie; viPrintf (Agilent, "FUNC SIN\n"); // Sinus spanning GetCtrlVal (funkpanel, FUNKPANEL_UOFFSET, &uoffset);// Stel offset spanning in viPrintf (Agilent, "VOLT:OFFS %lf\n", uoffset); GetCtrlVal (funkpanel, FUNKPANEL_UMEET, &umeet); // Stel uitgangsspanning in viPrintf (Agilent, "VOLT %lf\n", umeet); FreqExp (); // Bereken startfrequentie frequentie = pow (10, e_freq); viPrintf (Agilent, "FREQ %lf\n", frequentie); // Set Frequentie. viPrintf (Agilent, "OUTP ON\n"); // Uitgang actief return; } /***************************************************************/ /* PANEL: INSTRUMENT CONNECTIE */ /***************************************************************/ // OK knop: start GPIB & instrumenten initialisatie int CVICALLBACK InstrOk (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event == EVENT_COMMIT) { StartComInstr (); RemovePopup (connpanel); } return 0; } // knop Afsluiten: einde programma int CVICALLBACK InstSluit (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event == EVENT_COMMIT) { RemovePopup (connpanel); QuitUserInterface (0); } return 0; } /***************************************************************/ /* PANEL: STEPSWEEP */ /***************************************************************/ // decimale start waarde: check max, en corrigeer int CVICALLBACK StartDec (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double decimaal; double voorvoegsel; if (event == EVENT_VAL_CHANGED) { GetCtrlVal (steppanel, STEPPANEL_STARTDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_STARTDVV, &voorvoegsel); if (decimaal * voorvoegsel > 80000000) decimaal = 80; SetCtrlVal (steppanel, STEPPANEL_STARTDEC, decimaal); } return 0; } // decimale stop waarde: check max, en corrigeer int CVICALLBACK StopDec (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double decimaal; double voorvoegsel; if (event == EVENT_VAL_CHANGED) { GetCtrlVal (steppanel, STEPPANEL_STOPDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_STOPDVV, &voorvoegsel); if (decimaal * voorvoegsel > 80000000) decimaal = 80; SetCtrlVal (steppanel, STEPPANEL_STOPDEC, decimaal); } return 0; } // voorvoegsel start waarde: check max, en corrigeer int CVICALLBACK StartDVV (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double decimaal; double voorvoegsel; if (event == EVENT_VAL_CHANGED) { GetCtrlVal (steppanel, STEPPANEL_STARTDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_STARTDVV, &voorvoegsel); if (decimaal * voorvoegsel > 80000000) decimaal = 80; SetCtrlVal (steppanel, STEPPANEL_STARTDEC, decimaal); } return 0; } // voorvoegsel stop waarde: check max, en corrigeer int CVICALLBACK StopDVV (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double decimaal; double voorvoegsel; if (event == EVENT_VAL_CHANGED) { GetCtrlVal (steppanel, STEPPANEL_STOPDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_STOPDVV, &voorvoegsel); if (decimaal * voorvoegsel > 80000000) decimaal = 80; SetCtrlVal (steppanel, STEPPANEL_STOPDEC, decimaal); } return 0; } // aanvink "1-2-5 Stappen": dimmen N-Stappen int CVICALLBACK Freq125 (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int aanvink; if (event == EVENT_COMMIT) { GetCtrlVal (steppanel, STEPPANEL_FREQ125, &aanvink); if (aanvink == 0) SetCtrlAttribute (steppanel, STEPPANEL_NSTEPS, ATTR_DIMMED, 0); else SetCtrlAttribute (steppanel, STEPPANEL_NSTEPS, ATTR_DIMMED, 1); } return 0; } // switsh "lin/log": dimmen int CVICALLBACK LinLog (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int aanvink; if (event == EVENT_COMMIT) { GetCtrlVal (steppanel, STEPPANEL_LINLOG, &aanvink); if (aanvink == 0) // lineair { SetCtrlAttribute (steppanel, STEPPANEL_FSPATDEC, ATTR_DIMMED, 0); SetCtrlAttribute (steppanel, STEPPANEL_FSPATDVV, ATTR_DIMMED, 0); SetCtrlAttribute (steppanel, STEPPANEL_FREQ125, ATTR_DIMMED, 1); SetCtrlAttribute (steppanel, STEPPANEL_NSTEPS, ATTR_DIMMED, 1); } else // logaritmisch { SetCtrlAttribute (steppanel, STEPPANEL_FSPATDEC, ATTR_DIMMED, 1); SetCtrlAttribute (steppanel, STEPPANEL_FSPATDVV, ATTR_DIMMED, 1); SetCtrlAttribute (steppanel, STEPPANEL_FREQ125, ATTR_DIMMED, 0); GetCtrlVal (steppanel, STEPPANEL_FREQ125, &aanvink); if (aanvink == 0) SetCtrlAttribute (steppanel, STEPPANEL_NSTEPS, ATTR_DIMMED, 0); else SetCtrlAttribute (steppanel, STEPPANEL_NSTEPS, ATTR_DIMMED, 1); } } return 0; } // decimale frequentie afstand waarde: check max, en corrigeer int CVICALLBACK FspatDec (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double decimaal; double voorvoegsel; if (event == EVENT_VAL_CHANGED) { GetCtrlVal (steppanel, STEPPANEL_FSPATDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_FSPATDVV, &voorvoegsel); if (decimaal * voorvoegsel > 80000000) decimaal = 80; SetCtrlVal (steppanel, STEPPANEL_FSPATDEC, decimaal); } return 0; } // voorvoegsel frequentie afstand waarde: check max, en corrigeer int CVICALLBACK FspatDVV (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double decimaal; double voorvoegsel; if (event == EVENT_VAL_CHANGED) { GetCtrlVal (steppanel, STEPPANEL_FSPATDEC, &decimaal); GetCtrlVal (steppanel, STEPPANEL_FSPATDVV, &voorvoegsel); if (decimaal * voorvoegsel > 80000000) decimaal = 80; SetCtrlVal (steppanel, STEPPANEL_FSPATDEC, decimaal); } return 0; } // selectie Parameter1: dimmen Bron, visueel Referentie int CVICALLBACK Parameter1 (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int parameter; if (event == EVENT_COMMIT) { GetCtrlVal (steppanel, STEPPANEL_PARAMETER1, ¶meter); if (parameter == 0) SetCtrlAttribute (steppanel, STEPPANEL_PARABRON1, ATTR_DIMMED, 1); else SetCtrlAttribute (steppanel, STEPPANEL_PARABRON1, ATTR_DIMMED, 0); if (parameter == 8) SetCtrlAttribute (steppanel, STEPPANEL_PARAREF1, ATTR_VISIBLE, 1); else SetCtrlAttribute (steppanel, STEPPANEL_PARAREF1, ATTR_VISIBLE, 0); } return 0; } // selectie Parameter2: dimmen Bron, visueel Referentie int CVICALLBACK Parameter2 (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int parameter; if (event == EVENT_COMMIT) { GetCtrlVal (steppanel, STEPPANEL_PARAMETER2, ¶meter); if (parameter == 0) SetCtrlAttribute (steppanel, STEPPANEL_PARABRON2, ATTR_DIMMED, 1); else SetCtrlAttribute (steppanel, STEPPANEL_PARABRON2, ATTR_DIMMED, 0); if (parameter == 8) SetCtrlAttribute (steppanel, STEPPANEL_PARAREF2, ATTR_VISIBLE, 1); else SetCtrlAttribute (steppanel, STEPPANEL_PARAREF2, ATTR_VISIBLE, 0); } return 0; } // selectie Parameter3: dimmen Bron, visueel Referentie int CVICALLBACK Parameter3 (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int parameter; if (event == EVENT_COMMIT) { GetCtrlVal (steppanel, STEPPANEL_PARAMETER3, ¶meter); if (parameter == 0) SetCtrlAttribute (steppanel, STEPPANEL_PARABRON3, ATTR_DIMMED, 1); else SetCtrlAttribute (steppanel, STEPPANEL_PARABRON3, ATTR_DIMMED, 0); if (parameter == 8) SetCtrlAttribute (steppanel, STEPPANEL_PARAREF3, ATTR_VISIBLE, 1); else SetCtrlAttribute (steppanel, STEPPANEL_PARAREF3, ATTR_VISIBLE, 0); } return 0; } // selectie Parameter4: dimmen Bron, visueel Referentie int CVICALLBACK Parameter4 (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int parameter; if (event == EVENT_COMMIT) { GetCtrlVal (steppanel, STEPPANEL_PARAMETER4, ¶meter); if (parameter == 0) SetCtrlAttribute (steppanel, STEPPANEL_PARABRON4, ATTR_DIMMED, 1); else SetCtrlAttribute (steppanel, STEPPANEL_PARABRON4, ATTR_DIMMED, 0); if (parameter == 8) SetCtrlAttribute (steppanel, STEPPANEL_PARAREF4, ATTR_VISIBLE, 1); else SetCtrlAttribute (steppanel, STEPPANEL_PARAREF4, ATTR_VISIBLE, 0); } return 0; } // knop Setup Oscilloscoop: open popup Setup Oscilloscoop int CVICALLBACK SetupScoop (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char antwoord[100]; char tekst[10]; char header[10]; if (event == EVENT_COMMIT) { InstallPopup (scooppanel); /*** Vraag Probe Identiteit ***/ // Probe CH1 viQueryf (LeCroy, "C1:PROBE_NAME?\n","%t",antwoord); CH1probesoort = Probe_id (antwoord, tekst); SetCtrlVal (scooppanel, SCOPEPANEL_CH1PROBE, tekst); // Probe CH2 viQueryf (LeCroy, "C2:PROBE_NAME?\n","%t",antwoord); CH2probesoort = Probe_id (antwoord, tekst); SetCtrlVal (scooppanel, SCOPEPANEL_CH2PROBE, tekst); // Probe CH3 viQueryf (LeCroy, "C3:PROBE_NAME?\n","%t",antwoord); CH3probesoort = Probe_id (antwoord, tekst); SetCtrlVal (scooppanel, SCOPEPANEL_CH3PROBE, tekst); // Probe CH4 viQueryf (LeCroy, "C4:PROBE_NAME?\n","%t",antwoord); CH4probesoort = Probe_id (antwoord, tekst); SetCtrlVal (scooppanel, SCOPEPANEL_CH4PROBE, tekst); /*** Vraag Probe Verzwakking ***/ // Probe CH1 viQueryf (LeCroy, "C1:ATTeNuation?\n","%t",antwoord); sscanf (antwoord, "%s%d", header, &CH1verz); sprintf (tekst, "x %d", CH1verz); SetCtrlVal (scooppanel, SCOPEPANEL_CH1VERZW, tekst); // Probe CH2 viQueryf (LeCroy, "C2:ATTeNuation?\n","%t",antwoord); sscanf (antwoord, "%s%d", header, &CH2verz); sprintf (tekst, "x %d", CH2verz); SetCtrlVal (scooppanel, SCOPEPANEL_CH2VERZW, tekst); // Probe CH3 viQueryf (LeCroy, "C3:ATTeNuation?\n","%t",antwoord); sscanf (antwoord, "%s%d", header, &CH3verz); sprintf (tekst, "x %d", CH3verz); SetCtrlVal (scooppanel, SCOPEPANEL_CH3VERZW, tekst); // Probe CH4 viQueryf (LeCroy, "C4:ATTeNuation?\n","%t",antwoord); sscanf (antwoord, "%s%d", header, &CH4verz); sprintf (tekst, "x %d", CH4verz); SetCtrlVal (scooppanel, SCOPEPANEL_CH4VERZW, tekst); } return 0; } // knop Setup Funktiegenerator: open popup Setup Funktiegenerator int CVICALLBACK SetupFunk (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event == EVENT_COMMIT) InstallPopup (funkpanel); return 0; } // knop Start Meting: open popup Meten & schrijf instellingen naar instrumenten int CVICALLBACK StartMeting (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char antwoord[100]; char tekst[10]; char header[10]; if (event == EVENT_COMMIT) { /*** Vraag Probe Identiteit ***/ // Probe CH1 viQueryf (LeCroy, "C1:PROBE_NAME?\n","%t",antwoord); CH1probesoort = Probe_id (antwoord, tekst); SetCtrlVal (scooppanel, SCOPEPANEL_CH1PROBE, tekst); // Probe CH2 viQueryf (LeCroy, "C2:PROBE_NAME?\n","%t",antwoord); CH2probesoort = Probe_id (antwoord, tekst); SetCtrlVal (scooppanel, SCOPEPANEL_CH2PROBE, tekst); // Probe CH3 viQueryf (LeCroy, "C3:PROBE_NAME?\n","%t",antwoord); CH3probesoort = Probe_id (antwoord, tekst); SetCtrlVal (scooppanel, SCOPEPANEL_CH3PROBE, tekst); // Probe CH4 viQueryf (LeCroy, "C4:PROBE_NAME?\n","%t",antwoord); CH4probesoort = Probe_id (antwoord, tekst); SetCtrlVal (scooppanel, SCOPEPANEL_CH4PROBE, tekst); /*** Vraag Probe Verzwakking ***/ // Probe CH1 viQueryf (LeCroy, "C1:ATTeNuation?\n","%t",antwoord); sscanf (antwoord, "%s%d", header, &CH1verz); sprintf (tekst, "x %d", CH1verz); SetCtrlVal (scooppanel, SCOPEPANEL_CH1VERZW, tekst); // Probe CH2 viQueryf (LeCroy, "C2:ATTeNuation?\n","%t",antwoord); sscanf (antwoord, "%s%d", header, &CH2verz); sprintf (tekst, "x %d", CH2verz); SetCtrlVal (scooppanel, SCOPEPANEL_CH2VERZW, tekst); // Probe CH3 viQueryf (LeCroy, "C3:ATTeNuation?\n","%t",antwoord); sscanf (antwoord, "%s%d", header, &CH3verz); sprintf (tekst, "x %d", CH3verz); SetCtrlVal (scooppanel, SCOPEPANEL_CH3VERZW, tekst); // Probe CH4 viQueryf (LeCroy, "C4:ATTeNuation?\n","%t",antwoord); sscanf (antwoord, "%s%d", header, &CH4verz); sprintf (tekst, "x %d", CH4verz); SetCtrlVal (scooppanel, SCOPEPANEL_CH4VERZW, tekst); /*** Start meting ***/ InstallPopup (meetpanel); SetupAgilent (); SetupLeCroy (); Check_actief (); RunMeting(); } return 0; } // knop Sluiten: afsluiten GPIB sessie & einde programma int CVICALLBACK SluitStep (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event == EVENT_COMMIT) { StopComInstr (); QuitUserInterface (0); } return 0; } /***************************************************************/ /* PANEL: SETUP OSCILLOSCOOP */ /***************************************************************/ // selectie Triggerbron: bij Extern of Extern10 Trigger verzwakker en Impedantie niet gedimt int CVICALLBACK TrigBron (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int bron; int dimmen; if (event == EVENT_COMMIT) { GetCtrlVal (scooppanel, SCOPEPANEL_TRIGBRON, &bron); if (bron == 5 || bron == 6) dimmen = 0; else dimmen = 1; SetCtrlAttribute (scooppanel, SCOPEPANEL_SETUPTEXT2, ATTR_DIMMED, dimmen); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRIGEXTV, ATTR_DIMMED, dimmen); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRIGEXTK, ATTR_DIMMED, dimmen); } return 0; } // waarde Trigger Nivo: niets doen int CVICALLBACK TrigNivo (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: break; case EVENT_VAL_CHANGED: break; } return 0; } // selectie Trace A Math: control dimmen bron X, Y en inhoud 2e ring int CVICALLBACK TrAMath (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int mathsel; if (event == EVENT_COMMIT) { GetCtrlVal (scooppanel, SCOPEPANEL_TRAMATH, &mathsel); if (mathsel == 0) { SetCtrlAttribute (scooppanel, SCOPEPANEL_TRABRONX, ATTR_DIMMED, 1); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRABRONY, ATTR_DIMMED, 1); } else { SetCtrlAttribute (scooppanel, SCOPEPANEL_TRABRONX, ATTR_DIMMED, 0); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRABRONY, ATTR_DIMMED, 0); } if (mathsel == 3 || mathsel == 4 || mathsel == 5 || mathsel == 6) { ClearListCtrl (scooppanel, SCOPEPANEL_TRABRONY); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, 0, "CH 1", 1); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "CH 2", 2); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "CH 3", 3); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "CH 4", 4); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "TR A", 5); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "TR B", 6); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "TR C", 7); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "TR D", 8); } if (mathsel == 1) { ClearListCtrl (scooppanel, SCOPEPANEL_TRABRONY); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, 0, "0.5 bits", 1); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "1.0 bits", 2); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "1.5 bits", 3); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "2.0 bits", 4); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "2.5 bits", 5); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "3.0 bits", 6); } if (mathsel == 2) { ClearListCtrl (scooppanel, SCOPEPANEL_TRABRONY); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, 0, "1 sweeps", 1); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "3 sweeps", 2); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "7 sweeps", 3); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "15 sweeps", 4); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "31 sweeps", 5); InsertListItem (scooppanel, SCOPEPANEL_TRABRONY, -1, "63 sweeps", 6); } } return 0; } // selectie Trace B Math: control dimmen bron X, Y en inhoud 2e ring int CVICALLBACK TrBMath (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int mathsel; if (event == EVENT_COMMIT) { GetCtrlVal (scooppanel, SCOPEPANEL_TRBMATH, &mathsel); if (mathsel == 0) { SetCtrlAttribute (scooppanel, SCOPEPANEL_TRBBRONX, ATTR_DIMMED, 1); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRBBRONY, ATTR_DIMMED, 1); } else { SetCtrlAttribute (scooppanel, SCOPEPANEL_TRBBRONX, ATTR_DIMMED, 0); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRBBRONY, ATTR_DIMMED, 0); } if (mathsel == 3 || mathsel == 4 || mathsel == 5 || mathsel == 6) { ClearListCtrl (scooppanel, SCOPEPANEL_TRBBRONY); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, 0, "CH 1", 1); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "CH 2", 2); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "CH 3", 3); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "CH 4", 4); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "TR A", 5); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "TR B", 6); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "TR C", 7); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "TR D", 8); } if (mathsel == 1) { ClearListCtrl (scooppanel, SCOPEPANEL_TRBBRONY); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, 0, "0.5 bits", 1); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "1.0 bits", 2); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "1.5 bits", 3); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "2.0 bits", 4); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "2.5 bits", 5); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "3.0 bits", 6); } if (mathsel == 2) { ClearListCtrl (scooppanel, SCOPEPANEL_TRBBRONY); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, 0, "1 sweeps", 1); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "3 sweeps", 2); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "7 sweeps", 3); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "15 sweeps", 4); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "31 sweeps", 5); InsertListItem (scooppanel, SCOPEPANEL_TRBBRONY, -1, "63 sweeps", 6); } } return 0; } // selectie Trace C Math: control dimmen bron X, Y en inhoud 2e ring int CVICALLBACK TrCMath (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int mathsel; if (event == EVENT_COMMIT) { GetCtrlVal (scooppanel, SCOPEPANEL_TRCMATH, &mathsel); if (mathsel == 0) { SetCtrlAttribute (scooppanel, SCOPEPANEL_TRCBRONX, ATTR_DIMMED, 1); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRCBRONY, ATTR_DIMMED, 1); } else { SetCtrlAttribute (scooppanel, SCOPEPANEL_TRCBRONX, ATTR_DIMMED, 0); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRCBRONY, ATTR_DIMMED, 0); } if (mathsel == 3 || mathsel == 4 || mathsel == 5 || mathsel == 6) { ClearListCtrl (scooppanel, SCOPEPANEL_TRCBRONY); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, 0, "CH 1", 1); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "CH 2", 2); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "CH 3", 3); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "CH 4", 4); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "TR A", 5); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "TR B", 6); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "TR C", 7); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "TR D", 8); } if (mathsel == 1) { ClearListCtrl (scooppanel, SCOPEPANEL_TRCBRONY); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, 0, "0.5 bits", 1); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "1.0 bits", 2); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "1.5 bits", 3); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "2.0 bits", 4); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "2.5 bits", 5); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "3.0 bits", 6); } if (mathsel == 2) { ClearListCtrl (scooppanel, SCOPEPANEL_TRCBRONY); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, 0, "1 sweeps", 1); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "3 sweeps", 2); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "7 sweeps", 3); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "15 sweeps", 4); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "31 sweeps", 5); InsertListItem (scooppanel, SCOPEPANEL_TRCBRONY, -1, "63 sweeps", 6); } } return 0; } // selectie Trace D Math: control dimmen bron X, Y en inhoud 2e ring int CVICALLBACK TrDMath (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int mathsel; if (event == EVENT_COMMIT) { GetCtrlVal (scooppanel, SCOPEPANEL_TRDMATH, &mathsel); if (mathsel == 0) { SetCtrlAttribute (scooppanel, SCOPEPANEL_TRDBRONX, ATTR_DIMMED, 1); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRDBRONY, ATTR_DIMMED, 1); } else { SetCtrlAttribute (scooppanel, SCOPEPANEL_TRDBRONX, ATTR_DIMMED, 0); SetCtrlAttribute (scooppanel, SCOPEPANEL_TRDBRONY, ATTR_DIMMED, 0); } if (mathsel == 3 || mathsel == 4 || mathsel == 5 || mathsel == 6) { ClearListCtrl (scooppanel, SCOPEPANEL_TRDBRONY); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, 0, "CH 1", 1); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "CH 2", 2); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "CH 3", 3); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "CH 4", 4); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "TR A", 5); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "TR B", 6); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "TR C", 7); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "TR D", 8); } if (mathsel == 1) { ClearListCtrl (scooppanel, SCOPEPANEL_TRDBRONY); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, 0, "0.5 bits", 1); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "1.0 bits", 2); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "1.5 bits", 3); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "2.0 bits", 4); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "2.5 bits", 5); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "3.0 bits", 6); } if (mathsel == 2) { ClearListCtrl (scooppanel, SCOPEPANEL_TRDBRONY); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, 0, "1 sweeps", 1); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "3 sweeps", 2); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "7 sweeps", 3); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "15 sweeps", 4); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "31 sweeps", 5); InsertListItem (scooppanel, SCOPEPANEL_TRDBRONY, -1, "63 sweeps", 6); } } return 0; } // knop OK: sluit popup Setup Oscilloscoop int CVICALLBACK ScoopOk (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event == EVENT_COMMIT) RemovePopup (scooppanel); return 0; } /***************************************************************/ /* PANEL: SETUP FUNKTIEGENERATOR */ /***************************************************************/ // waarde meetspanning: contoleer meetspanning en offset op maximum int CVICALLBACK Umeet (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double umeet; double uoffset; if (event == EVENT_VAL_CHANGED) { GetCtrlVal (funkpanel, FUNKPANEL_UMEET, &umeet); GetCtrlVal (funkpanel, FUNKPANEL_UOFFSET, &uoffset); uoffset = fabs (uoffset); if ((umeet/2)+uoffset > 5) umeet=2*(5-uoffset); SetCtrlVal (funkpanel, FUNKPANEL_UMEET, umeet); } return 0; } // waarde offset: contoleer meetspanning en offset op maximum int CVICALLBACK Uoffset (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double umeet; double uoffset; if (event == EVENT_VAL_CHANGED) { GetCtrlVal (funkpanel, FUNKPANEL_UMEET, &umeet); GetCtrlVal (funkpanel, FUNKPANEL_UOFFSET, &uoffset); uoffset = fabs (uoffset); if ((umeet/2)+uoffset > 5) umeet=2*(5-uoffset); SetCtrlVal (funkpanel, FUNKPANEL_UMEET, umeet); } return 0; } // knop OK: sluit popup Funktiegenerator int CVICALLBACK FunkOk (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event == EVENT_COMMIT) RemovePopup (funkpanel); return 0; } /***************************************************************/ /* PANEL: METING */ /***************************************************************/ int CVICALLBACK SluitButton (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event == EVENT_COMMIT) RemovePopup (meetpanel); return 0; } int CVICALLBACK SaveButton (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event == EVENT_COMMIT) { if (FileSelectPopup ("c:\\Documents and Settings\\Freddy\\My Documents\\Meten\\Data", "*.txt", "*.txt", "Opslaan meetdata", VAL_OK_BUTTON, 0, 1, 1, 0, filenaam) > 0) { ArrayToFile (filenaam, filedata, VAL_DOUBLE, filerij, filecol, VAL_DATA_MULTIPLEXED, VAL_GROUPS_AS_COLUMNS, VAL_SEP_BY_TAB, 10, VAL_ASCII , VAL_TRUNCATE); SetCtrlAttribute (meetpanel, MEETPANEL_SAVEBUTTON, ATTR_DIMMED, 1); } } return 0; }