Messure RPM width interrupt problem

Hi First post here
Must say arduino is great for special thing in a car. :slight_smile:
But got a problem messuring RPM, i need to messure absolutly perfectly. at the messuring is used to control an injectingpump.

i use attachInterrupt(2, rpm_fun, RISING); have also tryed high low falling. non seams to work great.

i messure almost 10 times as many pulses as i should. and the PRM is flagging from 200 RPM 1000 RPM when is is actually running 700 RPM.

I think the problem is in the signal i get from the car. as i have messured RPM perfectly from other cars, width no problem.

https://picasaweb.google.com/olefejer/0206201102?authkey=Gv1sRgCI2f_eSGiJbm5gE#5613583854903019506

Any idea what to do width this signal before it goes in the board ? maby some extra components is needet ?

Any help GREATLY appriciatet.

No shure the the link was working here it is.
https://picasaweb.google.com/lh/photo/SeeYqUijRaG8CxZJ5l1EG13DH6Dyo3hd6XAMSyrO5G8?feat=directlink

Hi,

It seems there is noise on the line, you need a scope to confirm that.

You can adapt the code of the IRQ to handle noise to certain extend. If you know that #pulse per second is e.g. max 50 you can use the following trick. Check if the last IRQ is at least 20 millis ago. SOmething like this:

volatile uint32_t last;

void IRQ()
{
  if( millis() - last > 20)
  {
    last = millis();
    // do your IRQ things here
  }
}

Rob

Hi Rob
thanks for a suggestion. its a good idea, but the problem is that when the engine is running full speed its almost the same as the noise when idle, 700 RPM idle 6000 RPM max. you see the problem,
I think i need some hardware before the signal goes in to the interrupt pin on the arduino. but no idea what to use, any help from you hardware guys :slight_smile:

but no idea what to use

First off, I'd use an oscilloscope.

I have used an oscilloscope, here is the signal i need to detect.

https://picasaweb.google.com/lh/photo/SeeYqUijRaG8CxZJ5l1EG13DH6Dyo3hd6XAMSyrO5G8?feat=directlink

it gives me almost 10 times to many signal. and i have a common ground, on the board and the car.

shouldnt two (one ?)diodes in series take care of that ???

Yes it did, the voltage drop takes the lover part away. Thanks. But got a new problem when i drive my mosfett i have interference, on the interrupt same frequence as my pwm. I run the board from usb power, and the mosfet from car. The arduino board and mosfett has common ground?

Hey

Are u taking the signal directly from the crank sensor on the car, or the output for RPM which is given by the engine control module??
If you are taking the output from a sensor, what sensor is it? Hall-effect or variable reluctance??

Nishad

The problem may the very slow rise/fall times of that signal (very slow means more than about 1us for logic purposes!!!)

If there is high frequency noise on the signal it will cause multiple triggering. The 328 chip has a small amount of hysterysis on its inputs but I am guessing this is not enough. A schmidt-trigger logic gate is needed to 'clean up' the signal and prevent multiple triggers. A 74HC14 hex-inverter chip for instance - this will be resistant to noise of several volts magnitude and the output switches fast and cleanly whatever the input does.

Another problem might be signal reflections from the leads and EMI pickup - this can be reduced by using an RC low-pass filter in the input before the schmidt trigger gate - say 10k in series with the input to 1nF to ground.

To Nishad :
The sensor is an inductive type a coil width a magnet in the middle, and metal running by, and i want to be able to read this signal, as i dont have this computer in the car where the engine goes,

To MarkT :
Thanks alot for hopfully some great info, Just ordert some 74HC14 hex-inverter chip, this sounds just like what i need, lets hope. and i will try out the RC low-pass filter. to see if this helps.

I get back width info when i have tried it out. THANKS

you may bre able to get a cleaner signal from an injector wire, or from the wire that triggers the ignition coils

ht leads are noisy by nature and you may need to use something other than an inductive pickup

you may need to halve the signal on a 4 cylinder car if it is running wasted spark

There is no ignitions wires as it is a diesel, the only thing i got is the RPM sensor.
The Diesel injection pump controlling the amount of diesel injectet by a PWM signal.
It is a 3,0 L mercedes turbo Diesel engine witch can give 400 HP, width the rigth turbo and amount of diesel.
Thats why i am focused on getting a clean signal,

I got the 74HC14 hex-inverter chip today and now ready to some test on the car. get a totally square signal now from a PC blower i used to test it

By the way i have many ways of killing the engine, as we dont want a 400 HP runaway engine.

If you are interested you can see the previous test here

sldiesel:
To Nishad :
The sensor is an inductive type a coil width a magnet in the middle, and metal running by, and i want to be able to read this signal, as i dont have this computer in the car where the engine goes,

I just went through this same thing reading RPM off my car from the crank signal, which is also a reluctance sensor. Since this signal is AC and, at least on my car, has an output range from <1v to over >40v) you may need something like the LM1815 chip to convert its signal to something an Arduino input can reliably read.

you can buy a reluctor interface which will convert an analogue signal to digital for the crank sensor


the injector driver should output a square wave signal with a a varying pulsewidth, the pulse width could be quite small at low rpm's

at high rpm's the pulse width can be quite wide and the system goes into 100% duty cycle

if this happens the injector is wide open and you loose the ability to use it to measure rpm

Hi All
I have now testet the 74HC14 hex-inverter chip on the Car, and it works perfectly. now i got a 100% square signal :-).
but still have a noise sourse when i use PWM in the Car, when i remove everything from the car and build the same on a table, i have no problem.
i have some ideas i have to test, bigger wire. better ground, keep pwm far avay from signal wire and so one. i let you know when i got it to work

Hi again
I have now added a Mosfet driver chip as i thought it was electric noise, but still have same problem.

Let me refresh
when using interrupt to measure RPM from an engine and controlling a pump width PWM the interrupt goes crazy.
i can also see this problem when i on the table connect a PC cooler and measure the RPM from that using interrupt, as soon i use interrupt the RPM i measure jumps crazy up and down ?.
But the funny thing is that if i implement PWM but don't connect anything to the pin, everything is ok. ??
if i read this page http://www.arcfn.com/2009/07/secrets-of-arduino-pwm.html
Can it has to do width the internal timer going crazy ?.

Iam lost what should i do.

I have done other projects where exatly the same thing happens, but they are not so critically, i just filter the values and they work ok,

Would it be an idea to implement an external PWM driver. but how do i implement this any help ?

Regards
Ole

Have you scoped your input pin before and after your PWM circuit is causing it to go crazy? If you run PWM without anything plugged into the PWM pin and you don't see the problem then I wouldn't be on this being a timer issue.

controlling a pump width PWM

What kind of circuit do you have for this? How are you controlling the Mosfet? What resistors do you have in place? Show as much as you can about this part of your circuit including power going to the valve or solenoid you are controlling.

Mark