WIENER Product Discussion Forum Index WIENER Product Discussion
A place to Discuss WIENER products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Acquisition in list mode

 
Post new topic   Reply to topic    WIENER Product Discussion Forum Index -> Windows
View previous topic :: View next topic  
Author Message
ntgu2002



Joined: 02 Feb 2009
Posts: 5

PostPosted: Mon Feb 02, 2009 3:19 pm    Post subject: Acquisition in list mode Reply with quote

I have to acquisition in list mode. Trigger signal by LAM.

As I understand, it is necessary:
1. Load command stack, using function xxusb_stack_write (I need read N=11, A=0, F=2), i.e. stack should contain: 0x0001, 0x1602?
2. Write LAM mask using CAMAC_write_LAM_mask.
3. Start acquisition by setting bit 0 of the Action Register to 1. I should use xxusb_register_write or CAMAC_register_write?
4. Then I have to read the USB port In FIFO in a loop using xxusb_bulk_read? How?

Could you give an example how to make it on c ++.
Back to top
View user's profile Send private message
aruben



Joined: 08 Jun 2007
Posts: 46
Location: Springfield, OH

PostPosted: Tue Feb 03, 2009 9:32 am    Post subject: CC-USB stack mode example Reply with quote

Hi, here is an example for stack mode operation. Please note that you have to drain all data from the buffer when ending DAQ mode.

//-------------------------------------------------------------------------
// Read LeCroy 2249A im LAM triggered DAQ mode
// A. Ruben 06/22/07
// tested with 2249 in slot 15 / LAM-mask 0x4000 and up to 10kHz rate 06/20/07
// tested with C-EMU in slot 2 / LAM-mask 0x2 at 10kHz pulser rate 06/22/07
//-------------------------------------------------------------------------
int CCUSB_Test_DAQ_read_2249 (usb_dev_handle *hdev, long loops, long trigger_rate, long LAM)
{
long stack [100];
int i,j,k,k_loops, error_count=0, events=0, event_size=0;
// unsigned int IntArray [10000]; //-> produces 32 bit data structure, use only with event alignment!
short IntArray [10000]; //for FIFOREAD
// char * ByteAP;
long data_lines;
long CEMU_ct_0, CEMU_ct, CamN;
int ret,CamQ, CamX;
int CAM_2249=2; // station number for 2249 ADC
// prepare stack and load to CC-USB
CamN=(CAM_2249<<9);
stack[0] = 0x0F; // number of lines to follow
for (i=0; i<=11; i++) stack[i+1] = CamN+(i<<5); // Read C-EMU N(in bits 9-13) F(0) A(i) for counter
stack[13] = CamN+0x0009; // CLEAR LAM N()with F(9) A(0)
stack[14] = 0x0010; // add marker
stack[15] = 0xffff; // marker = ffff
ret = xxusb_stack_write(hdev, 2, stack);
// Prepare LeCroy ADC (enable LAM)
ret = CAMAC_read(hdev, CAM_2249, 0, 26, &CEMU_ct_0,&CamQ, &CamX);
// Define Trigger LAM=0 -> extern, otherwise LAM
ret = CAMAC_write(hdev, 25,9,16,LAM,&CamQ, &CamX);

// set buffer to 4092
// Set buffer size to 4k BuufOpt in Global Mode register N(25) A(1) F(16)
ret = CAMAC_write(hdev, 25, 1, 16, 0x0,&CamQ, &CamX);

// Prepare data file
data_file = fopen("CCUSB_test_2249.txt","w");
fprintf(data_file,"CC-USB test data file \n");
// START DAQ
// printf("switch to DAQ & Reading data\n");
// Start DAQ mode
ret = xxusb_register_write(hdev, 1, 0x1); // start acquisition
k_loops=0;
while(k_loops<loops) // number of loops to read
{
ret = xxusb_bulk_read(hdev, IntArray, 8192, 100); // use for 32-bit data
data_lines = ret / 2;
event_size = (IntArray[1] & 0xffff);
if (event_size > 0x100) event_size = 0x100;
if (data_file !=NULL)
{

if(ret>0)
{
events = (IntArray[0]& 0xffff);
// printf("Events in loop %i : %i\n ",k_loops, events);
for (j=0; j<=data_lines; j++) fprintf(data_file,"%hx \t",IntArray[j]);
}
else
{
error_count ++;
printf("no read\n");
}
fprintf(data_file,"\n");
}
k_loops ++;
}
// leave DAQ mode
xxusb_register_write(hdev, 1, 0x0);
// drain all data from fifo
ret=1;
k=0;
while(ret>0)
{
ret = xxusb_bulk_read(hdev, IntArray, 8192, 100);
if(ret>0)
{
// printf("drain loops: %i (result %i)\n ",k,ret);
k++;
if (k>100) ret=0;
}
}
// in case still DAQ mode -> leave!!!
// xxusb_register_write(hdev, 1, 0x0);
fclose(data_file);
return 0;
}

