Help reduce noise in interrupts... :(

Hello..

I am using arduino's interrupt 0 to measure RPM of my motorcycle and using interrupt 1 to measure speed and distance

dont know why it happens that when I start my motorcycle, both the interrupt (both pins are open ) readings increases with the increase in throttle... If the engine is not running then there is no problem... :frowning:

I am getting mad of how to solve this problem... :frowning:

Are you sure the problem is electrical not in your programming ?

I am sure from my side that it is not a code issue..

this is the code I am using for measuring the RPM

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 9, 8);

const int ignitionPin = 2;
const int ignitionInterrupt = 0;
const unsigned int pulsesPerRev = 1;

unsigned long lastPulseTime = 0;
unsigned long rpm = 0;

void ignitionIsr()
{
  unsigned long now = micros();
  unsigned long interval = now - lastPulseTime;
  if (interval > 2000)
  {
     rpm = 60000000UL/(interval * pulsesPerRev);
     lastPulseTime = now;
  }  
}

void setup()
{
  lcd.begin(16,2);
  pinMode(ignitionPin, INPUT);
  attachInterrupt(ignitionInterrupt, &ignitionIsr, FALLING);
}

void loop(){
  lcd.setCursor(0, 0);
  lcd.print("RPM- ");
  lcd.print(rpm);
  delay(200);
 
}

Hi,
Is your set up decoupled at all ?

I learned a lot from this - De-coupling

Its also possible that your are getting radio frequency interference if you have long unshielded wires in your project or bike.

Duane B

rcarduino.blogspot.com

yes I have the power supply decoupled very well..

Is decoupler also need on the interrupt pins..??

I do have little long wires, but I think it is not that long too... the interrupt wires are around 30 cm long... :stuck_out_tongue:

Hi,
I would suggest twisting the +ve and -ve interrupt wires around each other, I have done this in my RC Cars and its helped, easily done and worth a try.

With regards to the sensor itself, I recall seeing a suggestion to put a decoupling capacitor across the signal and ground pins on IR Receivers as a strategy to eliminate environmental noise so its possibly worth a try to put the same across your sensor to decouple any spikes coming from elsewhere on the bike - anyone care to offer a second opinion on this ?

Duane B.

rcarduino.blogspot.com

twisting the +ve and -ve interrupt wires around each other

I did not understand this part..
I should twist which wire with the interrupt wire...?? +ev wire or the -ev wire

Hmm...

We might have an answer here, what do you mean by 'the interrupt wire' ? do you have a picture of your circuit ?

Duane B.

rcarduino.blogspot.com

Above you can see the home built board ...
A bunch of wires are running out of the board through that wide sleeve to a female 8 pin connector..

Of those wires there are two wires connected to Atmega's pin 4 and 5 which are the interrupts 0 and 1 respectively
One is used for measuring RPM and another is used to measure the speed with a HALL sensor..

You will notice another narrow sleeve which is the power supply for the board..When I connect the power supply to the motorcycle everything is fine, there is no noise in both the interrupts..
But as I will start the enging the interrupts will sense interrupts and show readings on the RPM and SPEED where the RPM and the Hall is not connected.. the readings even increase with the increase in throttle of the engine.. :frowning:

Dont know why is this happening.. :frowning:

Hi,
My guess is that is Radio Frequency interference generated by pulses travelling through the motor bikes wiring, these pulses would be coming from the ignition which would be consistent with them increasing with revs.

I am not sure how your sensors work so if I can ask a stupid questions, where is the earth connection for the two interrupts ?

If they are not earthed, they will be liable to pick up any and all noise just like and arial.

As for twisting the wires, I twist any long pairs of positive and negative wires around each other, this should help to cancel any noise they pick up or emit.

Duane B

Another method would be to put some shielding around that bundle of wires. As I have access to it I would get some braid from some coax cable and the ground it ONLY AT THE CIRCUIT BOARD END. You could also try some aluminum foil around the cable (wrap it with tape to insulate it from everything else) and ground it at the circuit board end.