Facebook
From frawafs, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 276
  1. // cw3konsola.cpp : Defines the entry point for the console application.
  2. //Kusy Mateusz, Wągrodzki Marek
  3. //
  4.  
  5. #include "stdafx.h"
  6. #include <windows.h>
  7. #include <math.h>
  8.  
  9. /*Dołączenie pliku nagłówkowego driver'a NI-488.2*/
  10. #include "ni4882.h"
  11.  
  12. extern char ErrorCodes[29][5]; //Kody błędów NI 488.2
  13.  
  14. void IEC625_prog(void *par);//prototyp procedury obsługi IEC-625.2
  15. //////////////////////////////////////////
  16. // parametry programu
  17. float a=50;
  18. float b=7000;
  19. int i=8; //ile probek na dekade
  20. float A=0.5;
  21. float O=0;
  22. float P6=0;
  23. float z;
  24. short ma=21;//multi
  25. short ga=10;//adres gene
  26. float freq[18];
  27. Addr4882_t result[2];
  28. char buffer[101];
  29.  
  30.  
  31. double count;
  32. short SRQasserteed;
  33.  
  34.  
  35. //////////////////////////////////////////
  36. // punkt wejścia programu konsolowego
  37.  
  38. int _tmain(int argc, _TCHAR* argv[])
  39. {
  40.         //wypisanie tekstu na ekranie
  41.         WriteTxt("Cw3. program NASZ IEC-625.2\r\n");
  42.         _Wait(); //zatrzymanie programu
  43.         //wywołanie funkcji obsługi IEC-625.2
  44.        
  45.         for(int j=0;j<18;j++)
  46.         {
  47.                 freq[j]=(float)50*(float)pow(10,(float)j/8);
  48.         }
  49.         IEC625_prog(0);
  50.         _Wait();
  51.         return 0;
  52. }
  53.  
  54. char komunikat[100];
  55.  
  56. /*
  57. Procedura systemu pomiarowego IEC-625.2
  58. */
  59. void IEC625_prog(void *par){
  60.         SendIFC(0);
  61.         EnableRemote(0, &ma);
  62.         EnableRemote(0, &ga);
  63.  
  64.         result[0]=(Addr4882_t)ma;
  65.         result[1]=(Addr4882_t)ga;
  66.         DevClearList(0,result);
  67.  
  68.         Send(0,ma,"*RST;*CLS",9L, NLend);
  69.         Send(0,ma,"*SRE 16;*OPC?", 14L, NLend);
  70.         Receive(0, ma, buffer, 2L, STOPend);
  71.         Send(0,ma,"CONF:VOLT:AC",12L,NLend);
  72.         Send(0,ma,"*OPC?",5L,NLend);
  73.         Receive(0, ma, buffer, 2L, STOPend);
  74.         Send(0,ma,"TRIG:SOURCE IMM",15L,NLend);
  75.         Send(0,ma,"*OPC?",5L,NLend);
  76.         Receive(0, ma, buffer, 2L, STOPend);
  77.         Send(0,ma,"DET:BAND 20",11L,NLend);
  78.         Send(0,ma,"*OPC?",5L,NLend);
  79.         Receive(0, ma, buffer, 2L, STOPend);
  80.         Send(0,ma,"DET:BAND 20",11L,NLend);
  81.         Send(0,ma,"*OPC?",5L,NLend);
  82.         Receive(0, ma, buffer, 2L, STOPend);
  83.         Send(0,ma,"SAMP:COUN 1",11L,NLend);
  84.         Send(0,ma,"*OPC?",5L,NLend);
  85.         Receive(0, ma, buffer, 2L, STOPend);
  86.  
  87.         Send(0,ga,"*RST;*CLS",9L, NLend);
  88.         Send(0,ga,"*OPC?",5L,NLend);
  89.         Receive(0, ga, buffer, 2L, STOPend);
  90.  
  91.  
  92.  
  93.         for(int j=0;j<18;j++)
  94.         {
  95.                 DevClear(0,ma);
  96.                 int len;
  97.                 short buf = 0;
  98.                 strcpy_s(komunikat,"\0");
  99.                 sprintf_s(komunikat,"APPL:SIN %f, %f, %f", freq[j],A,O);
  100.                 len=strlen(komunikat);
  101.                 Send(0,ga,komunikat,len,NLend);
  102.                 Send(0,ga,"*OPC?",5L,NLend);
  103.                 Receive(0, ga, buffer, 2L, STOPend);
  104.  
  105.                 Send(0,ma, "INIT",4L,NLend);
  106.                 Send(0,ma,"FETC?",5L,NLend);
  107.                 WaitSRQ(0,&buf);
  108.                 Receive(0,ma,buffer,16L,STOPend);
  109.                 printf("%s",buffer);
  110.         }
  111. }
  112.  
  113.