IR line sensor? Reading rpm.

I want to read rpm of an engine flywheel. I thought of either doing this with a hall effect sensor and magnet on the flywheel, or somthing else I have seen done is the flywheel painted black with a white line. There is a IR led directed at the flywheel and a IR sensor, when the white line passed the sensor it reflects the IR light to the sensor.

But I do not know which type of sensor to use. I have sensors used for IR remotes, and I also have another setup from a robot for "line detection".

The one from the robot is from a cybot. http://en.wikipedia.org/wiki/Real_Robots

From what I can tell it has an IR led, and another 2 pin device that looks like an led. My guess is, that its resistance changes with the amount of IR detected.

What is the best way to measure the rpm of the flywheel?

I think the "line detection" sensor will work with the black-and-white painting. These typically have an LED and a phototransistor (also can look like an LED). Here is a circuit that was intended to work as a photointerrupter but has the same basic structure as a photoreflector: You can also get a specialized LED/detector mounted in a single IC so it's nice and tidy. Something like the Omron EE-SY124.

You can certainly use a painted line for rpm sensing. One thing to worry about is the dirt and oil film that tend to collect and interfere with the measurement.

You can count teeth on a starter gear with a hall effect sensor or a projection on any other object that has a fixed relationship to crankshaft rotation. You can also drill a depression to sense but a projection gives you a higher output.

Printers usually have 2 or 3 photo interrupters (and encoder wheels and/or strips) and I've found photo reflector in an HP DeskJet.

I will try "RuggedCircuits" way for now since I have the parts handy.

This is actually for a 2 stroke engine. I want to eventually to be able to control spark timing with an arduino. So it would be good to know exactly where the flywheel is.

I have a few ideas on how to do this:

1.) 1 signal per rotation (either IR, or hall sensor), then based on the rpm we can guess where the flywheel is based on time. Example: At 6000rpm the piston will be 30*btdc in 100ms after the arduino has received a signal.

2.) The flywheel has 18 cooling fins on it. (one is broken off tho :o). I could paint the flyhweel black and the edges of the fins white, and detect each fin go past. This would give me higher accuracy in guessing where the flywheel is. Tho the problem is, if the arduino misses one of the fins (dosent reflect properly or somthing) it would then become "out of sync". Maybe I could have two sensors, 1 to count flywheel fins, and another that triggers once every revolution to keep it in sync.

18 fins / 360 degrees = 20 degrees. So I would get a signal every 20 degrees, then I could guess alot more accuratly where the flywheel is exactly.

But 18 fins at 14,000 rpm is 4200 interrupts per second. Plus another 233 interrupts if I use a second sensor. I would also like to run a serial LCD.

2 stroke engine ... 14,000 rpm

Yikes! That's impressive! The fastest 2 stroke engine I've ever touched is a lawn mower engine.

I have a suggestion... put the timing mark at the maximum angle before top-dead-center the spark will ever be fired. The program can then...

  • Wait for the timing mark
  • Delay for the spark time (if necessary, using micros)
  • Fire the spark
  • Spend the remaining time handling the user interface and LCD

This should give you the highest possible precision in firing the spark and still have some time left over to do other things.

Those engines tend to be dirty and a lot of smoke and sooth come out because of the burning oil. This might quickly lead to degradation of light depending sensors. It depends on how everything is built of course. Maybe the hall effect sensor will be better.

This side of the engine is actually remarkably clean, it is almost spotless. The other side tho... with the exhaust and the chain, is very dirty :)

But yes, a hall effect sensor would be much more reliable.

Yikes! That's impressive! The fastest 2 stroke engine I've ever touched is a lawn mower engine.

It is a chainsaw engine. I remember testing it at some point and it revved somewhere around there. But I will let you know exactly when I get this working :)

I like your idea. Later on I would also like to monitor throttle position and engine temperature.

I have considerable experience along these lines and I can tell you for certain that guessing where the flywheel is based on a 1PPR is not going to give you the precision you need. CB’s suggestion has merit.

Bear this in mind though, at 14,000 rpm, 1 degree of crankshaft rotation happens every 11.9 usec. I don’t think the Arduino is capable of doing the timing to that precision and if it is it certainly won’t be doing anything else. Your performance will suffer greatly if your ignition timing is imprecise.

Oh, and you will definitely need some way to indicate the once per rev event to stay synchronized. Two ways to do that are to use two sensors or to have the once per rev event produce a longer pulse so that you can discriminate by pulse width.

Edit:

Maybe I'm being a little too pessimistic. If this is more than a one cylinder engine, I suggest that you could use CB's idea and if possible use one sensor per cylinder to avoid synchronization issues. You could compute RPM off either of those sensors. There is jitter built into the AVR's interrupt handling, but you can use the timers to correct for the variable latency.

That is the way it is done on modern engine control units. They have the advantage of using a processor that was designed specifically for the task but if you only have a couple of cylinders, you should be fine.

I don't think the optical approach will give you the repeatability necessary for ignition timing but might give reasonably accurate RPM readings.

I will measure the RPM's first, as it might not go as high as 14krpm. BTW, it is single cylinder.

That's a good place to start. A single cylinder ought to be do-able if you can get reliable timing.

