Go Down

Topic: RPM measurement (Read 971 times) previous topic - next topic

ra_duino

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?

Johnny010

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.


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.

Johnny010

#3
Nov 01, 2015, 02:47 pm Last Edit: Nov 01, 2015, 02:49 pm by Johnny010
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.

robtillaart

try to get a duemillanova - they had crystals IIRC
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

DuaneDegn

#5
Nov 02, 2015, 06:14 am Last Edit: Nov 02, 2015, 06:15 am by DuaneDegn
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.

ra_duino

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


Code: [Select]
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)

jboyton

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?

MarkT

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.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

CrossRoads

#9
Nov 08, 2015, 12:16 am Last Edit: Nov 08, 2015, 12:50 am by CrossRoads
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
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

jboyton

#11
Nov 08, 2015, 02:24 am Last Edit: Nov 08, 2015, 02:25 am by jboyton
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.

CrossRoads

Depends on if you have 3 weeks to wait for it to show up.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

jboyton

#13
Nov 08, 2015, 02:43 am Last Edit: Nov 08, 2015, 02:44 am by jboyton
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.



MarkT

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!
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy