LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

frequency measurement problem

Solved!
Go to solution

Hello everyone, I have a measuring bench for speed sensors composed of a gear wheel, a motor and a chopper. I also have a NI PCI 6221 acquisition card I have to acquire signal amplitudes and frequency and put them in graphs but as you can see in the photo my blocks do not see anything, they just return 0. On other programs where I do tests I have error 20315 which appears with the message "The Waveform dt parameter is <= 0" However, I checked the status of my card and everything is fine Do you have any ideas?

katramz_0-1740395323620.png

Thanks

0 Kudos
Message 1 of 12
(433 Views)

Good morning, @katramz.

 

From the one "picture" that you presented, I can't "see the solution" to your question "Why doesn't my code do what I want it to do", but I can see many improvements you can (and should) make that will serve you well in your LabVIEW development.  I'm guessing that you have picked up LabVIEW largely by yourself, perhaps coming from a background of text-based programming, and didn't learn the "secrets" of Data Flow programming.

 

Here are a few "red flags" that I immediately noticed:

  • Use of the Sequence Structure, rarely needed except for FPGA programming (or the rare "elapsed time" measurement).
  • Use of the "Stacked Sequence Structure" (which NI has now "hidden" from the Block Diagram structures in recent versions of LabVIEW).  Keeping the wires properly connected when you have even two levels of stacked sequences, let along the seven on your diagram, is very difficult.
    • A "fix" for this is to use a For or While loop with a Case Structure inside it wired to the loop Index.  Use Shift registers to keep track of the variables, while the Case handles the 0 .. 6 instances (label the initial Case "0, Default" to keep the Case from throwing an error).
  • Use the Error Line everywhere you can.  Not only does it enforce Data Flow, it can "pick up errors" and aid in your tracking them down.
  • Do not use "Dynamic Data Wires", but rather use the native LabVIEW types (Arrays, Waveforms, etc.).  They "obscure the code" and slow down the processing by doing unnecessary conversions and reformatting.
  • Do your best to keep your major wires (the ones at the upper and lower corner connectors, such as "Task References" and the Error Line) running straight, left-to-right.  Make every effort to not run a wire "backwards" (Enqueue input wires, where the data apparently flows "backwards", are an obvious exception).

Sorry that I couldn't directly comment on the problem you are having.  I'm not familiar with the Toolkit you are using (the one getting data from the Dynamic Data Wires), but that might be a place to start.  Have you tried opening MAX and creating a Test Panel for your 6221 to read a few A/D values and make sure they aren't really all 0?  [Maybe it's "hardware", not "software"?]

 

If you want more comments on your code, you'll have to provide more code, preferably something we can open with LabVIEW instead of an "image viewer" ...

 

Bob Schor

 

 

0 Kudos
Message 2 of 12
(410 Views)
 

 Hello and thank you for the response in fact it's quite old coding that I'm just trying to make work again. In my other labview files I use while loops and error threads but I run into the same problem. Unfortunately I have to use my 7 wires because I have 7 sensors to test at the same time and my acquisition card cannot use two blocks "read" at the same time. 

For example I give you another photo of code where I use various means to obtain a frequency (a signal split, an array or a cluster) and I block in the same way

katramz_0-1740406321978.png

katramz_1-1740406527698.png

I will try to take your comments into account, but normally even if it is not the best way to code it should work.. And I don't understand why I detect no frequency

 

0 Kudos
Message 3 of 12
(404 Views)
 

 I also opened NI Max yes, everything was good

0 Kudos
Message 4 of 12
(401 Views)

Filtering and Extract Single Tone (N Ch).png

 

You can wire the array of waveforms (returned by DAQmx Read in your code) directly to the IIR Filter.

When you are debugging LabVIEW code, find the first VI that returns unexpected results.

 

I hypothesize that you are not getting data from the DAQmx Read. The error message definitely indicates the downstream VIs don't like dt = 0.

 

 

Recommendations:

  • Specify Timing (sample mode, sample rate, samples) for both AO and AI tasks
    • For a continuous AO task, you probably don't want to stop the task immediately after starting it
    • For the AI task, look at the data you have acquired and verify (manually to start) that the expected data is acquired
  • Use the N Channel instances of the IIR Filter and Extract Single Tone Information VIs to avoid unnecessary code duplication
  • Connect Error wires! 
Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 5 of 12
(363 Views)

I suggest using the MAX Test Panels for AO and AI, and verify that you are acquiring expected signals. Then, use the AO Test Panel to control the analog output and use your code to perform analog input. After you have verified your analog input code, reenable your analog output code.

If you attach your code, we can be more helpful.

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 6 of 12
(336 Views)

Hello, 

I will try with your code and adding the error bars, but I still have to connect my array to my read block because it has to visualize my 7 inputs

 

By connecting only one of my sensors to my input 1, on NI max I have the right signal (it is a hall effect sensor, so square signal)

katramz_0-1740487977536.png

 

0 Kudos
Message 7 of 12
(304 Views)

I understand that you have to analyze your acquired data. The code snippet was provided as an example of how you can connect one array of waveforms directly to the Filter VI.

If you are treating one or more of your channels like a tachometer, consider using the Tachometer Processing functions in the Sound and Vibration Toolkit (Full). The SVT VIs have a lot of run time in the field.

 

Again, if you attach your code, this community can be more helpful.

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 8 of 12
(286 Views)

Hello yes sorry I did not have access to the forum from the PC on which I have LabView but I managed to put it. I made a second code following your suggestions (error bars, deletion of sequences) I share it with you. I can now acquire amplitudes but very weak, but this may concern my sensor and not the code

0 Kudos
Message 9 of 12
(265 Views)

I know you are trying to get some old code working, but you might be better off building parts of the code that are more easily verifiable and adding as you go.

Here is a snippet that acquires from 7 ai channels, low-pass filters the signals, and extracts the biggest tone:
Acquisition with Tone Extraction.png

 

The extracted tones output looks like this:

dsbNI_0-1740612485001.png

 

That looks like what I expected given the input signals connected to my ai channels.

I would like you to get to the point where you are acquiring and processing ai channels and happy with those results before adding more features.

 

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 10 of 12
(239 Views)