LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview for arduino reading frequency

I'm trying to figure out a way to read a frequency from a device. The device tells how far away something is by a beeping signal. I tapped into this beeping signal and it is now connected to an arduino pin generating a high/low signal to Labview. I got this much to work but now I need the distance that the device is collecting. Basically I need to know if it's possible to generate a number on a numeric idicator from the information on how fast the frequency changes. I'm not really sure if this is enough information but I'm attaching my basic high/low code. I used a basic meter to display whether it is high or low.

0 Kudos
Message 1 of 7
(5,252 Views)

Here's the code.

0 Kudos
Message 2 of 7
(5,251 Views)

Hey cmoyer,

 

How fast/how often are you reading in these 'beeps'? The difficulty that you are going to run into is that there will be a limit on how fast you can accurately acquire these signals (and then measure a time between them) because the timing on the operating system will not be extremely accurate. You will be limited by your processor speed and the accuracy of the timing on your OS. If you are measuring at a relatively slow pace we could probably find a way to convert your simple high/low signals to a frequency measurement. It will be a bit cumbersome but it is possible.

 

Thanks,

 

Doug B

Applications Engineer
National Instruments
0 Kudos
Message 3 of 7
(5,221 Views)

Doug,

 

It would be really good and helpfull that you give us a hand on how to measure frequency from a square wave signal using arduino. Personally I need to measure very slow frequency signals, that come from an optical sensor which is switched by a rotary disk with a small gap. The range I need to measure goes from 0 rpm to not much more than 150 or 200 rpm. I already tried "timing and transitions measurements" and "pulse measure" but both modules give and error. I suppose that the kind of signal they are expecting is not the one that the board is giving.

 

Thanks for any piece of advice you can give on this.

 

 

(Oh, notice that I Do see the square wave using the "continous sampling example" so all works ok between the board and the software)

DMDsync
0 Kudos
Message 4 of 7
(5,140 Views)

Hi,

 

Take a look at at this example: https://decibel.ni.com/content/docs/DOC-6951

It uses DAQmx calls but if you replaced them with the Arduino code you posted, then you could use the VI for frequency.

 

Regards,

 

Greg H.

Applications Engineer
National Instruments
0 Kudos
Message 5 of 7
(5,126 Views)

As I commented some time ago, I'm tring to adapt the example to get a simple RPM measure of a spinning rotor. It doesn't go fast (not more than 200 RPM) but i cannot figured it out the way to do it with arduino. I already have the arduino and labview connection working, I use an optical sensor (emmiter and receiver), and whenever i cut the light between them I get to see the square wave it forms. None of the blocks for working with pulses or frequency have worked yet (error using them), and I don't believe I have (for the Arduino) all the blocks that are available for DAQmx. Any suggestions?

 

Thanks in advance to anyone that can help me out here.

DMDsync
0 Kudos
Message 6 of 7
(5,080 Views)

Hi,

 

In the example I posted before, you don't want to use any of the DAQmx VIs.  You would replace these with the arduino code but use the same frequency calculation.

 

What errors are you getting when using the pulses or frequency functions and which ones have you tried?

 

You could do a manual calculation of the RPM.  Assuming you get one pulse per rotation, count the pulses of the optical sensor for 1 second.  This will give you rotations/second.  Then you can multiply this number by 60 to get rotations per minute.  The problem with this is if 1 second passes when the motor is half way through a rotation, then there is no way to account for this in the calculation.  If there is more than one pulse per rotation then you will need to factor this into the calculation.

 

Regards,

 

Greg H.

Applications Engineer
National Instruments
0 Kudos
Message 7 of 7
(5,061 Views)