Removing noise from the speed sensor of a motorcycle – EESE, 2021jun14, Viewed 109 times
The OP’s NJK-5002C Inductive Proximity Switch NPN Datasheet – Electrokit
TFT Dash 1/6 – Gathering the Parts – 2020Mar22
TFT Dash 2/6 – Stage 1 Assembly – 2020mar24
TFT Dash 3/6 – Continuing Stage 1 Assembly – 2020mar25
TFT Dash 4/6 – Mounting the boards – 2020mar27
TFT Dash 5/6 – Completing Stage 1 Assembly – 2020mar27
TFT Dash 6/6 – Final Assembly – 2020mar27
The TFT Dash Project – 2019oct09
NJK-5002C NPN Hall Effect Magnet Proximity Sensor for Arduino DIY – 2019sep22, 5,924 views
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!
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 yesterdayasked 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 6 hours 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 6 hours 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 6 hours 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 6 hours 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 6 hours ago
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 BLDC motor? How to fix this problem?
Part A Troubleshooting Suggestion
/ to continue, …
/ to continue, …
Appendix A – NJK-5002C Datasheet/Tutorial Reading Summary Notes
How inductive proximity sensors work
Inductive proximity sensors are used for non-contact detection of metallic objects. Their operating principle is based on a coil and oscillator that creates an electromagnetic field in the close surroundings of the sensing surface.
The presence of a metallic object (actuator) in the operating area causes a dampening of the oscillation amplitude. The rise or fall of such oscillation is identified by a threshold circuit that changes the output of the sensor.
The operating distance of the sensor depends on the actuator’s shape and size and is strictly linked to the nature of the material (Table 1).
Table 1. Sensitivity when different metals are present. Sn = operating distance. Iron (Fe37) = 1.0 x Sn Stainless steel = 0.9 x Sn Brass - Bronze = 0.5 x Sn Aluminum = 0.4 x Sn Copper = 0.4 x Sn
2 wire DC: These sensors contain an output amplifier with the function N.O. or N.C. that can pilot a load connected in series. In this system a residual current flows through the load even when in the open state and a voltage drop occurs to the sensor when it is in the closed state. Attention must be paid to these restrictions when selecting relays or electronic controls to be used with these sensors. They are compatible with P.L.C. units.
3 & 4 wire DC: These amplified D.C. sensors contain an output amplifier. They are supplied as 3 wire with function N.O. or NC and as 4 wire with complementary outputs (NO + NC) in the types NPN and PNP. Standard version include protected against short circuit, protected against polarity and peaks created by the disconnection of inductive loads. They are compatible with P.L.C. Units
Analog & Linear: In these 3 wire amplified sensors a current or voltage output varies in proportion to the distance between the sensor and a metallic object.
NAMUR: These are 2 wire non-amplified sensors whose current varies in the presence of a metallic object. The difference between these sensors and traditional sensors is the absence of amplifier trigger stages. Their current and voltage limits allow them to be used in hazardous (explosive) environments when used with approved amplifiers. In standard applications (normal atmospheres) the sensor must be used with amplifier units ALNC, ALN2 or similar.
2 wire AC: These are two-wire sensors that contain a thyristor output amplifier. In this system a residual current flows through the load even when in the open state and a voltage drop occurs to the sensor when it is in the closed state. Attention must be paid to the minimum switching current, residual current and voltage drop when selecting low consumption relays or high impedance electronic controls to be used with these sensors. They are compatible with P.L.C. Units
NO (normally open): A switch output that is open prohibiting current flow when an actuator is not present and closes allowing current flow when an actuator is present.
NC (normally closed): A switch output that is closed allowing current flow when no actuator is present and opens prohibiting current flow when an actuator is present.
NPN Output: Transistor output that switches the common or negative voltage to the load. The load is connected between the positive supply and the output. Current flows from the load through the output to ground when the switch output is on. Also known as current sinking or negative switching.
PNP Output: Transistor output that switches the positive voltage to the load. The load is connected between output and common. Current flows from the device’s output, through the load to ground when the switch output is on. Also known as current sourcing or positive switching.
Operating Distance (Sn): The maximum distance from the sensor to a square piece of Iron (Fe 37), 1mm thick with side’s = to the diameter of the sensing face, that will trigger a change in the output of the sensor. Distance will decrease for other materials and shapes. Tests are performed at 20ºC with a constant voltage supply. This distance does include a ± 10% manufacturing tolerance.
Power Supply: The supply voltage range that sensor will operate at.
Max Switching Current: The amount of continuous current allowed to flow through the sensor without causing damage to the sensor. It is given as a maximum value.
Min Switching Current: It is the minimum current value, which should flow through the sensor in order to guarantee operation.
Max Peak Current: The Max peak current indicates the maximum current value that the sensor can bear in a limited period of time.
Residual Current: The current, which flows through the sensor when it is in the open state.
Power Drain: The amount of current required to operate a sensor.
Voltage Drop: The voltage drop across a sensor when driving the maximum load.
Short Circuit Protection: Protection against damage to a sensor if the load becomes shorted.
Operating Frequency: The maximum number of on/off cycles that the device is capable of in one second. According to EN 50010, this parameter is measured by the dynamic method shown in fig. 1 with the sensor in position (a) and (b). S is the operating distance and m is the diameter of the sensor. The frequency is given by the formula in fig. 2.
Repeatability (%Sn): The variation between any values of operating distance measured in an 8 hour period at a temperature between is 15 to 30ºC and a supply voltage with a <= 5% deviation.
Hysteresis (%Sn): The distance between the “switching on” point of the actuator approach and the “switching off” point of the actuator retreat. This distance reduces false triggering. Its value is given as a percent of the operating distance or a distance. See Fig. 3
Flush Mounting: For side by side mounting of flush mount models refer to Fig. 4a. Non-flush mount models can be embedded in metal according to Fig. 4b. for side by side refer to fig. 4c. Sn = operating distance.
Protection Degree: Enclosure degree of protection according to IEC (International Electrotechnical Commission) is as follows:
IP 65: Dust tight. Protection against water jets. IP 67: Dust tight. Protection against the effects of immersion
Appendix B – NJK-5002C Hall Sensor Proximity Switch NPN 3-wires Normally Open Type Spec Summary
This Inductive Proximity Switch Sensor is ideal for detecting the presence of ferrous or magnetic objects to determine rotational speed, the presence or absence of parts, or position limits.
NJK5002C (8002C) Output NPN, N.O. (Normally Open) 3 Wire Type: (Black = Signal Output, Brown= +VDC Power In, Blue=Ground) Detecting Distance : 5-8mm Supply Voltage : DC +5-30VDC Max Current Output : 150mA Operating Temperature: -25°C to +55°C Sensor: 40mm x 12mm (1.5" x 0.47") (LxD) Cable Length: 115 cm / 45 inches
Appendix C – Optically isolated proximity switch schematic
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 yesterdayMilliways49k2525 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 yesterday
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.
- 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 yesterday
- 1@mina is everything properly grounded together? – Swedgin yesterday
- 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 yesterday
- 1@mina You need to edit all clarifications into your original question. I am confused by a seemingly contradictory set of symptoms. – joan yesterday
- 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 yesterday