Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a PXI-6562, can I acquire data with length determined by start and stop pattern triggers?

I have a PXI-6562, and I am writing a VI that reads data off an SPI bus in 16-bit word increments. I want the VI to begin sampling data when the CS line goes low, and then to stop sampling data when the CS line goes high.

 

I am able to get the acquisition to start using a pattern "Start Trigger" block with the pattern 'F' for a falling edge. However, when I have tried adding any combination of "Reference Trigger," "Advance Trigger," and "Pause Trigger," I'm not getting the data that I expect. In fact, most of them end up timing out on the acquisition. In particular, I expect the length of the data to be a function of the trigger times and the sample rate.

 

Here's how I expect it to behave: given a start trigger and a sample rate and a maximum data acquisition size, begin acquiring data on the start trigger pattern, and then stop acquiring when the stop pattern is reached. Then return the data found between start and stop triggers.

 

The documentation includes the following state diagram for acquisition triggering:

State Diagram with title.PNG

 

... based on this, it seems that I should be able to do this. Yet, the VIs always return the number of data points that were allocated at the start of the acquisition, rather than the number of points between start and stop.

 

Is is possible to get data with length dependent on trigger times? If not, is there another way to do this without analyzing the whole waveform in software?

0 Kudos
Message 1 of 12
(4,761 Views)

The best way to approach the type of acquisition that you are working with would be to use both a Start and a Reference Trigger. The Start trigger actually allows the device to respond to a sample clock, and the reference trigger will allow us to set the number of pre an post-reference trigger samples to actually acquire. If we configure the Start trigger to activate when the CS line goes low, that would allow the pre-trigger samples taken by the Reference Trigger to begin. We would want to set the post-trigger samples to zero, such that we take all pre-trigger samples with the reference trigger. We could then use the Reference trigger source as the CS line going high, such that we would stop acquiring when we got to that trigger point. So, use a start trigger to initiate the acquisition, and a reference trigger setup to take all pre-trigger samples, and configured at the end point of the acquisition (the 2nd trigger).

Timothy S.
Senior Technical Support Engineer
0 Kudos
Message 2 of 12
(4,755 Views)

Thanks Timothy. I'm eager to try this out. Using an niHSDIO property node VI, I am able to set the number of pre-trigger samples (RefTrig.PretrigSamples), which, I assume is the minimum number of pre-trigger samples. But I don't see any property or VI for setting the post-trigger samples.

 

How do I ensure that the post-trigger samples are set to 0?

 

Thanks,

Arthur

0 Kudos
Message 3 of 12
(4,751 Views)

Arthur,

 

The number of post-trigger samples is determined based on the number of samples per channel you configure the task to acquire, and the specified number of pre-trigger samples set with the Reference Trigger.

The post triggers will simply be the total samples set to acquire minus the specified pre-trigger samples. You would simply need to work to ensure that those numbers line up with what you are expecting to see and go from there.

Timothy S.
Senior Technical Support Engineer
0 Kudos
Message 4 of 12
(4,740 Views)

It sounds like I have to know how many data points that I want to collect before I start the acquisition. I'm trying to set it up, so that it acquires a record whose length in samples is unknown, except that it doesn't exceed some maximum. I want the returned data to be truncated at the "stop tigger," which it looks like would be the reference trigger.

 

Referring again to the SPI port, the start of the signal begins with the CS line low, and then ends with the CS line high. Let's say I'm sampling with the HSDIO at 100MHz, and my SPI clock signal is 2MHz. The SPI data I acquire may be 4-bit, 8-bit, 12-bit, or 16-bit words. At 2MHz with no trail/lead time, that corresponds to 20us, 40us, 60us, and 80us expected signal durations. At 100MHz sampling rate, my data acquired is 200, 400, 600, or 800 samples, respectively. 

 

If I acquire a 4-bit word, then I want to configure the task so that it returns only 200 samples, and then immediately begin setup for the next trigger. If I get a 16-bit word, I want the same setup to return 800 samples, etc. In a multi-record acquisition, I might get a series of words of varying sizes on the same SPI port. Is it possible to have the same acquisition task accommodate them all without returning extra samples on the shorter words?

 

