Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to “latch/hold” the value of counter output? (USB 6212)

I am new to NI DAQ devices. My project is to use linear encoder to measure position/length.

 

The input to the 6212 (i.e.. the output of the encoder) is digital pulses. I like to use the 6212 to count the rising edges of the input, i.e.. at every positive edge, the counter increments 1. When I am ready to read the counter’s output, I like to send a “latching/holding” signal (e.g.. an active HIGH) to the 6212 so that the counter’s output stops changing (the counter keeps counting), and after I am done reading (the “latching” signal goes to LOW), the counter’s output resume reflecting the already-counted numbers. The objective is to keep the counter’s output unchanged (“stable”) while reading, e.g.. I want to write the counter’s output to RAM but I don’t want the counter’s output change while I am doing this read/write process.  This function is like a gated / transparent latch – it either passes the input to output or holds, depending on the control signal.

 

Does the 6212 have this “latching/holding” function? If yes, any particular input port I should use, e.g.. one of the PFIs, or any port?  Can I program this function with NI-DAQmx?

 

Any help would be greatly appreciated.

0 Kudos
Message 1 of 7
(5,136 Views)

Hi lize,

 

This isn't exactly what you asked for, but it sounds like what you really need is a way to latch the value from the count register into memory based off of a hardware clock.  Something like this (from the 621x User Manual😞

 

2011-11-07_123359.png

 

You wouldn't need to hold the value during the entire state of the clock since the value of the counter is latched into a buffer on the edge of the clock and subsequent updates to the count regsiter do not affect the latched value.  Here is an example that shows the software configuration in LabVIEW.  You may use any of the PFI lines as a clock source.

 

 

Best Regards,

John Passiak
0 Kudos
Message 2 of 7
(5,126 Views)

Hi, John. Thank you very much for your quick and informative response.  I am studying the information you provided. 

 

A couple of questions/clarification points:

1. You mentioned "... latch the value from the count register into memory based off of a hardware clock." ---  the "memory" here means the "buffer" shown in the Fig 8-4 you included, correct?

2. How do I access/read this buffer/memory? e.g. At the Sampling Clock edge, I like to read/output the latched value in the buffer to an external SRAM or somewhere else so that I can analyze the data.

3. Assuming I configured the 6212 to achieve the desired function(s), can I download the configuration to multiple 6212s (one at a time) so that I can use the configured 6212s at different locations, like downloading a complied digital design to a FPGA, and the FPGA always has the designed function upon power up?  If this is doable, how?  While researching this question, I noticed that there is an Export feature in NI-DAQmx but I am not sure if that's the "downloading" feature I asked for here.

 

Thanks.

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

Hi lize,

 

1.  The value of the count register at the sample clock edge is stored in an on-board FIFO on your 6212.  DAQmx transfers samples from this FIFO to kernel memory on your host PC.  The transfer is usually done behind the scenes as the FIFO fills up.

 

2.  To get the data from the kernel buffer of your host PC, you call DAQmx Read in the Development Environment of your choosing (e.g. LabVIEW, C/C++, .NET).  The data is now transferred from kernel memory to your application, and you may do whatever you'd like with it at this point (including writing to file).

 

3.  The 6212 isn't like an FPGA--the code always runs on your host PC.  You can't deploy the application to the 6212 itself.  Any computer that you want to use to communicate with the 6212 must have drivers installed.  If you plan on deploying your application to other PCs you would probably want to build your program into an executable and deploy it along with the necessary drivers.

 

 

Best Regards,

John Passiak
0 Kudos
Message 4 of 7
(5,115 Views)

Ref. to the question/answer #3:

 

Without using the executable+driver solution you mentioned (which I'll research before I ask any questions), would the following procedure work for a multi-location deployment? (sorry if I am repeating what you said, I want to make sure I understood you correctly)

 

1. On the first computer, install and use NI-DAQmx to configure the first 6212, and export the configuration to a file

2. On the second computer, install NI-DAQmx and import the previously exported file/configuration for the second 6212

3. repeat step 2 for all the other 6212s

 

So, the final deployment will be multiple "computer-6212 pairs", i.e.  at each location, there is a 6212 that is connected to a computer, running NI-DAQmx and the configuration.

 

Thanks again.

0 Kudos
Message 5 of 7
(5,112 Views)

Hi lize,

 

In your case I'd probably suggest building an executable and putting all of the configuration within the software rather than exporting a configuration file.  What development environment are you using?

 

DAQmx actually comes in 3 possible distributions (Full, Config, and Core).  Your development system would require the Full version.  If you won't be writing DAQmx programs on the other systems, you can get by with installing the Config or Core versions.  Config includes Measurement and Autmation Explorer, whereas Core does not.  Much of the functionality (e.g. renaming devices) which available in MAX is also available programmatically.

 

 

Best Regards,

John Passiak
0 Kudos
Message 6 of 7
(5,107 Views)

Hi, John,

 

We are currently using a "home-grown" Visual Basic application to analyze the data, though we are considering other alternatives. 

 

Thank you very much again for all of your help.

0 Kudos
Message 7 of 7
(5,100 Views)