3

I am working on a dashboard for a motorcycle. I created a Qt application on my raspberry pi 4 on a raspberry pi os lite.

I have configured one of my GPIO as interrupt using the wiringPi library.

wiringPiSetup();
pinMode(m_pin,INPUT);
pullUpDnControl (m_pin, m_pud) ;
wiringPiISR(m_pin, INT_EDGE_RISING, isrInput);

and in my interrupt handler I am incrementing an attribute.

void Capteur_Input::isrCallback()
{
    increment_impulsion();
    qDebug()<<"nombre d'impulsion"<<get_impulsion()<<"le nombre de tour est "<<(get_impulsion())/4;

}

my sensor is an inductive sensor , each turn it generates 4 pulses. I tested this and it is working fine.

But when putting the sensor on the axis of the motor wheel and running the engine, it shows random values even if the wheel is fixed and not turning.

is it because of the magnetic field generated by the engine alternator?

even when removing the sensor and just leaving a cable connected to the gpio it shows values.

if I remove every thing the gpio of the raspberry does not detect any thing so the problem comes from the cable. how to isolate this?

it shows that the speed is 40 when the wheel is fixed so it is detecting like 20 pulses/second !

The other gpio that are not interrupt works almost fine even when the engine is running.

can some one please help me!

mina
  • 385
  • 2
  • 5
  • 14

1 Answers1

0

An idea is you could implement a RC low pass filter on the offending pins, being the resistor in series and the capacitor to GND.

Since it is a low pass, calculate https://www.translatorscafe.com/unit-converter/pt-BR/calculator/rc-circuit/ the timing constant and cutoff frequency to be a little higher than the one you are measuring. Your filter will look like this http://sim.okawa-denshi.jp/en/CRlowkeisan.htm .

Put the RC close to the Pi not the sensor. basically any capacitor will do, but for your frequencies a cheap electrolytic does the job.

From my experience such RC works pretty well to filter out noise from digital pulses like the ones you have. I once made a bycicle speedometer using Arduino and reed switches, and had to implement RC's as well.