Thanks for your help!

Arthur

0 Kudos
Message 5 of 12
(4,736 Views)

Arthur,

 

I've gathered some more resources for us to look through in this situation. Another possible way for us to approach this triggering methodology would be to use a start and then a Pause trigger (Trigger Summary, Configure Triggers). We would be using the pause trigger to pause the acquisition when we receive the second trigger so that we can stop the data where we want it.

 

Other resources in general for SPI to have access to are the SPI Digital Waveform Reference Library, as well as Serial Protocol Communication Reference Design for Digital Waveform Devices . There is also another forum thread dealing with SPI that may have further information located here.

Timothy S.
Senior Technical Support Engineer
0 Kudos
Message 6 of 12
(4,719 Views)

Hi Timothy,

 

Thanks for the info. I've been using information from the links that you sent. They are helpful in general, though neither addresses the specific triggering problem we're looking at here. The SPI Digital Waveform Reference Library has convenient functionality for generating waveform data, but doesn't do any hardware communication; and the Serial Protocol Communication Reference Design for Digital Waveform Devices shows how to do hardware communication, but all of the examples require knowing how many samples to acquire per record.

 

I see the pause trigger you mentioned in the help, and it sounds promising, but it is not illustrated in the state diagram for dynamic acquisition. Can you give an example of how it is used?

 

Also, if I want to acquire multiple variable-length records, will the start-trigger or advance-trigger work once the acquisition has been paused by the pause-trigger?

 

Thanks,

Arthur

0 Kudos
Message 7 of 12
(4,705 Views)

Arthur,

 

If we are trying to do multiple multi-record acquisitions separated by the second trigger signal, that would actually be workable with the advance trigger, as we could set the first trigger as the start trigger, and the second trigger (our stop trigger) set to the advance trigger. This would cause a new record to be created each time we received the second trigger, thereby allowing for multiple variable length records. Let me know if I'm misunderstanding what you're getting at here. There is an example working with this type of setup at http://zone.ni.com/devzone/cda/epd/p/id/5020 though this example uses the same trigger for start and advance.

Timothy S.
Senior Technical Support Engineer
0 Kudos
Message 8 of 12
(4,691 Views)

Hi Timothy,

 

The multi-record acquisition pretty much takes care of it, except that there's dead space between the data being sent on the line. In the linked example, the end of one record marks the beginning of the next record, and in my case there is dead time between the end of one record and the beginning of the next. The start of a record is marked by a falling edge of the CS line, and the end of a record is marked by a rising edge of the CS line.

 

I just learned that I have an old version of the HSDIO drivers installed (1.5.3), and that the latest version includes some support for using a pause-trigger during continuous acquisition. I think that might be the solution I'm looking for if it works. I had tried yesterday to get a continuous acquisition to do what I'm describing, but it didn't work. I'll post here after I've tried with the new drivers.

 

I realize also now that once I get this to work, I might be painting myself into a corner with the trigger rearm speeds: if I don't get enough sample-clock cycles between data words on the SPI line, then I might miss some trigger events, in which case I'll have to collect the data in bulk (continuous acquisition) and analyze it in software for the active/inactive locations. There's a table in my manual for the PXI-6562 that lists rearm times for start-to-reference, start-to-advance, and reference-to-reference triggers, but it doesn't specify anything about start-to-pause or pause-to-start. If you have any info on that, it would be helpful.

0 Kudos
Message 9 of 12
(4,688 Views)

Arthur,

 

Everything I could find in relation to rearm times with regards to the pause trigger points to them being in the same range as the start to reference and advance triggers. I'll do a bit more research to see if I can come down with something more specific, but there shouldn't be a large difference between that rearm time and the start to advance trigger times.  Thank you for checking on the drivers as well. Hopefully we won't run in to any walls with the rearm times. In general, the easiest way to approach this would likely be some setup of post processing based on your system needs and the available triggers for acquisitions on the device, but it would be great if we could get this working via hardware triggers as well.

Timothy S.
Senior Technical Support Engineer
0 Kudos
Message 10 of 12
(4,681 Views)