RPM measurement

Which out-of-the-box Arduino is best suited to measure microseconds (in the range of 0.5s up to 2s) between attachinterrupts() events at <100ppm error?

From my understanding:

  • Current versions of Uno / Mega only use a ceramic resonator (not accurate enough)
  • Due has a glitch with micros()
  • Zero is off by 576us due to the 48MHz dividend by 32768Hz rounding

I am stuck with the question which hardware I can use?

A binary counter?

http://www.nxp.com/documents/data_sheet/74HC590.pdf

Can always then feed that parallel output in to a parallel to serial IC:

http://www.nxp.com/documents/data_sheet/74LV165A.pdf

So you can use the arduino as the "trigger" for the binary counter to start and stop counting.
The arduino can also be used to clock the serial output from the parallel to serial IC.

As for the sensor...maybe there are already available (de-bounced) sensors that will provide a nice clean and accurate HIGH/LOW signal.

Thank you. I understand this would solve for accurate counting, however I still have the issue with not having a precision time stamp from the Arduino, do I?

What I would like to do in simplified terms is: A sensor that triggers attachinterrupt() and the Arduino sets a micros() time stamp in the ISR. The loop always calculates the difference between new and previous time stamps. As said the trigger interval is between 0.5s and 2s but the resolution needs to be 100us or better. I will have approx. 10 revolutions to measure but I need the timing for each single one, so counting the revs over a longer accurate period (e.g. for one second) and taking the average will not work.

Ah...I see.

Well maybe not use the arduino for timing at all?

Use a signal generator to give impulses and have the counter stop counting once the wheel has turned 1 revolution.

So you can put a 1MHz (1 micoseond resolution) square wave on to the counter which will give the number of microseconds per revolution. Use an arduino to interpret the data from the IC.

I do not know weather the IC will keep the previous revolution's binary output while counting a new revolution...check the datasheet.

As far as accurate signal generators go...have a browse around. I am sure you can calibrate these with a decent oscilloscope.

EDIT: You could feed the counters output quickly in to a "state holding" type IC...Like a parallel to parallel 8bit register type thingy...I dunno. This will hold the value whilst the counter is reset and gives the arduino some time to record the output.

try to get a duemillanova - they had crystals IIRC

ra_duino:
Thank you. I understand this would solve for accurate counting, however I still have the issue with not having a precision time stamp from the Arduino, do I?

What I would like to do in simplified terms is: A sensor that triggers attachinterrupt() and the Arduino sets a micros() time stamp in the ISR. The loop always calculates the difference between new and previous time stamps. As said the trigger interval is between 0.5s and 2s but the resolution needs to be 100us or better. I will have approx. 10 revolutions to measure but I need the timing for each single one, so counting the revs over a longer accurate period (e.g. for one second) and taking the average will not work.

Can’t you make an ISR which captures the micros() value? Won’t this give resolution better than 100us?

The value returned by micros() takes over an hour to rollover.

Sorry if I’m missing some major point.

No, this is exactly what I would like to do.

const int sensor = 0; 

unsigned long interval = 0;
volatile unsigned long measurement_old = 0;
volatile unsigned long measurement_new = 0;

void setup()
{
 Serial.begin(115200);
 attachInterrupt(sensor, measure, RISING);
}

void measure()
{
 measurement_new = micros();
}

void loop()
{
  interval_time = measurement_new - measurement_old;
  if (measurement_new != measurement_old && interval_time > 500000)  //debouncing (value <0.5s)
   { 
    Serial.println(interval_time);
    measurement_old = measurement_new; //set new reference time  
   }
}

As said, the big issues I have identified are:

  • MCU clock reference (need for an oscillator with low frequency error, e.g. Uno is unfortunately using a ceramic resonator with >300ppm error - I will try Due or Leonardo, which have crystals with ~20ppm +/-30ppm temperature variance)

  • internal dividers/multipliers (e.g. the Zero uses a 32.768kHz crystal apparently multiplied by 1464 which gives 47.972352MHz instead of 48MHz which seems to result in a ‘build-in’ 576ppm rounding error of micros() - see http://forum.arduino.cc/index.php?topic=342697)

Here is an interesting list of various individual boards/devices tested by one person.

The usual solution would be to either replace the resonator with a crystal or add an RTC chip for calibrating the system clock, but neither of those are "out-of-the-box".

Another possibility is calibration of the resonator frequency vs. internal temperature sensor. You could get to within 100ppm that way. But it would have to be done on a board-by-board basis.

What about a Teensy?

Some (maybe all?) of Uno boards have pads for replacing the resonator
with a quartz crystal and caps, if your soldering/desoldering skills are
good enough.

Uno Rev 3 does not have pads for crystal caps, not that they couldn’t be added on using the socket pins for example.
Attached is the top artwork for the board showing only resonator pads.
These guys still carry Duemilanove’s:
http://www.nkcelectronics.com/arduino-duemilanove.html

Or make your own board and use whatever crystal you’d like:
http://www.digikey.com/product-search/en?pv253=19&FV=fff4000d%2Cfff8016d%2C1140050%2C22c0011&k=crystal&mnonly=0&newproducts=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25
Frequency Stability
±10ppm

Frequency Tolerance
±10ppm

Or take a chance with ebay/chinese arduino that has a 16MHz crystal instead of a resonator. Is it within 100ppm? Probably. Maybe. For $3.50+shipping you can find out.

Depends on if you have 3 weeks to wait for it to show up.

I've ordered a few things from that particular "alice" seller and got the items within a week or ten days.

I'm not defending the whole ebay thing. I actually dislike it. But the goods are probably legit. What isn't clear is whether the requirement of the OP will be met or not. One board I bought from that seller was out of spec and I purchased items from Mouser or Digikey and fixed it myself. Did I just contradict myself? Yeah, probably.

Its shocking the Uno doesn't have accurate time keeping, it still shocks me a couple of years on.
The early Unos had pads for a crystal and caps so I resoldered mine so it was useful for projects
like this.

A lot of the clones don't make this very limiting error!