2

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!

5
  • 1
    Perhaps a 4k7 external pull-up or down and a small capacitor to smooth the signal. This isn't really a Raspberry Pi problem. It is a signal conditioning problem.
    – joan
    Commented Apr 26, 2021 at 10:23
  • 2
    You need to learn the hard lessons about how to interface electronics in a hostile environment. This happens regardless of technology. This is something of a specialist field.
    – Milliways
    Commented Apr 26, 2021 at 11:11
  • Thank you for helping, I will try to learn about how to interface electronics in such environment
    – mina
    Commented Apr 26, 2021 at 13:01
  • More details on your setup might be useful: hardware components, schematics of your wiring, even a picture of your motorcycle with sensor wiring. I can't comment on your software, but a few thoughts on your hardware: GPIO are high input impedance, and wiring of even moderate length can cause issues (false signals). In general, solutions that filter transients are worth a try. For example, you might try a low-pass filter near the GPIO pin. Many tutorials available - for example
    – Seamus
    Commented Apr 27, 2021 at 6:33
  • I would suggest you watch a few tutorials on the automotive electronics environment. It is about the toughest environment for electronics. Give google a try and search for "automotive electronics cookbook" you will get a lot of good leads.
    – Gil
    Commented Jan 18, 2023 at 22:02

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.