LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

data input stabilization

Hi,

 

I'm relatively new to labview and I am learning quite fast, but I'm stuck on this problem.

 

I have an input signal coming from a cDAQmx as a dynamic data string. My goal is to output a true/false where true occurs when the data flow stabilizes to within a certain rate.

 

The mathematical description would be something like this: When N=+/-.5%*N-1, output=true. Where N is the iteration, and +/-.5% is the tolerance, and the sample rate is .5, meaning a new N value every .5s.

 

Basically, if the current sample is within .5% of the previous one (indicating stable data), output true

 

Another option I would add in later is to compare the current sample with the avarage of the last 3 which would be:

N=(((+/-.5%*N-1)+(+/-.5%*N-2)+(+/-.5%*N-3))/3)

 

But once the basic idea is down it shouldn't be tough to adjust it.

 

I tried messing around with a while loop and a convert dynamic data to array, but I'm not sure I'm going about it the right way.

 

Thanks,

 

Ryan

0 Kudos
Message 1 of 17
(3,359 Views)

Rayn,

 

You may be on the right track, but it is hard to describe a graphical program like LabVIEW in a few words.  Please post your VI so we cansee what you ahve tried.

 

Lynn

 

Hint: You need a shift regsiter.

0 Kudos
Message 2 of 17
(3,042 Views)

The hint helped a lot. I think I have it set up closer-but now I'm am having a data type issue with the in range function.

 

Another thing-You see the third data signal on the bottom? That will be a on/off, 0 or 10 mA input. What is the easiest way to make that into a T/F trigger for data stabilization while loop?

 

Thanks!

0 Kudos
Message 3 of 17
(3,030 Views)

Ryan,

 

The easiest way I can think of doing this off the top of my head is to compare the value to a limit (Example: < 2mA) then have a case structure that uses from this limit to append a T/F to your data.

 

Hope this helps.

 

Regards,

Trey C.

0 Kudos
Message 4 of 17
(3,007 Views)

I just realized my daq assist error too -_- 

 

I believe I got the T/F output to work from one of the channels, but I am still having trouble with the data type into the In Range function. Why can't the function accept a dynamic data range and continuously compare X?

0 Kudos
Message 5 of 17
(2,997 Views)

Ryan,

 

The dynamic data type is the beginner's worst nightmare.  You cannot tell what is inside by looking at it an you can only convert it to other data types by using the optioons the conversion wizard gives you.  I never use it.

 

Anyway, the help for the broken wire says the In Range and Coerce cannot accept that data type without further explanation.  So you need to convert it to soemthing else, possibly an array of DBL.

 

Lynn

0 Kudos
Message 6 of 17
(2,990 Views)

I used the convert from dynamic function to write to a 1D array with most recent option, then indexed the 0 value to output for the in range function.

 

I'm afraid I'm not familiar to know if this indexing is needed to compare the most recent values from the shift registers, or if plugging the arrays directly into the in range function will produce the desired result.

 

Thoughts?

 

Thanks!!!

 

Ryan

0 Kudos
Message 7 of 17
(2,983 Views)

Hey Ryan,

 

I apologize but I'm not very clear on what you are trying to accomplish with the test VI that you attached.  Given the current setup, both of your while loops are infinite.  If you could detail what you are trying to accomplish here, it would be easier to provide a suggestion on where to go from here.  

 

Regards,

Trey C.

0 Kudos
Message 8 of 17
(2,961 Views)

This vi is a base for a larger structure that I am creating, so the end result doen't make a whole lot of practical sense.

 

Both while loops are infinite at the moment. The first one will stay infinite-we will always be reading that data regardless.

 

The other loop is infinite for test purposes, as I have not yet created the limit comparison for the trigger. It will be triggered by a current value from a third channel from the daqassist that I have yet to create. When its finished it will be controlled by a hardware switch, but at the moment its easier to control that loop in the sortware. And while the switch is on and the condition is true, I do want it to be infinitely running; so it is constanly assesing the stability and outputing a T/F value. The T/F value will eventually act as a another trigger for datalogging.

 

The idea is that the 'data stabilization' will occur at the flip of a switch. The latest VI is my attempt to circument the problem of not being able to compare the dynamic data type from the shift registers.

 

As such, I suppose I am really just asking if there is a better way to do it than the way I have it set up. Me being relativelt new to LV, I suspect there is Smiley Very Happy

 

Ryan

0 Kudos
Message 9 of 17
(2,951 Views)

Hey Ryan,
Couple of things for you. First, I recommend exploring the daqmx vi's, specifically the create task, create channel, read, and end task vi's. These will output double numerics rather then dynamic data and are in general more versatile. It is not necessary as the daq assist will work and is a little easier to configure at first. We also ship several examples with labview which you may find helpful in becoming familiar with these vi's and may help you write code for your desired tasks. You can find this under the help tab by click 'find examples'. These particular examples are found under hardware input and output >> Daqmx >> Analog measurements.

 

Second, I believe your code could be put into a single while loop. The averaging function doesn't need to be outside of the loop. An important note is that the while loops will not export data out of the loop until the ending condition is met. You can view this data flow by clicking the 'highlight execution' button (it looks like a lightbulb). This is a cool feature that can assist in debugging your code. In your uploaded vi, the ending condition is met immediately since you have the ending condition to be when it encounters a true and then fed it a true constant. For while loops, this means the loop will iterate once and then exit. The second loop will behave similarly. You can combine both your loops and wire a control instead of a constant. This will allow you to stop the program by pushing the correspond button on the front panel.


The timer you've added pauses in between iterations freeing up your computer processor to engage in other tasks so your computer can do more then just run a vi. This is good coding practice for a while loop.

Also, we have training classes available that are quite beneficial to new users of labview. The Core 1 and Core 2 classes provide a lot of exposure to the labview coding environment and help to develop the basics of using the many capabilities labview has to offer. You can check out the link below for more information on the training courses.http://sine.ni.com/tacs/app/fp/p/ap/ov/lang/en/ol/en/oc/us/pg/1/sn/n8:28/

 

Hope this helps,

 

Luke West

National Instruments

Application Engineer

0 Kudos
Message 10 of 17
(2,927 Views)