Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

NI USB 6259 digital input read

Solved!
Go to solution

Hi all,

 

I must admit I am unexperienced with DAQ cards (just done some simple stuff in past). We just got the NI USB 6259 card. The plan is to use it for many tasks. One of them is a measuring digital signal at the maximum rate. So far I tried ti create a task in MAX - what I was able to achive was to measure 500 - 700  samples at 1 Mhz using N samples measurment. In order to have sample rate at 1 Mhz I use External clock PFI12 (counter 0 output - I set the counter to generate 20Mhz Signal - 50ns/50ns High Time/Low Time).

 

The thing is - is it possible to get samples acquired at 1 MHz with continuous mode ? When I try with my current settings I get overflow error - I tried to ru tasks both ways - first started clock generator and then Digital Input; and the other way Digital Input first - so I assume that overflow is not due to improper usage.

 

In documentation it says :

If the DAQ device receives a DI Sample Clock when the FIFO is full, it reports an overflow error to the host software.

 

Is there another way to acquire digital signal, where one frame lasts around 6 ms and consists 8 bits ?

--------------------------------------------------
Regards,

PacHOOk
0 Kudos
Message 1 of 7
(5,003 Views)
Solution
Accepted by pachook
Pachook, 
 
In order to have buffered acquisition for Digital Input you have to:
1. Create Counter Output Task
2. Create Digital Input Task
3. Connect in DI Sample Rate (DAQmx Timing.vi) as source DevX/CtrXInternalOutput
4. Start DI Task
5. Start  Counter Task
Now you should be able to read digital samples. Remember to set number samples to read for 1/2-1/4 of the buffer.
 
I wanted to ask also why you want to have acquisition of 1MHz?  For 6ms frame, each bit last 0,75ms - this means that one bit is with 1.33kHz frequency. So you don't need so big sampling frequency.
The other way could be, but first I would have to know what is the signal.
Can you connect each bit to different channel?
Or each iteration you would like to have acquired one frame (in a loop) and later convert in to frames?
 
The overflow error can occur because USB bus cannot transfer data fast enough. Probably you have set to big sample rate (like 1MHz) and you're trying to read 8 samples per each iteration, which is way to little...
 
There are 2 documents that can be helpful:
1. Understanding and Avoiding Overwrite and Overflow Errors with NI-DAQmx: http://digital.ni.com/public.nsf/allkb/A224DA0551EEA073862574F60060AB6F?OpenDocument
2. Why Do I Get Error -200279 from my DAQmx Read VI or Property Node? http://digital.ni.com/public.nsf/allkb/AB7D4CA85967804586257380006F0E62?OpenDocument
 
Hope it will help at least at some point.
 
Regards,
Dawid 
0 Kudos
Message 2 of 7
(4,971 Views)

Thanks Dawid for help. I will try out the solutions as soon as possible. The reason to have the 1Mhz sampling rate is mainly because we have just got the card and I wanted to test all the possibilities with it, and according to spec it should be able to handle that task ( I agree that for the signal I was trying to read it was too big), but if we can why not try it 🙂

 

 

--------------------------------------------------
Regards,

PacHOOk
0 Kudos
Message 3 of 7
(4,943 Views)

Hi Pachook, 

 

I wanted to follow up with you, how things are going? Did you have a chance to check out your program and ideas given from me? 

 

Beside you can use 1MHz sampling frequency, but you have to read more samples at one time. Usually it's take like 1/2 or 1/4 of buffer size which is dependent on your sampling rate.  

 

Thanks,

Dawid 

0 Kudos
Message 4 of 7
(4,885 Views)

Hello Dawid,

 

yes I finally got enough time to do some tests with card and LV. I enclose my result program below.

 

And I also do have some remarks/advice for others :

 

  • During the test we observed that the loop has to be called exact times as the reading requires - if you read data from 100ms of a signal you should call a loop every 100 ms, when I set it to 110 I got an overflow error after a while - the fastes speed would be the best, but you should be aware of another actions; threads and so on
  • Beware where you are pluging in the card ( We have usb device) so that you could use full usb 2.0 performance
  • And it is good to do some more test with various settings, and let the test program run for a while - then you can be more sure about the overflows and overwrites.

 

And about the test program - it should work with 1 Mhz sampling rate, but only when I plugged it to full speed usb prt, for high speed front port or with the usb 2.0 hub I got an overflow error. I made it basing on NI examples - hopefully it is allowed 🙂

 

 

--------------------------------------------------
Regards,

PacHOOk
0 Kudos
Message 5 of 7
(4,824 Views)

Pachook, 

 

I'm glad that finally you have found enough time to work with it and finally it works. I just wanted to tell you that USB full speed standard allows you to send 12Mb/s this means 1,25MB/s. When using 1MHz and 16bit resolution (2B) then you're sending every second 2MB. That is why you have to use in those speed USB high speed, which can transfer up to 60MB/s (theoretically). 

 

Beside if you were using simple while loop you don't have to use delay and it that case next iteration would happen when the acquisition would be over (in that case ~100ms). 

 

Anyway I'm glad that finally you solved the problem:)

 

Regards,

Dawid 

0 Kudos
Message 6 of 7
(4,821 Views)

I agree what you said, I just couldnt remember the Full USB speed 🙂

 

And in previous version I also used the while loop, just later wanted to play with time loop too.

 

Anyway thanks for help and hopefully this thread here will help someone

 

🙂

--------------------------------------------------
Regards,

PacHOOk
0 Kudos
Message 7 of 7
(4,819 Views)