_________________
Andreas Ruben

WIENER, Plein & Baus, Corp. - Springfield, OH
aruben@wiener-us.com
(937) 324 2420
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ntgu2002



Joined: 02 Feb 2009
Posts: 5

PostPosted: Tue Feb 03, 2009 10:05 am    Post subject: Re: CC-USB stack mode example Reply with quote

thanks for the fast reply!!
Back to top
View user's profile Send private message
ntgu2002



Joined: 02 Feb 2009
Posts: 5

PostPosted: Wed Feb 04, 2009 9:02 am    Post subject: ERROR! Reply with quote

Hello again! I have problem with your code.

In a manual_CC-USB_2_7_1.pdf description of the function the following:

WORD xxusb_bulk_read{
HANDLE hDevice,
CHAR *pData,
WORD wDataLen,
WORD wTimeout
};

In your code, you use instead of array char array short,
like this:
short IntArray [10000];
xxusb_bulk_read(hdev, IntArray, 8192, 100);

then I have an error:
error C2664: 'xxusb_bulk_read' : cannot convert parameter 2 from 'short [10000]' to 'char *'

if I use char array:
char IntArray[10000];
xxusb_bulk_read(hdev, IntArray, 8192, 100);

then:
error LNK2019: unresolved external symbol "short __stdcall xxusb_bulk_read(struct usb_dev_handle *,char *,short,int)" (?xxusb_bulk_read@@YGFPAUusb_dev_handle@@PADFH@Z) referenced in function "public: void __thiscall CNAF06Dlg::OnBnClickedStart(void)" (?OnBnClickedStart@CNAF06Dlg@@QAEXXZ)
Back to top
View user's profile Send private message
aruben



Joined: 08 Jun 2007
Posts: 46
Location: Springfield, OH

PostPosted: Wed Feb 04, 2009 11:04 pm    Post subject: Reply with quote

I assumethere is something else wrong. I can compile this with visual studi 7 without a problem. Defining only the pointer the data can be even accessed as 32 bit words, i.e.

unsigned int IntArray [10000]; //-> produces 32 bit data structure, use only with event alignment!

// short IntArray [10000]; //for FIFOREAD
// char IntArray [10000]; //for FIFOREAD

will work too! I just tested all 3 different tyoes and got no compilation error!

_________________
Andreas Ruben

WIENER, Plein & Baus, Corp. - Springfield, OH
aruben@wiener-us.com
(937) 324 2420
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ntgu2002



Joined: 02 Feb 2009
Posts: 5

PostPosted: Fri Feb 06, 2009 8:16 am    Post subject: Reply with quote

I think, if you can compile that code, maybe something wrong with
.lib/.dll/.h?!
I have XX-USB version 3.5 from wiener-d.com
From "XX-USB_CD3_5\MS-Windows C++\EasyCAMAC demo-c" I took the
xxusbdll.h and add to my project.
Also the files: libxxusb.lib, libxxusb.dll, libusb0.dll I've put in to
the directory with the program.
And in the property of a project in: Linker->Input->Additional
Dependencies, I have written "libxxusb.lib".

All is correct?

Could you send me an example project (visual c++) with all libraries!?
Back to top
View user's profile Send private message
aruben



Joined: 08 Jun 2007
Posts: 46
Location: Springfield, OH

PostPosted: Fri Feb 06, 2009 10:25 am    Post subject: Reply with quote

Hi,
I got your mail and will send he complete visual studio project later today.

_________________
Andreas Ruben

WIENER, Plein & Baus, Corp. - Springfield, OH
aruben@wiener-us.com
(937) 324 2420
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ntgu2002



Joined: 02 Feb 2009
Posts: 5

PostPosted: Fri Feb 06, 2009 11:56 am    Post subject: Reply with quote

Thank you very much!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WIENER Product Discussion Forum Index -> Windows All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group