UK
Offline
Sr. Member
Karma: 0
Posts: 267
Arduino - very interesting !
|
 |
« on: June 08, 2011, 12:48:18 pm » |
I want to datalog some rpm pulses from a motor. The motor may run up to 50,000 rpm. I want to have more than one pulse per revolution. I wanted to know how many pulses per revolution i could use.
100 pulses per rev would give me high accuracy.
If the processor speed is 16 million cycles per second then the arduino should have no problems?
Any advice welcome
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #1 on: June 08, 2011, 12:53:58 pm » |
Yes at 100 pulses per second the arduino should have no problem. It might be best to look at using interrupts to read the time between the pulses.
|
|
|
|
|
Logged
|
|
|
|
|
United States of America, Florida
Offline
Jr. Member
Karma: 0
Posts: 64
Watching electrolytic caps exploding is one of my favorite past-times.
|
 |
« Reply #2 on: June 08, 2011, 01:06:12 pm » |
Yes at 100 pulses per second the arduino should have no problem. It might be best to look at using interrupts to read the time between the pulses.
I am no expert but wouldn't using the PulseIn() function be better and easer. And with it being able to read 1pulse per 10microseconds that would be exactly what you needed. http://arduino.cc/en/Reference/PulseIn
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #3 on: June 08, 2011, 01:08:26 pm » |
Let's see....50,000 RPM is 834 rotations per second, multiplied by 100 pulses/rotation gives 83,400 pulses/second. That's about 12 microseconds between pulses. That's definitely "fast" but probably doable as long as your code doesn't have plans to do much of anything else. A speed of 16 MHz for the Arduino sounds high but it takes several instructions to handle an incoming pulse, then you have to save it somewhere, and each instruction takes 2-3 clock cycles (on average) so it is not as high as it seems in practice. -- The Rugged Circuits Yellowjacket: 802.11 WiFi module with ATmega328P microcontroller, only 1.6" x 1.2", bootloader
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #4 on: June 08, 2011, 01:11:09 pm » |
I am no expert but wouldn't using the PulseIn() function be better and easer. No because while you use that function the arduino is not doing anything else. By using interrupts you free up that time to do something with the data you are getting.
|
|
|
|
|
Logged
|
|
|
|
|
United States of America, Florida
Offline
Jr. Member
Karma: 0
Posts: 64
Watching electrolytic caps exploding is one of my favorite past-times.
|
 |
« Reply #5 on: June 08, 2011, 01:12:26 pm » |
I am no expert but wouldn't using the PulseIn() function be better and easer. No because while you use that function the arduino is not doing anything else. By using interrupts you free up that time to do something with the data you are getting. Ahh
|
|
|
|
|
Logged
|
|
|
|
|
Humboldt, CA
Offline
Full Member
Karma: 1
Posts: 220
Arduino BBB
|
 |
« Reply #6 on: June 08, 2011, 01:49:11 pm » |
Last time I played with microseconds, they came in units of 4, so don't expect very good resolution down at the 12microsecond range of things. (It counted: 4, 8, 12, 16, etc.)
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 101
Posts: 9551
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #7 on: June 08, 2011, 02:29:51 pm » |
you might consider an encoder with two outputs: - one that pulse once per revolution => RPM - one that pulses X times per revolution => ANGLE some code to get started - http://www.arduino.cc/en/Reference/AttachInterrupt#define PPR 120 // angle 3°
volatile unsigned long count_rpm = 0; volatile unsigned uint8_t count_angle = 0; // byte can hold 0..255 so a PPR of 240 (2°) is theoretically possible
void setup() { attachInterrupt(0, IRQ_RPM, RAISING); attachInterrupt(1, IRQ_ANGLE, FALLING); }
void loop() { // process the counters, act, display etc }
void IRQ_RPM() { count_rpm++; }
void IRQ_ANGLE() { count_angle++; if (count_angle >= PPR) count_angle = 0; // count_angle will always be between 0.. PPR-1 }
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 267
Arduino - very interesting !
|
 |
« Reply #8 on: June 08, 2011, 02:35:26 pm » |
Thanks for the advice guys
i will look at going for 60 pulses per rev
= (50,000 / 60) * 60 = 50,000 cycles per sec = 20 micro seconds
the 50,000 rpm is worst case senario most motors will turn at much lower speeds
the advice on the encoder is a very good idea
the only down side is the cost of an encoder against a hall effect sensor
|
|
|
|
|
Logged
|
|
|
|
|
United States of America, Florida
Offline
Jr. Member
Karma: 0
Posts: 64
Watching electrolytic caps exploding is one of my favorite past-times.
|
 |
« Reply #9 on: June 08, 2011, 02:45:48 pm » |
Thanks to my (slightly stupid) question, I found you can get rottary encoders that work well out of old "deskjet" type printers. http://arduino.cc/forum/index.php/topic,63448.0.htmlmost also come with a few standalone that do not have the engine attached but do have the sensor and (what do you call it anyway) plus the ones with the engine to.
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 101
Posts: 9551
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #10 on: June 08, 2011, 02:54:50 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #11 on: June 08, 2011, 02:58:10 pm » |
i will look at going for 60 pulses per rev Do you need that degree of control? You are only making life more difficult for going for more pulses per rev. What about just 8?
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 267
Arduino - very interesting !
|
 |
« Reply #12 on: June 08, 2011, 03:23:03 pm » |
the more pulses the better
however it is less important on the 50,000 engines - i could actually use one pulse per rev at those rpms in retrospec due to the nature of the motor
so its probably best to have two options and allow the use to select the type of triggerwheel
very interesting that you can get a shaft encoder from an old printer !
i know you can also get good optical sensors from an old mouse
|
|
|
|
|
Logged
|
|
|
|
|
New Hampshire
Offline
God Member
Karma: 13
Posts: 776
There are 10 kinds of people, those who know binary, and those who don't.
|
 |
« Reply #13 on: June 08, 2011, 04:04:25 pm » |
the more pulses the better
What is the basis of that statement? What are you doing with the RPM value and what kind of resolution do you need on the RPMs to effectively accomplish whatever it is you are doing with the value? Any resolution beyond what is necessary to accomplish the task is not only simply wasted, but adds complexity, time, and cost to a project with no benefit. So, just enough pulses to accomplish the task is the best and any more than that is in fact, not better.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 267
Arduino - very interesting !
|
 |
« Reply #14 on: June 08, 2011, 04:21:33 pm » |
i was recommended 100 pulses per rev by a guy who has been doing this stuff since the 1960's
I too share your concerns, but trust this guy 100%
|
|
|
|
|
Logged
|
|
|
|
|
|