04-07-2016 03:59 AM
Hello I am learning how to use labview and could do with some help please.
I'm building up my programming and electrical knowledge, I've spent a week trawling the site on this, so figured it's time to ask for help. The other discussions have been very helpful. My datalogger is for use on a car.
I am trying to measure the frequency of two things;
1) a propeller shaft, with a rotary switch - 4 pulses per rotation (0V low, 2.7V high). Expected frequency ~ 0 - 450Hz
2) engine rpm, with an inductive bosch sensor - 34 teeth/pulses per revolution. Expected frequency ~ 400 - 3500Hz
I can read the propeller shaft sensor voltage, but not the engine, so let's focus on that until I can get more time with the car. I think the inductive sensor outputs current and I am yet to read that on its own. I have attempted the frequency counter VI's from the examples and other discussions. I think my problem is that the triggering is difficult without a separate digital module. Also I have read the documentation, but I still don't really understand how to access the CDAQ onboard counters.
I have a VI that counts the leading edges (thanks to my NI rep Avag!), please see attached. I had hoped I could add the onboard counter, count the freqout pulses of one period and invert it to get frequency, but my blunt programming skills haven't got me there yet!
I would be very grateful (kudos and marked solutions to be dished out!) if someone could help me solve this.
System
NI CDAQ-9133
NI-9220 Voltage module
NI-9219 Universal AI module
04-07-2016 12:04 PM
In these types of cases I try to go simple. Right now you have an AI task with one channel in it, running at 1Khz, why not have two channels in that task on that one 9220 which is a simultaneous sampling card, so you can crank up the sampling rate to 35Khz (10 X fastest rate nyquist) and then post process each in a similar way you are currently doing. No need to mess with counters and timers unless you want to. Personally I've had the request far too often to see the full waveform, so if I tell my customer the frequency is X Hz they then usually ask to see the full waveform like a scope, and a counter can't give you that information, but an AI can.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
04-07-2016 11:39 PM
Hi Hooovahh,
Thank you for your reply. I agree, I will increase the sampling rate, that will help catch all the pulses. The edge counting VI works, but not the frequency calculating VI that I attached. So at the moment, I think I need to add some kind of counter so that I can measure the time to get frequency (number of leading edges divided by time = frequency). At the moment I don't have the time part, I just have a count of pulses. Am I missing something here? I don't think I have a timebase to get the frequency or period. I feel I'm missing something because I can't be the first person with a CDAQ that wants to count pulses and get a frequency, that seems a simple task, so I must have overllooked something.
When you suggest two channels, so you mean have two channels at a high sampling frequency both looking at ai5? Or is the second channel doing something else?
Thanks!
04-08-2016 04:55 AM
I think he meant one channel for each of the two signals.
Look at the Extract Multiple Tone Information.vi in the Signal Processing >> Waveform Measurement palette. That may give the the frequencies directly.
With an analog signal all the timing information is derived from the sampling rate.
Lynn
04-08-2016 07:17 AM
Thank you Lynn, now I understand.
I had previously tried the extract tone information, without success. I have just tried and it seems to calculate a frequency, but my signal has too much noise and there are erroneous edges being counted. I will try again next week and see if I can reduce the noise with a low pass filter.
The Labview frequency measurement pages suggest using a counter, and I was having trouble with the frequency measurement examples because NI-9220 could not access the Start.AnlgEdge.Src in the timing node.
Thanks again for the suggestions and explanations, I'll report back soon. Have a great weekend
04-08-2016 07:27 AM
Can you post a VI with some of your noisy data saved as default? Seeing the actual waveforms and noise may make it easier for someone to offer better suggestions.
Lynn
04-08-2016 07:35 AM
That's a great suggestion. My CDAQ is all packed up now (it's Friday afternoon here in Kenya), so I'll try that on Monday. Although, I write VI's on my laptop, then deploy onto my CDAQ as an executable. I don't think the executables allow to initialise values to default, so I will try to save a tdms file, unless you can suggest a better way?
04-08-2016 02:06 PM
TDMS file is fine. You may need to zip compress it or change the file extention to ".txt" if the Forum will not let you attach the TDMS file directly.
Lynn
05-11-2016 07:59 AM
Hello
Sorry for the delay. I have tried a few other things with limited success. I have increased the reading frequency to 35kS/s and I am reading something, but not what I hoped for. As a note, there would be 34 pulses for one revolution of the timing wheel. So to convert from observed frequency to engine rpm, I would divide by 34 and mulitply by 60. If the engine speed is 950-5500rpm, I would expect an observed frequency of 538Hz - 3116Hz. I've attached the VI and a sample data where I revved the engine in neutral.
As always I appreciate the time and skills of everyone that attempts to help.
Alex