High-Speed Digitizers

cancel
Showing results for 
Search instead for 
Did you mean: 

C example code for programming two PXI 5124 cards?

Hello,

 

We are in the process of upgrading a two-channel digital acquisition system to 4 channels. We purchased a PXI chassis and two 5124 cards. I have my existing code working for two channels, but need to figure out how to handle triggering so that both cards acquire data on every trigger.

 

Is there any example C code that can show me how I might do this? I couldn't find anything appropriate in the included example code that comes with niscope.

 

Not sure if it's helpful, but my current code (which isn't correct, since each card gets every other trigger)  uses the following:

 

niScope_InitiateAcquisition (vi1)

niScope_Fetch (vi1, channelName, timeout, actualRecordLength, start_of_outmtrx, wfmInfoPtr)

 

niScope_InitiateAcquisition (vi2)

niScope_Fetch (vi2, channelName, timeout, actualRecordLength, start_of_outmtrx, wfmInfoPtr)

 

Thank you,

Nathan

0 Kudos
Message 1 of 5
(6,430 Views)

Howdy Nathan!

 

When you say that each card gets every other trigger do you mean:

 

Trigger sent - Card A & B triggered

Trigger sent - Nothing triggered

Trigger sent - Card A & B triggered

Trigger sent - Nothing triggered

etc...

 

OR

 

Trigger sent - Card A triggered

Trigger sent - Card B triggered

Trigger sent - Card A triggered

Trigger sent - Card B triggered

etc...

 

Also:

 

What is the source of your trigger?

 

How do you have the trigger source connected to the system?

 

How are you configuring the triggers in code?

 

What are you doing for clock synchonization between the two cards?

 

Regards,

Barron
Applications Engineering
National Instruments
0 Kudos
Message 2 of 5
(6,407 Views)

Hi Barron,

 

Sorry for the delay - been a hectic week.

 

 


@>> The Red Barron wrote:
>> Howdy Nathan!
>> When you say that each card gets every other trigger do you mean:
>> Trigger sent - Card A & B triggered
>> Trigger sent - Nothing triggered
>> Trigger sent - Card A & B triggered
>> Trigger sent - Nothing triggered
>> etc...
>> OR
>> Trigger sent - Card A triggered
>> Trigger sent - Card B triggered
>> Trigger sent - Card A triggered
>> Trigger sent - Card B triggered
>> etc...

I was getting the latter. Turned out my problem was pretty obvious. I had code that was basically:

Configure cards to fetch one waveform at a time
for k=1:N
  init(Card1)
  fetch(Card1)
  init(Card2)
  fetch(Card2)
  update display
end

(Sorry for the pseudocode - I'm away from the computer with the actual code on it)

This worked with one card, but with 2 cards, the first card would get the first trigger, the second would get the second trigger, etc.

I switched it to:

Configure cards to fetch N waveforms at a time
init(Card1)
init(Card2)
for k=1:N
  fetch(Card1)
  fetch(Card2)
  update display
end

This works great for my application, but I noticed if my triggers come at a very fast rate, the cards are not getting the same data. I assume that if a trigger comes between the two "init" commands above, the second card will be one trigger behind. If I wanted to fix this, maybe I'd need to get the special cable to synchronize the two cards?

One more question: if I want to abort the measurement before the card gets all the triggers, what is the best command to use? Resetting the card works, but maybe it's not best?

>> Also:
>> What is the source of your trigger?
>> How do you have the trigger source connected to the system?
>> How are you configuring the triggers in code?
>> What are you doing for clock synchonization between the two cards?

 

 

I am using an external function generator as the source for my trigger, and I simply use a BNC T-connector to trigger both cards.  I am not getting data at a very fast rate (I'm grabbing 10ms of data at a time in 100k waveforms every 100ms). At this rate, things appear to be synchronized. I assume that if I want to get more data more quickly (or to guarantee synchronization) I should get the cable to synchronize the cards.

 

-Nathan

0 Kudos
Message 3 of 5
(6,371 Views)

Since you are using a PXI system you should can synchonize the two cards without needing any external cables.  Clocks and trigger signals can be shared along the backplane of the chassis.

 

I would recommend looking over the NI-Scope examples, specifically the "MultiDeviceConfiguredAcquisitionTClk" example.  You can find them by going to Start>>Programs>>National Instruments>>NI-SCOPE>>Examples.

 

Regards,

Barron
Applications Engineering
National Instruments
0 Kudos
Message 4 of 5
(6,345 Views)

Sorry again for the delay - I was traveling. Thank you for your suggestion - I will check out the instructions on how to synchronize the cards.

 

-Nathan

0 Kudos
Message 5 of 5
(6,271 Views)