LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Taking an average frequency of a square wave input?

Hi everyone,

 

I'm a student who is working on a design project with the goal of being able to sense to color of a skittle that is placed in front of a TCS 3200 color sensor. The color sensor is fed a series of pulses corresponding to the red, green and blue diodes. Currently, my code is set up to read the square wave that the color sensor outputs and using the Extract Single Tone Information function display the frequency at the time of the pulse. What I am struggling with is being able to index the last few readings and perform and calculate the average of these values. Ideally I would like to be able to take the last X number of frequency sample of red, X number of blue and X number of green, with the end game of being able to use labview to analyze this data and output what color is being detected. The crux of my problem lies in not knowing how to index the last few values, take an average of them and output them in labview. Any help anyone could give me on this would be great.

 

I've attached my Labview code, where the case structure acts to send three pulses in series. The right of the Labview code involves sending voltage to an independent motor. 

 

Thanks to anybody who can give me some direction!

0 Kudos
Message 1 of 2
(2,736 Views)

Okay, so you have these array wires that come out of the Single Tone vis. My quess is you really only need the first value of this array as you read only 1 channel in each of the DAQ Assistant VI (just wire the array the an "index array" node and use the output, by default, it'll give you the first element of the array). Next up, I think you say you want to average these individual values over many loops. Okay, so Labview has a Mean PtByPt.vi that will accept one value every loop and give you the running average based on some number of averages you provide. If you want to output the moving average over time, feed the output into a Chart (not a graph).

 

Hope that helps.

0 Kudos
Message 2 of 2
(2,705 Views)