I'm looking to use an Arduino to read the rpm from a brushless motor for about 5 or 6 minutes and then take the mean, median, and max of the sample.
It looks like I could use a circuit like this to read the rpm, it gets outputted as a frequency which there's a couple libraries that I could use to read this and output the rpm. Brushless rpm Sensor - RC Groups
The problem I'm looking at now is how to do I record the 5 minutes of input and then calculate the stats for the run. From what I'm reading I could have the Arduino output the rpm into Matlab or a similar program and then within that I could do a few calculations and I have the stats. But I'm really hoping to have a stand alone device that doesn't need to be connected to a computer. So I'm stuck with what I should do.
Well, first you need to determine how often you will determine the RPM of the motor, each 100ms, or some other time value. Then each time you sample, add 1 to a counter. Then save the new RPM only if it is different from the previous RPM. Finally, to get the mean RPM, or the one midway in your sample run, compute what time will be exactly 1/2 way in your run time and save that RPM value as the mean RPM.
Set up an array to store the RPM values. At end of run, you can do the statistical analysis on the array values.
I see you also need the median value, so you may have to change the array to allow a counter for each RPM value and look in the array for a matching RPM entry. If found, add 1 to the entry counter. If not found, make a new entry with 1 for the counter.
At least that is one possible way to do your project.
I hope, by now, you have come to realize the method you proposed to measure the motor RPM does not give you what your project asks for. The circuit will show the same "RPM" when you put your finger on the fan hub and slow it to a complete stop.
Your statistical analysis of the RPM will always give the same results, no matter what you do to the fan.
I agree with Paul_KD7HB, the rcgroups solution measures the frequency of the drive circuit, not the frequency of rotation.
The brushless motor is basically a syncronous motor, but to there will always be what is called SLIP between the rotating field in the stator and the rotation of the rotor or output shaft.
This means that the rotor will run slower than the driver frequency, and runs slower as load on the rotor is increased.
The rpm feedback in 4wire fans uses a hall effect device to trigger whenever the rotor magnet goes passed it. This gives a pulse every rotation of the shaft.
I could see that issue for a non sensored motor but I believe for a sensored motor it should always be the same. That's why a non sensored motor cogs while a sensored motor is smooth on the bottom end. Correct me if I'm wrong, I might be.
If I turn out to be wrong I could splice in a connector into the sensor wire and get a reading from that but I'd really like to avoid that as that's much more intrusive than just clipping a wire on a motor connector.
At this point I'm thinking that I can store the rpm and temperature values in an array but I'm worried if the arduino could store an array big enough. Ideally I want the arduino to be able to crunch the numbers and display the max, mean, median rpm numbers on a small display along with the temperature after each run. Then after a number of runs I'd want to plug it into a computer and get all the data off for more in depth data analysis.
If I stored the rpm value every tenth of a second, over 5 minutes I'd end up with 3,000 values, each 4 or 5 integers long. Can the Arduino store all of that in an Array? And could I store multiple arrays that large?
Is the fan motor you are looking at 4 wire!!!!!!
Why didn't you say so, splice into the tacho wire, no complicated circuitry, just check that it is 5V pulses.
It's not a fan, it's a brushless motor with external controller. There's three power wires going to the motor along with the sensor wire. This device will attach to one of the motor wires and clean up the frequency so the arduino can read it
Can you post a picture of the motor and controller as well as model numbers thanks.