okies, i could help myself from trying, and indeed
I failed - I used lower level cmd read/write to try
to accomplish a fast polling of data. This didn't work
, mabe i'm doing things in the wrong order, please give some pointers. Also i'll try to use NI's IVI driver
for 8901a (lecroy).
code follows this never performer well even with the srq tries, now commented.
------------------------------------------------------
#include
/**************************************************************************
* This program initalizes and accesses the buffer data in the ADC 3512 by *
* CAMAC access. The speed is around 50ms and has the ablility to *
* freeze when disable is active on the pulse generator timing out in *
* 10s. *
*Switch settings are equal to 4.1.2.2 in ADC manual with internal switch * *
* set for internal buffer mode. Rear jumper set LAM active with * *
* 2 bytes in buffer.7 *
***************************************************************************/
#include
#include
#include
#include
char GetSerialPollResponse(int);
int initalizeboard(void);
int initalizedevice(void);
void SetupADC(int);
short GetSRQ(int);
static int MyDev;
static int Myboard;
unsigned int MyRead[1] = {0};
unsigned int MyRetn[1] = {0};
static int listen_current;
static int unlisten_current;
static int talk_current;
static int unlisten;
static int untalk;
int main()
{
int r=0, c,k=0,j;
short srqq;
unsigned int a,b[10],d[5],g;
unsigned int data[2048];
char e,f;
double volts;
FILE *fp;
fp = fopen("testdata.txt","wb");
Myboard = initalizeboard();
MyDev = initalizedevice();
SetupADC(MyDev);
//srqq gets status of SRQ wait either 1 or 0
srqq = GetSRQ(MyDev);
GetSystemTime (&d[1],&d[2], &d[3]);
printf ("%d:%d:%d\n",d[1],d[2],d[3]);
fprintf (fp," %d:%d:%d\n",d[1],d[2],d[3]);
//if srqq is not 1 there is no data to be read the program will end
g=time(0)+10;
//if (srqq == 1)
if(1)
{
do
{
//initiates destructive read of 3512 buffer.
d[3] = time(0);
// for (j=0;j<2048 && srqq == 1;j++) {
// for (j=0;j<2048;j++) {
if(srqq==1){
ibwrt (MyDev, "\x01\x00\x12", 3);
ibrd (MyDev, MyRead, 2);
data[1] = MyRead[r] & 8191;
//fwrite(&k,sizeof(k),1,fp);
//fwrite(&d[3],sizeof(d[3]),1,fp);
k++;
//initializes LAM for 3512
// ibwrt (MyDev, "\x1a", 1);
// ibrd (MyDev, MyRetn, 2);
//gets status of SRQ signifing data is ready to be read.
//srqq = GetSRQ(MyDev);
//If srqq is not 1 again the program will end
}
// fwrite(data,j*4,1,fp);
//initializes LAM for 3512
// ibwrt (MyDev, "\x1a", 1);
// ibrd (MyDev, MyRetn, 2);
//gets status of SRQ signifing data is ready to be read.
//srqq = GetSRQ(MyDev);
//If srqq is not 1 again the program will end
}
while(d[3] //while (srqq == 1);
GetSystemTime (&d[1],&d[2], &d[3]);
printf ("%d::%d:%d:%d\n",k,d[1],d[2],d[3]);
}
fclose(fp);
// CloseDev (Myboard);
scanf("%d",&d[1]);
return 0;
}
int initalizeboard()
{
//Initalizes the gpib board (not 8901a)
Myboard = ibfind ("gpib0");
//Myboard = OpenDev ("gpib0", "");
ibpad (Myboard, 0);
ibrsc (Myboard, 1);
ibsic (Myboard);
ibsre (Myboard, 1);
//disables autoserial polling so the status of SRQ can be utilized.
ibconfig (Myboard, IbcAUTOPOLL,0 );
return Myboard;
}
int initalizedevice()
{
static char bajsa[40];
MyDev = ibdev (0, 2, NO_SAD, T10s, 1, 0);
unlisten_current = 0x20 + MyDev;
talk_current = 0x41;
//unlisten= 3f;
//untalk = 5f;
//bajsa[0]=0x20;
bajsa[0]=listen_current;
//clear CAMAC
ibcmd(Myboard,"\x21",1L);
// ibwrt (MyDev, "\x22", 1);
ibwrt (MyDev, "c", 1);
ibcmd(Myboard,"\x3F",1L);
// bajsa[0]=0x20;
bajsa[0]=talk_current;
ibcmd(Myboard,bajsa,2L);
ibrd (MyDev, MyRead, 4L);
//assert inhibit (no data collection)
ibwrt (MyDev, "\x48", 1);
ibrd (MyDev, MyRetn, 2);
//set up for high speed block read 16bit
ibwrt (MyDev, "\x7A", 1);
ibrd (MyDev, MyRetn, 2);
//initalized CAMAC
ibwrt (MyDev, "\x21", 1);
ibrd (MyDev, MyRetn, 2);
return MyDev;
}
void SetupADC (int MyDev)
{
//clears LAM and buffer
ibwrt (MyDev, "\x0a\x00\x12", 3);
ibrd (MyDev, MyRetn, 2);
//writes control register settings (current 2120h)(least signif 1st)
ibwrt (MyDev, "\x10\x00\x12\x20\x21", 5);
ibrd (MyDev, MyRetn, 2);
//enables LAM
ibwrt (MyDev, "\x1a\x00\x12", 3);
ibrd (MyDev, MyRetn, 2);
}
short GetSRQ (int MyDev)
{
short e, f;
char d = 0;
//enables SRQ on occurance of LAM
ibwrt (MyDev, "\x41", 1);
//waits for SRQ (data is available)
WaitSRQ (0, &e);
//runs serial poll
ibrsp (MyDev, &d);
//disables SRQ and clears Inhibit
ibwrt (MyDev, "\x40", 1);
//sends interface clear
ibsic (Myboard);
return e;
}
All advice concerning making fast DAQ GPIB wise with 8901a are most welcome.
best regards Anders.