Uncategorized

Proxmity Sensor Testing Notes

GPIO configured as interrupts detects noise of the engine even if isolated

Ask QuestionAsked yesterdayActive todayViewed 40 times1

Did anyone work with a Raspberry Pi in a an automotive project ?

I am working on creating a dashboard for a motorcycle and it is making me crazy!

when configuring a GPIO pin as an interrupt it detects many pulses if the engine is running ! There is no problem with the other GPIO pins that they are not configured as an interrupt they work as expected!

But for the speed I am working with NJK-5002C sensor which is an NPN sensor , if it detects something the output will be connected to the GND. So I am configuring a pin as a pull Up GPIO and as an interruption to use it for this sensor.

It has been a while that I am facing this problem, I though it is because of the sensor but it is not. so to locate the problem I just started by testing the Raspberry Pi in this environment without even connecting the sensor and without connecting any thing to any GPIO. I just connected my Raspberry pi to the official power supply so the raspberry is totally isolated from the engine’s battery, I configured a pin as a pull up and an interrupt so it contains an internal pull up resistor and when I run the engine it detects nothing but if I just connect any type of wire to this GPIO and add simply a 10Kohm external pull up resistor without even connecting the output of the sensor to the GPIO. the wire acts like an antennae and detects all that noise coming from the engine and the alternator. I tried also with the coaxial cable and same thing ! So when my raspberry has a pin configured as an interrupt and it is just connected to an external pull up resistor and nothing else it is detecting noise!

enter image description here

For the software I am working with the WiringPi library so when configuring the pin I am using the wiringPiISR. I though that maybe the problem comes from this library which is not official so I tried the same thing with the Arduino and even the Arduino detected this noise.

Please if anyone worked with a Raspberry Pi on such a project tell me what should I do It’s been a while that I am facing this problem !gpioelectronicsinterruptssignalShareEditFollowCloseFlagedited 21 hours agoasked yesterdaymina13766 bronze badges

  • @mini, (1) Your interesting problem can can be briefly described as: “How come a Rpi GPIO pin in interrupt mode, connected to a NJK-5002C proxmity sensor, is detecting unwanted noisy signals from an e-Bike engine? How to fix this problem?” / to continue, … – tlfong01 42 mins ago    
  • / cont’d, … (2) My question: Can you give me the link to your eBike? Is it something like this: E-BIKE Munro 2.0 Electric motorbike 48V lithium battery electric motorcycle 26 inch emotor – AliEx, US$7,000 aliexpress.com/item/… / to continue, … – tlfong01 40 mins ago   
  • / cont’d, … (3) Can you give me a link to the dashboard you are trying to copycat?. Is it very roughly something like this? 48 Volt 1000 Watt 26 Inch Electric Bicycle Conversion Motor Kit LCD display to show battery power, time, speed, mileage and gears (Motor: 48V/1000W/470rpm) – Amazon amazon.com/Electric-Bicycle-Conversion-Motor-Front/dp/…, /to continue, … – tlfong01 39 mins ago   
  • / cont’d, … (4) Or are you playing with an conversion kit like this? Bafagn 48V 750W Ebike Conversion Kit for Bikes 20″ 26″ Rear Wheel Brushless Hub Motor Fat Tire Electric Bicycle Conversion Kit with LCD Display and Battery – Amazon amazon.com/BAFAGN-Ebike-Conversion-Electric-Display/dp/…, / to continue, … – tlfong01 27 mins ago   
  • / cont’d, … (5) I think the root cause of you noise problem is the BLDC motor, nothing to do with Rpi, and WiringPiIsr. (6) So I would suggest to start troubleshooting with a simple hardware test setup described below: (a) BLDC motor: your 48V/1000W gear BLDC motor, or at my side Aslong JGB37-3625 7~960rpm 24V Brushless DC Mini BLDC Gear Motor – AliEx US$26 aliexpress.com/item/32840957997.html? spm=a2g0o.search0302.0.0.6e844d36e33ITr&algo_pvid=null&algo_expid=null&btsid=0bb0623b16246955013437892eb447&ws_ab_test=searchweb0_0,sear, / to continue, … – tlfong01 1 min ago   Edit   

Add a comment

2 Answers

ActiveOldestVotes1

In my younger years (long before microprocessors) I spent some time working on automotive electronics. This is a HOSTILE environment – motorcycles are an order of magnitude worse.

It is possible BUT is somewhat a specialist field. You NEED an isolated supply, extensive shielding, all inputs should ideally be galvanically isolated and any connections need filtering and should be low impedance (internal pullups are a joke). All wiring needs careful consideration to routing, and single point earthing is mandatory.

This is not specific to the Pi. Just look at the dedicated electronics in most cars for examples.ShareEditFollowFlaganswered 20 hours agoMilliways49k2525 gold badges8181 silver badges161161 bronze badges

  • 1for my dashboard I developed a Qt application. the complete system reads the signal from all the sensors and output the result on a GUI application on the screen. When the engine is running the signal that are coming from light, Gear, fuel level and are connected to the GPIO pins that are not configured as interrupt works normally only the one GPIO that is configured as an interrupt is causing the problem and it is detecting noise. This seems so weird to me ! why is the problem comes only when configuring the pin as interrupt – mina 20 hours ago

Add a comment2

Any GPIO which is not connected to a voltage will float between high and low.

You need to give the GPIO a fixed voltage by supplying a pull to 3V3 or a pull to ground.

The weak internal pulls (about 50kohm) can easily be overcome by noise.

Try adding an external pull of around 5kohm or lower until the GPIO is stable in your environment.ShareEditFollowFlaganswered 23 hours agojoan63.3k55 gold badges6161 silver badges9797 bronze badges

  • 1actually when I don’t add the external pull up to the GPIO it didn’t detect noise as the GPIO is a configured as a Pull UP so has an internal pull up resistor. but when adding an external 10Kohm pull up resistor it detects noise ! It is because of the wiring that are acting like antennae and I didn’t find any solution for this – mina 23 hours ago 
  • 1@mina is everything properly grounded together? – Swedgin 22 hours ago
  • 1to locate the problem, I am just powering the Pi with the official supply power, I didn’t even connect the output of the sensor or any thing to the GPIO of the Pi , the pi is just connected to the official power supply, a micro HDMI and a USB for the screen and nothing else, nothing is connected to any GPIO. when running the engine nothing will be detected but just by adding simply an external pull up it starts detecting noise 😦 – mina 22 hours ago
  • 1@mina You need to edit all clarifications into your original question. I am confused by a seemingly contradictory set of symptoms. – joan 22 hours ago 
  • 1I just edited my post sorry for my english, hope it is clear now. It has been like 2 months that I am facing this problem. this is my post on electrical engineering forum electronics.electronics.stackexchange.com/questions/571035/… First I though it is because of how I was doing the conditioning of my sensor but when starting to locate the problem i found out that the GPIO is detecting noise even if the sensor if not connected ! just having a wire that connectes a pull up from the GPIO to 3.3v causes problem – mina 21 hours ago 

Add a comment

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.