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,025 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,017 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
(4,998 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
(4,978 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
(4,934 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
0 Kudos
Message 6 of 11
(4,920 Views)
I cannot figure out how to change this property, or even find the property listed anywhere.
Would you please give me some step by step instructions to find and change it?
Thank you,


"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"
0 Kudos
Message 7 of 11
(4,899 Views)
I found a VI in the examples that supposably converts a counter TTL signal directly to frequency.
This is what I want, so maybe it will work better than making my own configuration.

The url is: http://sine.ni.com/apps/utf8/niepd_web_display.display_epd4?p_guid=B45EACE3EF3256A4E034080020E74861

It asks the user to specify the board and counter. I know how to create an i/o link to the counter or a global channel.
I do not know how to create an i/o for the board or any other way to specify the board for this vi.

The description of the VI from the help bar is attached.

If anyone knows how to specify the board so I can try this VI, please let me know.

Thank you very much,
Electro-Frog
Download All
0 Kudos
Message 8 of 11
(4,891 Views)
Hello Electro-Frog,

The DAQmx Overwrite Property is found under the DAQmx Read Property Node.  Use the selector tool (the hand with the pointed finger) to select the Overwrite Mode.

I don't think the example program that you posted will work for you.  It uses the Traditional NI-DAQ (Legacy) driver.  You mentioned that you are trying to use both the counters and the analog inputs of your E-Series card.  You can only address the card with one of the two drivers, either DAQmx or Traditional NI-DAQ and of the two, the DAQmx driver is much more robust and easier to use.  You could try out the example program, the device number is listed in Measurement and Automation Explorer under Devices and Interfaces >> Traditional NI-DAQ (Legacy) Devices.  After verifying its functionality, you could transfer it from Traditional DAQ to DAQmx using some great references such as Transition from Traditional NI-DAQ to NI-DAQmx Tutorial and What are the Terminology Changes in NI-DAQmx?

Hope that helps!
Micaela
Micaela N
National Instruments
0 Kudos
Message 9 of 11
(4,875 Views)

I have managed to avoid getting the error with the overwriting samples by using the attached program.
The display will still freeze up occasionally, but usually it will start working again eventually.

Now my problem is that I am measuring the frequency correctly in measurement and automation, but not in my program.
I put a 500 Hz signal in to test the system. The input was selected as 2 counters, large range, 2 Hz - 2.5 KHz.
In measurement and automation, I received data generally dead on 500 Hz, sometimes a little different.
In my program I would sometimes get the correct reading for a second and then it would change to decimal numbers with seemingly no relation to the frequency.
i.e. .21, .5, .11 and so on.
I tried changing the frequency, and sometimes this changed the number slightly, sometimes it did not effect it, and sometimes the number changed either bigger or smaller in the opposite direction of how I changed the input.

Does anyone have any idea why LabView is not reading the same as Measurement and Automation?

Thank you,
Electo-Frog

0 Kudos
Message 10 of 11
(4,864 Views)