geikith
Posts: 3
Joined: Fri Aug 17, 2018 7:17 am

Floating input on industrial usage

Fri Aug 17, 2018 7:40 am

Hi everyone,

I freshly acquire my first Raspberry Pi, what an awesome device !
I'm currently working on a project to automatically detect if one machine is running or not and counting it's cycles (Using this Pi)
The machine send a 24V pulse at each cycle (About 150 to 400 pulse per minutes).
For that i trigger with a 4N25 optocoupler my 24v signal to 3v3. Using this circuit :
Image


But before all of that, I have a problem, even I remove the link with my machine and use this circuit instead :
Image

My input is floating. Before it was floating only if machine run, and not if the machine is stopped. now it's always floating. Resistance is correctly working, if I use in pull up mode i also have the same issue... I'm sure it's the machine generating much perturbations, same circuit on my desk, no problem, same circuit on the machine (even not linked) it's floating. I will become crazy...
So here i am... If anyone reading this message have some ideas, where it can come from, and eventually how I can solve that ? :?

drgeoff
Posts: 8442
Joined: Wed Jan 25, 2012 6:39 pm

Re: Floating input on industrial usage

Fri Aug 17, 2018 12:52 pm

What do you mean by "floating"? Do you mean the RPi is seeing the GPIO input changing between 0 and 1 and the reverse even with only the 10k resistor connected?

Are there high electrical or magnetic fields where the RPi is at the machine?

User avatar
mikronauts
Posts: 2634
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Floating input on industrial usage

Fri Aug 17, 2018 11:19 pm

The opto isolator circuit needs to connect to the ground of the 24v signal (not the Pi) to the cathode of its led, and 1k8 may be too low a value (i did not check you devices data sheet)

The non isolated circuit would neef to connect the Pi and machine grounds and use a proper voltage divider instead of just a 10k resistor (may damage Pi with just that resistot)
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Paul Hutch
Posts: 279
Joined: Fri Aug 25, 2017 2:58 pm
Location: Blackstone River Valley, MA, USA

Re: Floating input on industrial usage

Sat Aug 18, 2018 12:20 am

The symptom definitely seems like EMI pickup from the other gear.

I'd start by removing the pull down resistor, turning on the internal pull up for the pin, and also add a low value external pull-up to 3.3V for improved noise immunity. I'd start with 1k for the external pull up and go lower if EMI induced GPIO switching persists. If you get down to 100 ohms and are still getting the input changing you've got a lot of work to do likely including shielding and filtering.

Once you get the Pi no longer triggereing due to noise, then connect the photo-transistor emitter to ground and collector to the GPIO input. If you end up going lower than 1k for the pull up you may need to increase the LED current with a lower value series resistor.

User avatar
rpdom
Posts: 12740
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: Floating input on industrial usage

Sat Aug 18, 2018 2:23 am

The other question is which GPIO pin are you using and which naming scheme are you using to access it? (BCM, Board, WiringPi?) It may be you are not reading the pin you think you are reading.

drgeoff
Posts: 8442
Joined: Wed Jan 25, 2012 6:39 pm

Re: Floating input on industrial usage

Sat Aug 18, 2018 9:18 am

rpdom wrote:
Sat Aug 18, 2018 2:23 am
The other question is which GPIO pin are you using and which naming scheme are you using to access it? (BCM, Board, WiringPi?) It may be you are not reading the pin you think you are reading.
I doubt that is the issue. The OP wrote "I'm sure it's the machine generating much perturbations, same circuit on my desk, no problem, same circuit on the machine (even not linked) it's floating."

drgeoff
Posts: 8442
Joined: Wed Jan 25, 2012 6:39 pm

Re: Floating input on industrial usage

Sat Aug 18, 2018 9:22 am

mikronauts wrote:
Fri Aug 17, 2018 11:19 pm
..use a proper voltage divider instead of just a 10k resistor (may damage Pi with just that resistot)
Not so. The only voltages on the RPi side of the opto are ground and 3.3 volts. 3.3 volts is safe without a voltage divider.

User avatar
mikronauts
Posts: 2634
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Floating input on industrial usage

Sat Aug 18, 2018 3:10 pm

My bad, I misread the second figure as vonnecting the 24v direcly using just a current limiting resistor.
drgeoff wrote:
Sat Aug 18, 2018 9:22 am
mikronauts wrote:
Fri Aug 17, 2018 11:19 pm
..use a proper voltage divider instead of just a 10k resistor (may damage Pi with just that resistot)
Not so. The only voltages on the RPi side of the opto are ground and 3.3 volts. 3.3 volts is safe without a voltage divider.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

geikith
Posts: 3
Joined: Fri Aug 17, 2018 7:17 am

Re: Floating input on industrial usage

Sun Aug 19, 2018 12:04 am

Thanks all for your help. According what I ve been thinking and your remark here is what I will try

Tomorrow I will make some tries as Drgeoff notice I'm very close to the machine cabinet and it's transformer. First I will try with the system more far away...
Second I'm afraid the power 220v they install for me for the Pi is using a neutral not fixed to earth.
So I will try with a transformer 220v to 5v and make proper earthing of the neutral. Or use power from another source.
Also I will try with lower resistance value 200 Ohm will give me about 16.5mA for the Pi and transistor of the optocoupler which I think is reasonable. As Paul suggest I already try pull up mode with internal resistance and also with 1k but still same problem.

rpdom, yeah I'm reading the pin correctly unfortunately. If direct connection with wire to Pi GND or if I put 3v3 to the other side of the 10k resistance, then my system is fixed...

Mikronauts, I checked normally 1k8 is okay for the opto isolator that as about 13mA. Max current is 60mA for 4N25 opto isolator.

I keep you in touch. Thanks again for your help!

geikith
Posts: 3
Joined: Fri Aug 17, 2018 7:17 am

Re: Floating input on industrial usage

Tue Aug 21, 2018 10:29 am

Problem solved.
I just take power from another source. Same location for the system. No more issues...
I suspect that the neutral I used before wasn't earthed.

Return to “Advanced users”

Who is online

Users browsing this forum: tmoe and 19 guests