LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

11 bit counter using USB-6008

Hello,
 
I am trying to create a 11 bit counter using a USB-6008 DAQ.  I have tried to set the Digital Output Channel to "Digital U32 1 Chan 1 Samp" to increase the bits.  But currently the coutner will output up to the 8 bits of port 0, and then port 1 will always remain on (high).  I have the Channels declared on the front panel as "Dev1/port0:1".  That may not be the correct way to define the 2 ports, but that was how I did it.  Do I need to create to seperate tasks in order to do this using both ports?
 
What I am trying to do is to turn on each line at a timed interval.  So I set up an indexed array so that line 1 = 1 (00000000001), line 2 = 2 (00000000010), lin 3 = 4 (00000000100) , line 4 = 8 (00000001000), etc (converted the decimal to binary to figure out when the line would be on).
 
Also,  I am trying to have the data be aquired automatically.  The digital ports change once every 5 sec (that can be changed) and currently, you have to press the "Aquire Data Point" sometime in that 5 sec in order to get a RMS reading and other data stored into an array.  How can I time it so that there will be time for the voltage to "settle" (like 2-3 sec) and then I can read the voltage automatically and keep the digital ports changing every couple of seconds??
 
Thanks for your help.
 
Kenny
Kenny

0 Kudos
Message 1 of 6
(3,527 Views)
I attached a copy of my VI for reference.
Kenny

0 Kudos
Message 2 of 6
(3,529 Views)
I modified a shipping example to increment all the digital lines every iteration of the loop, it uses two tasks for the two different ports.  It treats Port 1 as the 4 most significant bits.  This VI will increment through every number from zero to the number specified as the 'upper limit' control, and output that number on the digital lines as a binary number.  If you wanted to turn on line 0, then on the next iteration, turn on line 1, then line 2 and so on, see this thread.  As far as your second question, about timing the ai, I'm not quite sure I understand completely.  Could you explain further? 
-Alan A.

Message Edited by Alan A. on 07-07-2005 05:02 PM

0 Kudos
Message 3 of 6
(3,503 Views)
Alan,
 
Thanks for your help again, I was able to get the VI working as I had hoped. 
 
As for the timing issue,  I have attached my updated VI with some comments written into the VI hopefully to better explain my problem.  I used LabView 7.1, let me know if you need it saved for the older versions or not. 
 
But here is what I am trying to accomplish:  Record data every 5 sec from the Analog Input, which correspondes to a change in the digital ports (which increment every 5 sec).  I created a timer loop which will count to 5 (with a Wait function set to 1 sec), output a boolean True, and then count to 5 again.  I inserted this into my VI, and it will work as expected (the timer loop) but my Analog Input will only record the first value it reads (because it is not on continuosly) and then will never read any other value except that first value.  I have tried using shift registers, and extra while loops, but I cant seem to get it to read coninuously and then record after 5 sec.
 
Thanks,
 
Kenny
Kenny

0 Kudos
Message 4 of 6
(3,488 Views)
Hello Kenny,
After looking at your block diagram, I have a few suggestions and a couple things to point out.
As for timing your analog input, a couple things come to mind (if I understand what you are trying to do).  You could use a local variable of your digital output data, feed it into a shift register, and each iteration of your ai loop, compare the current value to the previous value of the local variable.  Then, put your DAQmx Read in a case structure, and only do the read if the value has changed.
Another thing you could try is simply to let the ai control the timing.  If you wanted it to read and display data every 5 seconds, and you are sampling at 4 Samples per second, just put 20 for the input of the DAQmx Read VI (you will have to make the DAQmx Read a N Channel read) for number of sample to acquire.  If you do that, the Read will wait until it has all 20 samples before it returns.  20 samples at 4 samples per second would be 5 seconds. 
A couple LabVIEW suggestions.  First, NI-DAQmx Base is not multi-thread safe.  So, when you have multiple NI-DAQmx Base tasks, it is recommended that you force single-threaded execution by passing along the error cluster in sequentially (see attached picture for example) to all NI-DAQmx Base VIs.  Secondly, I noticed that your loop with the wait in it had no external data dependencies.  This means that the loop will execute whenever it can, not necessarily after stuff to the left or before stuff to the right.  It is a good idea to use data dependencies, by connecting it with wires.  Hope this helps.
-Alan A.
Message 5 of 6
(3,478 Views)
Kenny,

If you want to acquire the data continuously for one purpose (rms calculation) and intermittently for something else (current, power, resistance), then usually it works best to set up a parallel acquisition loop which runs continuously. Send the data via queues or functional globals (you can make a very nice circular buffer that way) to the parts of the program that do the calculations at various times. A state machine architecture is very useful for this type of project.

In the False case of the innermost loop you output a value of zero to a divisor input. This will produce a divide by zero error. It may just propagate NaN through your calculations, or it may cause other problems. I cannot tell enough about what you are trying to do to suggest an appropriate alterative.

Cleaning up your diagram can make it much easier for others (incluing your future self in about 6 months) to follow what you are doing.

Lynn
Message 6 of 6
(3,475 Views)