LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use a counter to measure frequency and multiple analog signals in the same VI?

I have a PCI-6071E, an SC-2345 with multiple modules, and a PXI-8184 (with a PXI-1002 Chassis).

My goal is to monitor pressures, flows, temperatures, and speed in one VI.
I am using Measurement and Automation Explorer version 3.1.1.3004 to manage my channels.

My speed is a PWM signal which I recently rewired through the counter 0 of my board.
I was hoping to configure this to read frequency directly in measurment and automation, have this scale the value to RPM, and then feed it directly in to my labView program.

In labView, it will not except this signal though.
I get error -200300 from the DAQmx Start Task.vi
-----
Possible reasons(s):

Invalid timing type for this channel.

Property: SampTimingType
You Have Requested: Sample Clock
You Can Select: Implicit, On Demand
----

After doing some research, it seems that the counter wants "Implicit" selected for the DAQmx Start Task.vi, but then I cannot use my other channels. Also, counter is included in the "Sample Clock" option description, so I do not understand why it is not working.

Does anyone know how to work around this problem or a way to configure the counter so that it will work in this way?

All my other channels are Analog.

Thank you.

0 Kudos
Message 1 of 11
(5,115 Views)
Hello,

I don't have the hardware to test it, but I would try it like this :


Message Edité par TiTou le 03-29-200610:20 AM


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 11
(5,107 Views)
This configuration may very well work to measure speed with the counter. I do not know how to integrate it along with the other channels though.

As you can see from the attached file, I am pulling in multiple channels by using arrays.
I then determine how many values are in each array, and that is used to handle each set of inputs differently.

I need a way that I can feed my counter input through the same set of channels, or a way to run two separate sample programs simultaneously.

Let me know if you need more information.

Thank you.
0 Kudos
Message 3 of 11
(5,088 Views)
Hi,
The counter operation will not affect the analog input acquisiton as long as the analog input isn't retriggerable. This is because retriggerable acquistions use counters for the sample clocks. However, the counter measurements need to be in a separate task from the analog inputs. 
 
Also, all of your analog inputs should be included in the same task. This is the proper configuration even though your measurements are of different types because there is only one analog input sample clock. Here is the link to an example that demonstrates this configuration: NI-DAQmx: Creating an Analog Input Task with Multiple Measurement Types. I hope that you find this information helpful.
 
Regards,
Hal L.
0 Kudos
Message 4 of 11
(5,068 Views)

I am working on getting just the counter working by using the program posted previously, and I am running into issues. Periodically I get the error:
________________

Error -200141 occurred at DAQmx Read (Counter DBL 1Chan 1Samp).vi

Possible reason(s):

Data was overwritten before it could be read by the system.

If Data Transfer Mechanism is Interrupts, try using DMA. Otherwise, divide the input signal before taking the measurement.

___________________

It seems to work better if I use cascaded counters, but I need timer 0 for analog channels when I run this code along with the program for the other measurements.
I have tried averaging, and selecting different values for the millisecond timer, and these did not seem to have an effect.
I tried different DAQms configurations and "Counter DBL 1Samp" seemed to work the best.
The program will work for a while and then it will give me the above error message.
If I use counter 0 as a cascaded counter input, the program runs fine. If I run this with other analog channels, it errors out because the analog channels use counter 0.
If I use counter 1 as a cascaded counter input, it seems to work better than a single channel, but it will still error out with the above error.
If I use only counter 1, I get the error above even faster.

 

Also, none of the configurations give measurements outside the While Loop.
The only place I can add a speed dial for the front panel is within the While Loop.
Is there someway to get the signal to continuously send out of the while loop?
I thought if I could get the signal out of the while loop, I could condition it anyway I wanted without the program erroring out.

 

Any suggestions would be much appreciated.

Thank you.
0 Kudos
Message 5 of 11
(5,024 Views)

Hello Electro-Frog,

I was not able to see what you were doing in your while loop from your previous post.  Are you doing a lot of data manipulation in your while loop? 

I also noticed that you are using local variables in your program, these can slow down your application which would contribute to error -200141 - which is cause when you receive a second sample before reading the last.

Another thing you could try is to set the DAQmx Overwrite Property in the DAQmx Read Property Node to Overwrite Unread Samples.  This will not error if you miss a sample.

Regards,

Micaela N
National Instruments