Messure RPM width interrupt problem

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

Hi Have just made the setup as simple as possible to see if the problem is still there, i have removed LCDDisplay code EEPROM code and anything else.

Problem still there.
But as soon i remove PWM from code RPM is 100% consistent.

i made a video for you helpful people to see.

Here is the code. made as simple as possible. i have ewen tryed also to remove Serial communication, no help.

----------------------------------------------------code---------------------------------------------
unsigned long LcdLoopTime =0;

unsigned long RpmNew2 =0;

unsigned long RpmNewMin =0;
unsigned long RpmNewMax =0;

unsigned long RpmTOld2 =0;
unsigned long RpmTNew2 =0;
unsigned long rpm_motor =0;

void setup()
{
Serial.begin(9600);
pinMode (21,INPUT); //RPM interupt interupt
digitalWrite(21, HIGH); //interupt interupt skal måske væk
attachInterrupt(2, rpm_fun, RISING); //RISING LOW FALLING CHANGE
pinMode(11, OUTPUT); // sets the pin as output

}

void loop(){
if (rpm_motor < RpmNewMin) {RpmNewMin = rpm_motor;}
if (rpm_motor > RpmNewMax) {RpmNewMax = rpm_motor;}

if(millis()>LcdLoopTime)
{
LcdLoopTime+=200;
Serial.print(rpm_motor); Serial.print(" "); Serial.print(RpmNewMin); Serial.print(" "); Serial.println(RpmNewMax);
RpmNewMin =rpm_motor;
RpmNewMax =rpm_motor;
}

if (RpmNewMax > 1200) {analogWrite(11, 254);} //0 - 255
if (RpmNewMax < 1200) {analogWrite(11, rpm_motor /5);} //0 - 255
}

void rpm_fun()
{
RpmTOld2 = RpmTNew2; RpmTNew2 = micros(); RpmNew2 = ( RpmTNew2 - RpmTOld2 );
rpm_motor = (10800000 /RpmNew2); // 10 800 000 / 16129 microsec = 669 omdr/min ved 62 HZ
}
----------------------------------------------------code END-----------------------------------------

extent:
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.

What do you mean by that. i have made a new test where the hall signal goes direct to interupt pin, common grund to battery and arduino.
I have 1K between mosfet and arduino.

If you haven't yet, you should read up on the LM1815 chip as it is designed specifically for what you're doing.

From the LM1815 datasheet:

The LM1815 is an adaptive sense amplifier and default gating
circuit for motor control applications. The sense amplifier
provides a one-shot pulse output whose leading edge
coincides with the negative-going zero crossing of a ground
referenced input signal such as from a variable reluctance
magnetic pick-up coil.

GlitchBoy:
If you haven't yet, you should read up on the LM1815 chip as it is designed specifically for what you're doing.

From the LM1815 datasheet:

The LM1815 is an adaptive sense amplifier and default gating
circuit for motor control applications. The sense amplifier
provides a one-shot pulse output whose leading edge
coincides with the negative-going zero crossing of a ground
referenced input signal such as from a variable reluctance
magnetic pick-up coil.

When i messure signal in a car i use 74HC14 HEX SCHMITT-TRIGGER inverters chip to get a square great signal.
But from the PC blower i have a nice 100% squre signal not missing a beep at looking at the scoope ?

But suddently the Interupt pin fires i between signals giving me a readout of way to high RPM

you have electrical noise

what is the spec of the rpm sensor ?

is it a VR sensor with analogue or digital output ?

Gadget999:
you have electrical noise

what is the spec of the rpm sensor ?

is it a VR sensor with analogue or digital output ?

I have tried almost any sensor the km sensor in the car the RPM sensor the Turbo RPM sensor, in the car And the type is width a magnet inside and a coil outside, triggert by metal passing by.
I have tried to connect them direktly and true the 74HC14 HEX SCHMITT-TRIGGER inverters chip. always get signal working ok, but when using PWM the problem starts.
I also thougt it was electric noise to start width thats why i made the setup on the table to try the most simple setup. but still no consticent signal. and the signal from the PC blower, is 100% squre 0 - 4.5 V that should be ok.

It is diffucult to see from the video but, it looks like you are sharing 1 ground wire with you Mosfet and your Schmitt trigger.

I would recommend that the Schmitt trigger have it own power,signal,ground wires to the Arduino to eliminate noise from other loads on the wire.

Mark

cyclegadget:
It is diffucult to see from the video but, it looks like you are sharing 1 ground wire with you Mosfet and your Schmitt trigger.

I would recommend that the Schmitt trigger have it own power,signal,ground wires to the Arduino to eliminate noise from other loads on the wire.

Mark

Hi Mark after a lot more failure search i found that i can get the Interrupt to fail when connecting the scoop to the PWM pin. but if i connect it after a 1 Kohm then no problem.

But i almost sure i found the problem.
If i have a LCD display 4 X 20 connected, i update i every 1 sec. and every sec i get a misfire from the interrupt port. :frowning:
If i dont write anything to the LCD no problem, I use the Serial Monitor to see the RPM,

Is there something in the LCD Library that using interrypt or using delay in an interupt.

Any idea.
Ole

Hi All
Thanks for any help
I have solved all problem.

Now the LCD Display is run by SPI (using I2C giving same problem as Parralel) i use this i2c / SPI character LCD backpack - STEMMA QT / Qwiic : ID 292 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Now using Interrupt to measure RPM 100% correctly.
PWM is now running perfect, without any hick-ups.

Congratulations! Good to hear you have success.

Mark