Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Use NI USB-6211 to count TTL rising edge

Solved!
Go to solution

Hello,

 

I am new to NI-DAQ cards, and so before buying anything would like to know if it is possible to use a NI USB-6211 device

to count and bin rising edges of an TTL signal.

 

What I want to do is count how many rising edges of an TTL signal I get in a period of 1ms; a sampling rate of 20 Mhz should be fine.

 

I would like to use Matlab to control and read from the USB-6211 the number of counted edges as well as in the meantime write and read additional digital I/O ports.

 

Is it maybe possible to let the external TTL signal trigger one of the 6211 counters, an then periodically ( after 1ms ) output and reset its counter value?

 

Is that possible, and if so, is it a good idea?

 

Thank you and regards,

Manuel

0 Kudos
Message 1 of 8
(8,706 Views)

Hey Manuel,

 

it is a little bit hard to understand all of your requirements but I will try to answer your questions.

 

What I want to do is count how many rising edges of an TTL signal I get in a period of 1ms; a sampling rate of 20 Mhz should be fine.

-> Take a look at this page

    Buffered Event Counting - Developer Zone - National Instruments
    https://www.ni.com/en/support/documentation/supplemental/21/buffered-event-counting.html
    You need to generate the 1ms periode with the second counter of the card, if you don't get the 1ms periode from a other device. This is possible, so that you generate the 1ms period with the second counter and propagate the signal to the gate input of the first counter. 20 Mhz is also possible.

 

I would like to use Matlab

->  You could found all the supported hardware at this page:

     MATLAB NI-DAQmx - Supported Hardware - National Instruments - Data Acquisition Toolbox - MathWorks Deutschland
     https://www.mathworks.de/products/daq/supported/ni-daqmx.html

Write and read additional digital I/O ports

-> Possible with LabVIEW, so that should also be possible with Matlab.

 

Is it maybe possible to let the external TTL signal trigger one of the 6211 counters, an then periodically ( after 1ms ) output and reset its counter value?

-> I don't understand your question

 

 

Regards, Stephan

0 Kudos
Message 2 of 8
(8,691 Views)

Hello Stephan,

 

thank you very much for your reply.

 

I in the meantime as well found out that the NI card offers what is called Buffered Event Counting and as you described it propably

would do the trick.

 

My only concern is with matlab and if it really supports using the counter in this way. The USB-6211 is in general supported by the Data Acquisition Toolkit, but

in order to use any counter functionality one has to use the sessioin based interface of the DAQ Toolkit ( https://www.mathworks.de/help/daq/working-with-the-session-based-interface.html ) ( which only works on matlab 2011a 64bit ).


For me the question is now if the DAQ toolkit supports Buffered Event Coutning.

 

 

About my unclear question:

 

     Is it maybe possible to let the external TTL signal trigger one of the 6211 counters, an then periodically ( after 1ms ) output and reset its counter value?

       -> I don't understand your question

 

I wanted to ask if it would be possible to not let the counter continue counting after 1ms, but reset it to zero.

As I understand, when using the Buffered Event Coutning, I would have to process the results further, calculating the difference between each stored value

in order to get the number of triggers. I hope it makes no problem to let the counter overflow. It will start counting again from zero I guess?

 

Regards,

Manuel

0 Kudos
Message 3 of 8
(8,686 Views)

Hi Manuel,

 

as far as I know, it is not possible to reset the counter to zero after 1ms with this card. This is should be possible in software, but I don't know if its possible by the hardware counter itself. If you use Buffered Event Counting, you have to calculate the difference between each stroed value. If the counter reaches the maximum value (2^32 bit), it will roll over to 0.

 

Stephan

0 Kudos
Message 4 of 8
(8,682 Views)

Hi manuel,

 

take a look at page 8-7 (104) at the manual

 

https://www.ni.com/docs/en-US/bundle/usb-621x-manual/resource/usb-621x-manual.pdf

 

The Buffered Period Measurement looks like the thing which can helps you. The counter is reset after every periode (e.g 1ms) back to 0.

0 Kudos
Message 5 of 8
(8,678 Views)

Hi Stephan,

 

thank you very much. True the Buffered Period Measurement sounds like a good option.

I would then generate a rectangular signal with a rising edge every 1ms and connect it to the Gate of the counter.

 

In order to generate this signal I could use a second timer in Continuous Pulse Train Generation mode, right?
But as the 6211 has only two counters, I would rather find an alternative way to generate this triggering signal.

 

Can you think of any way to do so, that needs no interaction on the software side. What i mean is that i simply

configure the card, continuously producing this trigger every 1ms?

 

Regards,

Manuel

0 Kudos
Message 6 of 8
(8,673 Views)
Solution
Accepted by topic author PasiekaM

Hi manuel

 

In order to generate this signal I could use a second timer in Continuous Pulse Train Generation mode, right?

-> Right. You can choose between 2 possible solutions

1) Get the signal from another device, e.g. signal generator or something like that. If you can't use such a device, you have to choose the second solution ->

2) Generate the 1ms periode square wave with the second counter of the USB-6211

 

I don't know a smart way to generate the 1ms periode signal without the software side. You need the software to configurate the second counter, route the signal from the second counter to the first counter and so on.

 

Maybe you could use the so called "test panel" inside the Measurment & Automation Explorer to generate the signal. The Measurment & Automation Explorer is a tool delivered with the driver for the DAQ-cards. The original purpose of this software utility is to configurate your hardware, test it and so on.

I don't know if this works, but I imagine the following solution:

You use the so called test panel inside the Measurment & Automation Explorer to generate the 1ms periode signal (see attached screenshot and https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGZPCA4&l=en-US). You don't need any additional program to run the test panel. On the USB-6211 you use a wire to connect the output signal from the second counter to the imput to the first counter. After that, you run the test panel with the signal generation for the second counter. At the same time you start your Matlab program and configurate only the first counter. You have to run the Testpanel all the time if you want to run your measurment.

Not very nice, but maybe the only solution.

 

Regards, Stephan

0 Kudos
Message 7 of 8
(8,665 Views)

Hi Stephan,

 

thank you. I will use the first counter in in Buffered Period Measurement mode and the second one in Continuous Pulse Train Generation mode, will physically connect the second clock to the gate of the first one and than use the first one to count the rising edges of the incoming TTL signal.

 

What I mend in my last post about  trying without software, is that I have to use both of the counters of the NI card to analyze the TTL signal.

In the best of cases I would have reader only used one of them in Buffered Period Measurement mode and trigger it every 1ms by one of the other digital I/O pins.

Without software I mend that this trigger should come from the NI card itself, without being ordered by my Matlab script; as I cant guarantee the script

to repeatedly trigger the I/O signal each 1ms. So i will use the second clock, configure everything once and then only read the output buffer of the first one.

 

Thx,

Manuel

0 Kudos
Message 8 of 8
(8,654 Views)