Where do I have to start? - RPM reading and action at certain engine speed

Hi all,

I am struggling where I have to start with my Arduino project. Altough it is my first Arduino project, I think it is a really simple one which I could realize within a day.. This is what I would like to do: read the signal from a rpm sensor and switch a output pin to a certain voltage when 6000 rpm is reached (for an engine cut-off).

The following rpm sensor (hall effect) is located on my engine dyno I think: http://www.magsensors.com/pdf/427007-10.pdf .
It also have three connection pins, but in the engine dyno manual they also speak about magnectic pick up tachometer (that's of the inductive type, am I right? not hall effect). So I am not 100% sure. However, let's assume it is the Hall effect one.
The output of this sensor is a block pattern Vcc it shows in the datasheet. How do I know the Vcc voltage? Normally 5 Volt or am I wrong?

When I know this, I could start with the code I think. Or is it not possible to connect the sensor wiring directly to my Arduino. After assigning the board pins I think I have to translate theoutput signal to engine rpm. I think it has to do with the amount of tooth on the trigger wheel, am I right?

When the Arduino could measure the engine speed, it has to output a pin to a certain voltage when 6000 rpm is reached (so else - if statement I think). At the moment I don't know what the output voltage has to be. Therefore I have to do some measurements first.

I hope someone could help me with a start code for this project which I could expand. I am not very experienced with programming language, so that would help me a lot.

Thanks in advance guys!

RaceEngineer:
I am struggling where I have to start with my Arduino project. Altough it is my first Arduino project, I think it is a really simple one which I could realize within a day..

Put that right out of your head. Allow at least a week, and lots of coffee.

The first thing you need to do is figure out if your Arduino can detect the pulses from your sensor. I think it should work if you power the sensor using the Arduino 5v pin.

How many pulses per second will you be getting when the engine is running at 6000 RPM?

The following code may help. It is extracted from a project I use for monitoring the speed of a small DC motor. It assumes that the sensor is connected to one the external interrupt pins - read about the attachInterrupt() function.

volatile unsigned long isrMicros;
unsigned long latestIsrMicros;
unsigned long previousIsrMicros;
volatile boolean newISR = false;


void loop() {
   if (newISR == true) {
     previousIsrMicros = latestIsrMicros; // save the old value
     noInterrupts(); // pause interrupts while we get the new value
        latestIsrMicros = isrMicros;
        newISR = false;
     interrupts();
     microsThisRev = latestIsrMicros - previousIsrMicos;
}

void myISR() {
   isrMicros = micros();
   newISR = true;
}

...R

Robin2:
The first thing you need to do is figure out if your Arduino can detect the pulses from your sensor. I think it should work if you power the sensor using the Arduino 5v pin.

I think this is not necessary, because the sensor already functions and so has power from another source. I only have to use the signal output and ground pin. Or am I wrong?
Do you know what kind of intermediate piece I can place between the engine dyno RPM cable? So I could bring the wires I needed to my Arduino?

Robin2:
How many pulses per second will you be getting when the engine is running at 6000 RPM?

The specs say it has a 60-tooth gear wheel. So (6000/60) [rps] * 60 [tooth] = 6000 [pulses / second]

I think this is not necessary, because the sensor already functions and so has power from another source. I only have to use the signal output and ground pin. Or am I wrong?

What is powering the sensor? The level of the output pulse is determined by an internal pullup to that voltage inside the sensor. The sensor can be powered with 4.5 to 24 vdc. If its powered by more than 5v, you will need to drop the voltage to the Arduino input.

There are several different ways to measure rpm. Robin2 has suggested determining the time between two pulses and deriving the rpm from that period.

With 60 teeth on the gear, and possible variations of velocity within one revolution, I think you would be better served by either counting the number of pulses occurring in a fixed period of time, or determining the time period for a number of pulses, rather than just one.

Robin's code could be modified to do this

void myISR() {
static byte count = 0; // if number of counts less than 255, other wise type as static unsigned int
count++;
if(count >= 60) // some number perhaps 60 for one revolution
  { 
   isrMicros = micros();
   newISR = true;
   count = 0;
   }
}

cattledog:
Robin's code could be modified to do this

That seems a very good idea.

And the reason I suggested powering the sensor from the Arduino is to ensure the output voltage is compatible with the Arduino. If the device is powered at a higher voltage then be sure to use a voltage divider to bring the maximum voltage comfortably within the limit acceptable to the Arduino.

...R

cattledog:
What is powering the sensor? The level of the output pulse is determined by an internal pullup to that voltage inside the sensor. The sensor can be powered with 4.5 to 24 vdc. If its powered by more than 5v, you will need to drop the voltage to the Arduino input.

I mean the sensor is powered by an external source (battery or voltage regulator) on the Vcc pin, which determine the output voltage. I have to measure first with a scope what the output voltage is. Today I tried with a multimeter and turn the shaft by hand. I only saw some milivoltage changes when the shaft rotated. Not the result I was aiming for.

However, there was no engine on the dyno and I don't know another way to measure the sensor output right now. Beside this, thanks for your advice about the software.

Robin2:
And the reason I suggested powering the sensor from the Arduino is to ensure the output voltage is compatible with the Arduino. If the device is powered at a higher voltage then be sure to use a voltage divider to bring the maximum voltage comfortably within the limit acceptable to the Arduino.

Ah smart idea, not tought of that option. There is a change that the sensor is powering by 12 Volt. Altough I hope it is already 5V. I first have to measure this before I am 100% sure about this.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

Have you googled arduino uno tacho

Tom.... :slight_smile:

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

Have you googled arduino uno tacho

Tom.... :slight_smile:

Hi,

Of course I used Google first, before I will start a new topic..
The problem is I don't know how and where to start exactly, because I am not expierenced with programming.

RaceEngineer:
before I will start a new topic..

Keep all your questions about this project in this Thread. It will make it much easier to help you.

...R

The output sinks current, 25mA max. I get that from specifications 3 and 5 of the PDF.

You could probably read it with a pin moded as INPUT_PULLUP, when the pin reads LOW the sensor is signaling a gear tooth.

Get that up and reading first.

Feeding voltage somewhere on a pin signal, I'd say use a transistor but what kind depends on how much current needs to flow.

Put that right out of your head. Allow at least a week, and lots of coffee.

I'd rather adehere to the "change time unit (one day -> one week) and square result (1 week ^2 = 1 week)"...

¡¡Damn!!: It's the same result.

Best regards

Robin2:
Keep all your questions about this project in this Thread. It will make it much easier to help you.

...R

I meant I already used Google before I started this topic..

GoForSmoke:
The output sinks current, 25mA max. I get that from specifications 3 and 5 of the PDF.

You could probably read it with a pin moded as INPUT_PULLUP, when the pin reads LOW the sensor is signaling a gear tooth.

Get that up and reading first.

Thanks for your response! I also read this, but don't exactly know what sinks current means. Does it mean I have to use an Arduino internal pullup resistor to obtain a 0 -5V signal?

Today I will purchase an Arduino, so I could connect only the sensor first to it. I will expand the code today, so I hope I could test the sensor reading on an random toothed gear wheel this week. When that part is done I will start focussing on the output signal.

I was looking for an Arduino. However, which one do you guys recommend me and do I need to buy some accessoires with it (like a breadboard and electrical kind of stuff)?

Hope to hear from you!

Arduino IO (in-out) pins can source or sink current, supply voltage or drain it. There's limits of course.

"Does it mean I have to use an Arduino internal pullup resistor to obtain a 0 -5V signal?"

It will save you building an external circuit. The pin set to INPUT_PULLUP has weak 5V (through 20K to 50K resistor) supplied to it. If you ground it (through much less resistance than 20K) then the pin reads LOW, otherwise it reads HIGH. That's the machine.

So you have an Output on the sensor that either grounds up to 25mA or doesn't ground. You could make a led circuit with 220R resistor that has 5V and wires to the sensor output and ground pins then see if hand-turning makes the led blink.

For Arduinos, look into the Nano but check others too. The Nano is small and has pins that do plug into breadboards. But don't use a breadboard in the end product, they're temporary at best.

If you were farther along, I'd link you on the path to programming bare MCU's because your project can likely run on a 6 or 8 pin ATtiny AVR.

RaceEngineer:
... but don't exactly know what sinks current means. Does it mean I have to use an Arduino internal pullup resistor to obtain a 0 -5V signal?

Other members intervening before do know much more than I do but ...

¿What is exactly your electric/electronic background?
¿Have you got an oscilloscope?
¿Do you know what an interrupt -that you probably will need for this project- is?

Best regards

GoForSmoke:
Arduino IO (in-out) pins can source or sink current, supply voltage or drain it. There's limits of course.

"Does it mean I have to use an Arduino internal pullup resistor to obtain a 0 -5V signal?"

It will save you building an external circuit. The pin set to INPUT_PULLUP has weak 5V (through 20K to 50K resistor) supplied to it. If you ground it (through much less resistance than 20K) then the pin reads LOW, otherwise it reads HIGH. That's the machine.

So you have an Output on the sensor that either grounds up to 25mA or doesn't ground. You could make a led circuit with 220R resistor that has 5V and wires to the sensor output and ground pins then see if hand-turning makes the led blink.

Thanks for your explanation. I could do that first, but I would also like to monitor the speed with println function. I am working on this code right now.

GoForSmoke:
For Arduinos, look into the Nano but check others too. The Nano is small and has pins that do plug into breadboards. But don't use a breadboard in the end product, they're temporary at best.

If you were farther along, I'd link you on the path to programming bare MCU's because your project can likely run on a 6 or 8 pin ATtiny AVR.

I am looking for an Arduino who could also carry out this tasks in the engine dyno environment for the next months. When everything is running we could always upgrade it to a more professional MCU. However, for the next time I am aiming to use Arduino. Would a Nano be enough then?

I was thinking of an Uno or Mega, maybe in combination with a starter kit. So I also have some electrical stuff I could use directly. I could rather buy it myself which is also cheaper I think, but the company is paying and would like to have it all.

The max speed is 12000 counts per second. That's not much faster than 115200 baud serial (11520 cps).
Interrupt should not be necessary for this at all on 16MHz AVR.

vffgaston:
Other members intervening before do know much more than I do but ...

¿What is exactly your electric/electronic background?
¿Have you got an oscilloscope?
¿Do you know what an interrupt -that you probably will need for this project- is?

Best regards

Would you please only response to on-topic questions, so this topic will remain clear for everybody..
However:

  • I am an Bachelor Automotive Engineering student specialized in ICE's. I have had Automotive Electronic lessons and only a very basic course programming in C.
  • Yes we have and I know how it works
  • I know the basics of it and when I need this I will search it by myself on the internet. However, GoForSmoke said I don't need this.

The max engine speed I will measure is 6000 rpm which is equal to 6000 HIGH or LOW pulses per second for a 60 toothed trigger wheel.

If you measure the voltage that is being sent to pin A of the sensor, this should tell you the upper voltage of the square wave signal that will be produced on Pin C. You can then reduce this to 5V if it is higher, and connect it to an interrupt pin on the arduino.

I am working on a similar project currently. I am measuring the RPM of a running motorcycle engine, using a square wave produced by the ECM, and displaying the calculated RPM as a number of LEDs on a neopixel strip.

My signal is a 0-12V square wave. I had to make sure this signal never went higher than 5V before connecting it to the arduino, I used a resistor and zener diode for this purpose. You can also use a voltage divider to get the same result.

Once you have a clean 0-5V square wave signal you should be able to calculate the RPM quite easily and perform any actions you need at certain RPMs.

RaceEngineer:
Thanks for your explanation. I could do that first, but I would also like to monitor the speed with println function. I am working on this code right now.

How are you reading the sensor now? Most of that was about getting good signal to the Arduino.

I am looking for an Arduino who could also carry out this tasks in the engine dyno environment for the next months. When everything is running we could always upgrade it to a more professional MCU. However, for the next time I am aiming to use Arduino. Would a Nano be enough then?

I was thinking of an Uno or Mega, maybe in combination with a starter kit. So I also have some electrical stuff I could use directly. I could rather buy it myself which is also cheaper I think, but the company is paying and would like to have it all.

The Nano is the same chip as the Uno, ATmega328P. Nano is smaller and more breadboard friendly as are quite a few Arduinos and compatibles. Both are massive overkill for your project. The Mega for this... a dumptruck to deliver a postcard.

If this is a company project then you may want to find the smallest, cheapest chip for the job and get the final boards made with that.

You aren't doing enough to need more than a Tiny, why 'upgrade'?

Geez I hope you don't think that Arduino boards aren't professional grade. The IDE is beginner friendly and the pros I know do move on to better but the boards and the chips we uses are all professional.

Here's MIT on programming 8 pin tiny45 and tiny85 chips. See what they can do, it's still more than you need.

I dunno bout you but I bought 4 plastic parts trays with lid at Harbor Freight for $4 each. I got my magnifier visor then too.
I bought discount assortments of resistors and capacitors, and got leds and other bits (diodes, transistors) and still only filled 3.
For jumpers, get DuPont Cables. Get at least 1 of male-male, 1 male-female and 1 female-female. Each has 40 wires.
For the price of most starter kits you could get a lot more.

Look around, shop, you might miss the big toy store if you don't!

"The max engine speed I will measure is 6000 rpm which is equal to 6000 HIGH or LOW pulses per second for a 60 toothed trigger wheel."

That leaves 2666 cpu cycles between pulses at max. Your needs won't take 600 of those. If your code blocks then sure you need interrupts for a lot of things but you will get non-blocking code and you won't need interrupts for this.

rickerman:
If you measure the voltage that is being sent to pin A of the sensor, this should tell you the upper voltage of the square wave signal that will be produced on Pin C. You can then reduce this to 5V if it is higher, and connect it to an interrupt pin on the arduino.

Pin C is an open collector, 25mA max. What voltage will be produced on that?