LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sample per channel and sample to read

Solved!
Go to solution

Hello everybody

I am new in LABVIEW and I have some difficulties with something.

I don t know exactly what is the difference between the sample per channel et the sample to read. I believe knowing that the sample per channel is the size of the buffer which is more big than the sample rate but I don t know what is the sample to read.

I ve tested with different sample per channel and sample to read. Sometimes I have an error and sometimes know and I would like to know why. If you have any example for I understand better, it will be great.

I really need to understand this part for my project

 

Thank for your help

 

Romaric GIBERT

0 Kudos
Message 1 of 7
(3,821 Views)
Solution
Accepted by topic author Roro8989

Hi Roro,

 

As you mentioned, when acquiring continuous samples you can specify the sample buffer size by placing a value at the input "samples per channel" on the timing vi. The "number of samples per channel" input on the read vi which automatically names a control/constant with "samples to read" specifies the number of samples you wish to pull out of the buffer in one go when reading multiple (N) samples. This link may provide a bit more clarification. I have also attached a good example from the NI example finder which you may find useful to explore. I'm assuming you are using the DAQmx driver set so please let me know if this is not the case, but the same principles should apply either way.  

 

This therefore means when sampling at a given rate, you need to ensure you are pulling data out in big enough 'chunks' to prevent the buffer from overflowing (which may well be causing the error you are seeing). Conversely if your sampling rate is slow and your read vi is having to wait for the number of samples to read you specified to be available, it may throw a timeout error. You can avoid this by either increasing your sampling rate, reducing your samples to read or increasing the timeout specified at the read vi input (-1 means it will wait indefinitely).

 

Let me know if this helps and how you get on.

 

All the best.

0 Kudos
Message 2 of 7
(3,806 Views)

Thank you for your help but my problem is not solve.

I explain you my problem,

I need to acquire 8 signals on 2 boards, but each boards has a different sample rate ( for example board 1 = 4kHz and board 2 = 2kHz)

So I need to save all my points in a TDMS File but I want only save 40000 samples for each TDMS. And the number of sample in a TDMS file depend on the sample to read.

So I don t know exactly what value can I put in sample to read if I have a sample rate of 4kHz or 2kHz. Can you help me please and say me how do you do to determinate the sampe to read?

 

Thank you very much

 

Romaric GIBERT

0 Kudos
Message 3 of 7
(3,795 Views)

Here is my VI

0 Kudos
Message 4 of 7
(3,791 Views)

Thanks for that, I was about to ask. Could you please provide me with your Log_Channels_(subVI) as well?

0 Kudos
Message 5 of 7
(3,787 Views)

Here is the LOG channel

Thank you

0 Kudos
Message 6 of 7
(3,784 Views)

Hi Roro,

 

I've had a look at your code and I've got some suggestions for you to hopefully get you on the way to achieving the desired functionality.

 

The first thing I would take a look at is the producer/consumer architecture for data. With this approach, you utilise parallel loops (consumers) all controlled by the main loop (producer) to ensure the correct sequence of operations within your code. For your scenario, you would typically look at performing the acquisition in your producer loop and then upon receiving 40000 samples pass this data down a queue to a consumer loop which would be waiting for it. Your producer loop can then carry on acquiring the next 40000 samples while your consumer loop writes the current batch of samples to your current TDMS file and creates the new file for the next batch when it is done. This way batches of 40000 samples from the producer loop can be built up in the queue and the consumer loop can deal with writing them to TDMS files at it's leisure.

 

Although it is not exactly what you are trying to achieve, this example gives a good idea of simple acquisition and data logging with TDMS using the producer/consumer architecture.

 

As for detecting when 40000 samples have been acquired, you could use the "AvailSampPerChannel" property of the DAQmx Read Node (Available in the DAQmx pallet). If you wire each task into a separate Node with this property and then perform some basic math to check when the total samples equal 40k, you could enter a case to then read all available samples from both tasks and dump them onto the queue.

 

Apologies if this is a lot of information in one go, but feel free to ask further questions about anything I've mentioned.

 

Let me know if this has been helpful.

0 Kudos
Message 7 of 7
(3,763 Views)