A few things to think about: As the piston passes the intake port and begins compression, it slows down. This translates to a slowing down of the crankshaft as well. You don't notice this when you measure RPM with a 1PPR signal but if you were to use an encoder to measure instantaneous crank shaft velocity, you'd see it.

Now I realize that the piston is moving at its slowest velocity around top and bottom dead center. That comes from the crank/con-rod geometry. The change I'm talking about is purely from compression loading. This could affect the accuracy of your ignition timing since you'll be measuring time from a reference point not actual degrees. You can take care of that in software though.

I kind of knee jerked at the beginning of your post because I'm used to thinking about 20 cylinder two-strokes, some with articulated rod geometry. It took me a minute to wrap my brain around one or two cylinders. :)

I completely understand what you mean. It would be nice to have more than 1PPR, but the arduino might not be able to keep up.

This is just for an experiment / somthing to do, so it dosent have to be super accurate, but it would be nice to get it as accurate as possible.

Bear this in mind though, at 14,000 rpm, 1 degree of crankshaft rotation happens every 11.9 usec. I don't think the Arduino is capable of doing the timing to that precision

In theory, it should be possible to get within one machine instruction (1 / 16,000,000 of a second ± crystal inaccuracies) of the fire point. There is a fairly significant overhead for an interrupt service routine (about half the registers are saved to the stack). About a dozen machine instructions are execute for digitalWrite (to fire the spark). Getting the timing just right will definately require either accounting for the overhead or some hand-coded assembly.

and if it is it certainly won't be doing anything else

No doubt! ;)

I don't think the optical approach will give you the repeatability necessary for ignition timing but might give reasonably accurate RPM readings

I know that the optical approach was used in "old" cars to measure RPM. I also know there is observable jitter (meaning it's possible for a human with bad eyesight to notice the jitter which means it's fairly bad).

What are used in modern automobiles? Magnet with Hall sensor?

I'm used to thinking about 20 cylinder two-strokes, some with articulated rod geometry

Wouldn't happen to be a gas compressing / transporation engine?

One more thing: Sometimes small two-stroke engines have some (typically mechanical) method of adjusting the ignition timing. If the engine in question has such a thing, instead of directly controlling the fire point, the Arduino could control the ignition timing thingy.

What are used in modern automobiles? Magnet with Hall sensor?

VR sensors and hall sensors.

One more thing: Sometimes small two-stroke engines have some (typically mechanical) method of adjusting the ignition timing. If the engine in question has such a thing, instead of directly controlling the fire point, the Arduino could control the ignition timing thingy.

This engine dosent, it is fixed at 30*

What are used in modern automobiles? Magnet with Hall sensor?

The new Hall sensors have a biasing magnet built in, but basically, yeah.

Wouldn’t happen to be a gas compressing / transporation engine?

Lucky guess. :smiley: Yeah, like a big Cooper-Bessemer. Two power cylinders and a compressor cylinder on the same throw. Real beasts. :slight_smile:

the Arduino could control the ignition timing thingy.

That would be fun, maybe a servo? Not sure what the thingy looks like on a chainsaw engine, might not be much room.

This engine dosent, it is fixed at 30*

Not even a centrifugal thingy? Totally static timing? This gets easier and easier! :slight_smile:

Just for grins, when you’ve got the head off your engine, you can tell how many degrees you are from top dead center by measuring the piston position. You will want to change the print precision probably.
:wink:

/* Given the crankshaft stroke radius and the connecting rod length calculate the normalized
   piston position (0.0-1.0). Multiply the fraction by the stroke to get actual piston position for your particular engine.
*/
float Master_piston_position;
 
void master(void)
{
// change stroke radius and rod length to match your engine
  float Stroke_radius = 3.5;  // equal to half of the stroke
  float  Master_rod_length = 14;  the distance between centers on connecting rod   
  int Crank_angle; 
  float Stroke;
  float Convert_to_radians = 2 * 3.14159 / 360;
  float Theta;                              
  float  Q_squared;                         
  float  Cosine_Phi;
          

  Stroke = Stroke_radius * 2.0 ;
  Q_squared = pow(Stroke_radius / Master_rod_length,2);
  Crank_angle = 0;

  for (Crank_angle == 0; Crank_angle <= 360; Crank_angle++)
  {
    Serial.print(Crank_angle);
    Serial.print("  ");
    Theta = Crank_angle * Convert_to_radians ;    
    Cosine_Phi = sqrt(1 - Q_squared * pow(sin(Theta),2)) ;
    Master_piston_position = ((Master_rod_length * (1 - Cosine_Phi) + Stroke_radius * (1 - cos(Theta))) / Stroke);
    Serial.println(Master_piston_position);
  }

}


void setup()
{
  Serial.begin(9600);
  master();
}

void loop()
{
}

Not even a centrifugal thingy? Totally static timing? This gets easier and easier!

Yep completely static.

Ive got the IR circuit working just as a test, it turns the pin 13 led on / off just passing a piece of white paper past it. Tho it seems to be picky on how far away it is.

Ive just painted the flywheel black, and it should be dry shortly.

So I guess it's a magneto type ignition? You can replace it with an aftermarket capacitive discharge unit if you decide to do more experimenting.

The IR sensor will have a focal point. You will have to find the best distance. I predict it will be sensitive to flywheel temperature as well. You may end up using a visible wavelength LED and phototransistor.