From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Errors when counters read zero

Solved!
Go to solution

I have to read a signal from circuit to determine the RPM of three motors. At times these motors will be at zero RPM so there will be no pulses being output. I'm using three counters on the cDAQ chassis and a NI 9401 digital IO module. The problem I'm having is when the RPM is zero and there are no pulses coming into the 9401 the DAQmx read.vi times out and throws an error. (See the vi and error below) As long as there is a signal present all is good but I will need it to function when there is no signal input. How can I get around this?

 

Thanks

counter.PNG

Message 1 of 10
(3,482 Views)

You are asking it to STOP the loop, in case of ANY error.

 

Consider extracting the error CODE and testing for error #-200284.

If that is the error, then do NOT stop the loop and simply try again.

If it's some other error, you probably DO want to stop.

If NO error, you do NOT want to stop.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 10
(3,448 Views)
Solution
Accepted by topic author GDthomas

 

An *expected* error is not the end of the world.  Immediately after the DAQmx Read function, check for the specific timeout error code that you know you'll get sometimes under normal conditions.  Then handle it instead of just passing it along.  Here you might just assign a 0 value to RPM and then erase the error.

 

A second refinement is to give some more careful thought to the timeout value you feed to DAQmx Read.  It should be short enough to keep the loop responsive, but long enough to account for "Samples per Loop" at the lowest RPM worth measuring.

 

A third refinement could be that when you *do* timeout, you make extra effort to try to get *some* data out of the task.  After erasing the error, you could query for # available samples and then read *that* amount.   It's unclear whether this partial data is of any particular use in your specific app though.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 3 of 10
(3,446 Views)

Steve & Kevin,

 

Thanks for the ideas. I think the idea of extracting the error code is the simplest way to go.  I like the idea of substituting in a 0 at that point also. It didn't make sense to me until I thought about it, the vi is waiting for data, no pulses no data and it times out.

0 Kudos
Message 4 of 10
(3,404 Views)

It didn't make sense to me until I thought about it,

 

That's the way it goes sometimes...

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 10
(3,401 Views)

Hi, I have the same problem with the RPM sensor stopping to read when the RPMs are 0, but I am really new at Labview and Im not able to fully understand your solution and how to implement it, I am using a code that has been provided to me so I am not really familiar with it. Here I attach the screenshots I took about it, please if you could help me I would  really appreciate it.

 

Thanks for your time,

 

Marcos

0 Kudos
Message 6 of 10
(2,160 Views)

Hi Struggling,

 


@StrugglingwithLabView wrote:

I am really new at Labview and Im not able to fully understand your solution and how to implement it,


When you are that new to LabVIEW you REALLY should take those "Training resources" offered in the header of the LabVIEW board.

 

Once you learned the basics you should implement the suggested solution: check the error number and stop only when the error number is not 200284…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 10
(2,151 Views)

Sorry to say, but you're really gonna need some time digging in and learning some basics.  Counters are kinda unique in the DAQ realm in that they don't measure or deliver *signal levels* (like AI, AO, DI, and DO) but instead they deal in counts and time (though time is really just derived from counts and a known frequency).

 

The second image you attached tells me that the code you were given is no good.  It betrays a very fundamental misunderstanding of counter task data and/or signal processing functions.  The task data is a single count.  The processing function wants to act on a good-sized set of signal level data.  They are *fundamentally* not compatible, so you're going to need to start over on the counter stuff.

 

My recommendation: spend some time with the shipping examples for counter tasks.  Open an output and an input task so you can run both at once.  Their front panels will let you easily choose a PFI pin for your counter output example and then choose the same PFI pin for your counter input example.  Spend time observing and experimenting with different kinds of counter tasks, particularly edge counting and frequency measurement.  For now, stick with the 1-counter method for frequency measurement b/c it'll be easier to understand.

 

I don't think I can usefully help with details such as those discussed earlier in the thread until you've spent some time to get more famliiar with counters.  Then you'll be equipped to follow and understand better.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 10
(2,146 Views)

Hey, it's me once again. I have managed to disable the error, but now I want the program to read 0 RPM when it doesn't have any input signal on the sensor, can this be done with a case structure or something similar?

I am attaching the excel file where it can be seen that as soon as the motor stops it does not read any RPM at all and just leaves an empty space in the Excel column for RPM, and I want the program to write 0 RPM in those blank spaces

 

Thanks for your help and quick responses I really appreciate it

Download All
0 Kudos
Message 9 of 10
(2,116 Views)

I can't really improve on what I already said back in msg #3.

 

Background: here's the problem with me.  I tend to be pretty choosy about which threads I spend significant thought and time on.  And it's pretty rarely the ones with "new user" questions.  I'm just a volunteer contributor here and put most of my efforts into things that help "keep me sharp".  Moderately complex stuff, interesting tidbits, or topics that happen to fall in a niche where I have fairly unique experience.

 

I saw the multiple DAQ Assistants, the (dreaded) dynamic data wires, and the Express VI all in a common loop, and I'm just probably not ready to get heavily involved yet.  Sorry, it's just kinda like this: I'm generally up for leading a hike up to a modest summit once you get to the trail head, but am probably not going to come pick you up and walk you half way across the country to bring you there.

 

Fortunately, others are more generous with their time and expertise, and I'm glad they are!

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 10 of 10
(2,108 Views)