LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MyDaq w/ Labview

I have attached my code, block diagram, and front panel. 

The goal of this set up is to count "jumping jacks" which is an moving accelerator right / left direction.

The error we see, is that when we surpass 10 or stay below ten, we get a failed message either way. how do we fix this?

Also we need to count peaks not data points above the threshold. How do we do this?

Any help or advice is appreciated!

Download All
0 Kudos
Message 1 of 3
(1,901 Views)

Start by taking LabVIEW seriously.  With very rare exceptions, you should never use a Sequence structure -- by using the Error Line, you can not only "see" your run-time errors, but you also set the sequence.  Do you know about the Principle of Data Flow?  That's the "central idea" behind LabVIEW, and if you don't know about it, you need to learn.

 

Spend serious time with the Tutorials.  Try to not use Express VIs -- learn LabVIEW.  

 

Bob Schor

0 Kudos
Message 2 of 3
(1,883 Views)

Hi nixxi119,

 

I echo Bob's sentiment that you will probably need to spend a fair amount of time with the LabVIEW and DAQmx documentation to understand how to implement your ideas in LabVIEW. I'll try to offer some specific advice and then I'll link some tutorial resources as well.

 

  1. Try rearchitecting your program using error wires to enforce control flow, rather than sequence structures. VIs and other functions will not execute until all of their inputs are computed. Think about how this can be used to enforce the order in which functions run. Error wires are the most common type of input that is used to enforce data flow because almost all LabVIEW functions have error in and error out terminals. This practice will improve your code's performance, but, most importantly, data dependency control flow motivates many of the design decisions made in LabVIEW and more advanced concepts will make much more sense if you are thinking about them in the context of data dependencies driving control flow.
  2. Learn a simple DAQmx architecture. Check out the LabVIEW shipping examples (Help>>Find Examples...) to get an idea of what good DAQmx code looks like. You will need to adhere to certain software rules to use DAQ hardware effectively. It is hard to write them all out in list form, but I think it will be clear what I am talking about if you take a look at a few of the examples. The one called "Voltage - Continuous Input.vi" is probably a good place to start. You shouldn't need to worry about triggers or logging right now, but I would definitely read more about the DAQmx Timing VI, particularly sampling rates. 
  3. Peak detection. There is a multitude of different ways to detect peaks in a waveform. For your application, I would recommend processing the entire waveform after it has been read into software using one of the VIs from this article. You can do this as data is acquired, instead of at the end of acquisition, but I would highly recommend you avoid that for now as it is easier to throw a shift register in the while loop than it is to build custom peak detection logic (and there is no reason to do this unless you have weird peaks).

As a sidenote, I took the DAQ code out of your VI and it runs fine without any bugs on my machine. I think your particular issue is being caused by the DAQ Assistant not returning quite the data you are expecting. This is one of the reasons I would recommend looking into sampling rates. Think about how much data you are collecting and how you are representing it. Unfortunately, LabVIEW is not quite as magical as it may seem. You still need to get all the numbers right.

 

Here's a couple of additional learning resources I would recommend:

 

Learn 10 Functions in NI-DAQmx

LabVIEW Basics

 

I think this project will become trivial to you if you spend just a few hours researching and learning about how to use the DAQmx API more effectively. That being said, feel free to post any follow up questions here and we will try to help.

 

Best,

 

Duncan Waldrop

Tech Support Engineer

National Instruments 

0 Kudos
Message 3 of 3
(1,868 Views)