TecHnoGuy
Posts: 20
Joined: Fri Feb 07, 2020 9:06 am

Wiring inductive sensors in series

Fri Feb 07, 2020 9:30 am

Let me preface this by saying I am a mechanical engineering student so I have very limited knowledge when it comes to coding and electronics but I am always happy to learn new things.

I am currently working on a project where I am trying to make a label printer print a time stamp when 6 inductive sensors are activated. I think I will be fine figuring out the CUPS end of things to connect the Pi to the printer, but I am having trouble working out the GPIO end.

The sensors I will be using are these: https://www.pepperl-fuchs.com/great_bri ... #documents

I know that the Pi can only take 3.3V so the output from the sensors will need stepped down, and I assume the sensors will need externally powered in some way. My problem is I only have a vague idea where to start and I would rather order everything that I need all together.

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Wiring inductive sensors in series

Fri Feb 07, 2020 10:55 am

Yes you'll need a seperate power supply to drive these. 12V DC should be sufficient.

As for interfacing to the Pi, I'd recommend an Opto-Isolator for each sensor.
Opto-isolators are basically a light and a light sensor in the same closed box. When the input is active (inductive sensor detects something) the light inside the opto-isolator lights up. That light is detected by the light sensor and the state of the light sensor can be read by a raspberry pi.

Might be worth asking at your Uni if someone can provide some electronics help.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

TecHnoGuy
Posts: 20
Joined: Fri Feb 07, 2020 9:06 am

Re: Wiring inductive sensors in series

Mon Feb 10, 2020 9:05 am

Thanks for the reply. I hadn't heard of opto-isolators before so never would have thought of it. Just to check that I have understood correctly I have made a circuit diagram where the symbols labelled IC are the opto-isolators.
Pi_Senssor-Circuit_1.png
Pi_Senssor-Circuit_1.png (114.91 KiB) Viewed 731 times
(Edit: And also I assumed resistors would be needed between the sensors and opto-isolators)
As for the electronics help, I am currently on placement in industry and I have asked around but no one has much experience with this sort of thing.

User avatar
neilgl
Posts: 2111
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Wiring inductive sensors in series

Mon Feb 10, 2020 9:37 am

That circuit will only set the GPIO2 high when all six sensors are closed - is that what you wanted?

TecHnoGuy
Posts: 20
Joined: Fri Feb 07, 2020 9:06 am

Re: Wiring inductive sensors in series

Mon Feb 10, 2020 9:51 am

neilgl wrote:
Mon Feb 10, 2020 9:37 am
That circuit will only set the GPIO2 high when all six sensors are closed - is that what you wanted?
Yes that is the plan at least

boyoh
Posts: 1468
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Wiring inductive sensors in series

Tue Feb 11, 2020 9:09 pm

TecHnoGuy wrote:
Mon Feb 10, 2020 9:05 am
Thanks for the reply. I hadn't heard of opto-isolators before so never would have thought of it. Just to check that I have understood correctly I have made a circuit diagram where the symbols labelled IC are the opto-isolators.
Pi_Senssor-Circuit_1.png
(Edit: And also I assumed resistors would be needed between the sensors and opto-isolators)
As for the electronics help, I am currently on placement in industry and I have asked around but no one has much experience with this sort of thing.

From BoyOh Before calculating the resistors , What is the sensors out put voltage
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

W. H. Heydt
Posts: 12431
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Wiring inductive sensors in series

Tue Feb 11, 2020 9:22 pm

I guess curricula have changed... When I was starting out as an engineering major, *everyone* took (1) an introductory programming course (Engineering 1, at the time), (2) a beginning electronics course, and (3) a beginning materials course. This was along with lots of physics, chemistry, and math, and dabble a bit in the humanities. One didn't--officially--major in any particular branch of engineering until you were upper division. Lower division, almost all the courses were the same, no matter what sort of engineering you intended go into.

User avatar
neilgl
Posts: 2111
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Wiring inductive sensors in series

Tue Feb 11, 2020 11:10 pm

The datasheet referenced for those devices says Operating voltage 5 ... 60 V - so operating at 5V should drive the optos OK

boyoh
Posts: 1468
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Wiring inductive sensors in series

Tue Feb 11, 2020 11:24 pm

TecHnoGuy wrote:
Mon Feb 10, 2020 9:05 am
Thanks for the reply. I hadn't heard of opto-isolators before so never would have thought of it. Just to check that I have understood correctly I have made a circuit diagram where the symbols labelled IC are the opto-isolators.
Pi_Senssor-Circuit_1.png
(Edit: And also I assumed resistors would be needed between the sensors and opto-isolators)
As for the electronics help, I am currently on placement in industry and I have asked around but no one has much experience with this sort of thing.
From BoyOh
You will won't to incorporate some sort of system fail . With them all being in series you wont to know witch one as failed
You will won't to know if it is the Sensor or the opto isolater as failed This will involve some Logic Thinking
But It can be don

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

emma1997
Posts: 774
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 12:41 am

If I'm not mistaken (it did happen one time at band camp, lol) in that diagram the pinouts on those optos are not correct. AFAIK not that many ICs have a pin 0. Numbered and arranged properly input pins 1-2, output pins 4-5.

Even wired correctly unlikely to function due to Vsat of optos bipolar transistor. MOSFET type might work but cost 20x more and harder to source. I think wiring in parallel instead of series might do it.

Don't seem to be the right interface for those sensors anyway. Little point in double isolation. I know it's unpopular around here due to love affair with optos and widespread FUD but think direct connect would be best. At least the ones I've used.

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 8:12 am

emma1997 wrote:
Wed Feb 12, 2020 12:41 am
If I'm not mistaken (it did happen one time at band camp, lol) in that diagram the pinouts on those optos are not correct. AFAIK not that many ICs have a pin 0. Numbered and arranged properly input pins 1-2, output pins 4-5.

Even wired correctly unlikely to function due to Vsat of optos bipolar transistor. MOSFET type might work but cost 20x more and harder to source. I think wiring in parallel instead of series might do it.

Don't seem to be the right interface for those sensors anyway. Little point in double isolation. I know it's unpopular around here due to love affair with optos and widespread FUD but think direct connect would be best. At least the ones I've used.
Data sheet suggests minimum operating voltage of 5 volts so direct connection might not work reliably. I assume that this is to ensure a good connection due to surface properties of the contacts. Also it might preclude putting sensors in series as some may close with zero volts across them.

I would however not put the optoisolator outputs in series for the reasons you suggest and because in a fault condition you can't tell which one has failed.
(BoyOh beat me to it!)
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

TecHnoGuy
Posts: 20
Joined: Fri Feb 07, 2020 9:06 am

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 12:15 pm

W. H. Heydt wrote:
Tue Feb 11, 2020 9:22 pm
I guess curricula have changed... When I was starting out as an engineering major, *everyone* took (1) an introductory programming course (Engineering 1, at the time), (2) a beginning electronics course, and (3) a beginning materials course. This was along with lots of physics, chemistry, and math, and dabble a bit in the humanities. One didn't--officially--major in any particular branch of engineering until you were upper division. Lower division, almost all the courses were the same, no matter what sort of engineering you intended go into.
I'm a student in the UK and it's much more common to just go straight into a specialised course in Uni (i.e. Mechanical, Civil, Electrical, Chemical etc.). In my first year I did have a module where half was based around electronics and coding but more heavily on the coding end so this sort of thing fried my head a bit.

TecHnoGuy
Posts: 20
Joined: Fri Feb 07, 2020 9:06 am

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 12:22 pm

boyoh wrote:
Tue Feb 11, 2020 11:24 pm
From BoyOh
You will won't to incorporate some sort of system fail . With them all being in series you wont to know witch one as failed
You will won't to know if it is the Sensor or the opto isolater as failed This will involve some Logic Thinking
But It can be don

Regards BoyOh
PeterO wrote:
I would however not put the optoisolator outputs in series for the reasons you suggest and because in a fault condition you can't tell which one has failed.
(BoyOh beat me to it!)
PeterO
It doesn't matter if I know which sensor is not closing as it is easy to see physically. The purpose of the sensors is just to activate the printer which can't be done unless all 6 are active or would this be cleaner to do through programming. Unless you mean to pick up faults in the wiring or components?

TecHnoGuy
Posts: 20
Joined: Fri Feb 07, 2020 9:06 am

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 12:27 pm

emma1997 wrote:
Wed Feb 12, 2020 12:41 am
If I'm not mistaken (it did happen one time at band camp, lol) in that diagram the pinouts on those optos are not correct. AFAIK not that many ICs have a pin 0. Numbered and arranged properly input pins 1-2, output pins 4-5.
I just used a free website to make the circuit diagram which did not have symbols for optos so I just substituted those in to get the idea across. The optos i have looked up I have found the internal diagrams and would connect up accordingly.
emma1997 wrote: Even wired correctly unlikely to function due to Vsat of optos bipolar transistor. MOSFET type might work but cost 20x more and harder to source. I think wiring in parallel instead of series might do it.

Don't seem to be the right interface for those sensors anyway. Little point in double isolation. I know it's unpopular around here due to love affair with optos and widespread FUD but think direct connect would be best. At least the ones I've used.
This bit you've lost me on (might need an eli5). What do you think would be the correct interface for the sensors?

emma1997
Posts: 774
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 6:04 pm

No interface at all. Specially no opto or relays. Just connect to parallel port on the Pi. A load resistor and maybe divider if outputs are over 4v but mine were not so that was not needed.

I did not have time to hunt down specs for your specific part but if they work like industry standard they internally measure change in frequency to detect metal. Output is usually open collector. My platform was AVR (Arduino type chip) but a Pi is surely capable. Principles are the same.

I would suggest testing operation with a DMM or LED before hooking to a computer. Hardware part is easy so IMO this is primarily a software project.

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 6:30 pm

emma1997 wrote:
Wed Feb 12, 2020 6:04 pm
No interface at all. Specially no opto or relays. Just connect to parallel port on the Pi. A load resistor and maybe divider if outputs are over 4v but mine were not so that was not needed.

I did not have time to hunt down specs for your specific part but if they work like industry standard they internally measure change in frequency to detect metal. Output is usually open collector. My platform was AVR (Arduino type chip) but a Pi is surely capable. Principles are the same.

I would suggest testing operation with a DMM or LED before hooking to a computer. Hardware part is easy so IMO this is primarily a software project.
You really need to follow the link that the OP gave to the device data sheet, because you are making all sorts of WRONG assumptions about the device.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

emma1997
Posts: 774
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 6:46 pm

PeterO wrote:
Wed Feb 12, 2020 6:30 pm
You really need to follow the link that the OP gave
No, I don't 'need' to follow any links at all and would have to be considerably more motivated to do so. If OPs don't bother to attach specs I'm not going to bother hunting them down.

You might be right about not understanding details. It's been a few years but I recall there were a couple basic types: 2 wire and 3 wire. That first needed a load and the second external power. Some worked off 3v others used 24v. I didn't need to know much more to finish the project.

In any case I'm hoping my replies have more info than that last (typical) one of yours. :)

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 7:20 pm

emma1997 wrote:
Wed Feb 12, 2020 6:46 pm
PeterO wrote:
Wed Feb 12, 2020 6:30 pm
You really need to follow the link that the OP gave
No, I don't 'need' to follow any links at all and would have to be considerably more motivated to do so. If OPs don't bother to attach specs I'm not going to bother hunting them down.

You might be right about not understanding details. It's been a few years but I recall there were a couple basic types: 2 wire and 3 wire. That first needed a load and the second external power. Some worked off 3v others used 24v. I didn't need to know much more to finish the project.

In any case I'm hoping my replies have more info than that last (typical) one of yours. :)
:lol:
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
neilgl
Posts: 2111
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 7:55 pm

Ah, I did follow the link to datasheet which gave "datasheet referenced for those devices says Operating voltage 5 ... 60 V" but of course it is up to individual people if they do follow or not. AFAIK we are all trying to help the OP ?

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Wiring inductive sensors in series

Wed Feb 12, 2020 8:19 pm

TecHnoGuy wrote:
Wed Feb 12, 2020 12:22 pm

It doesn't matter if I know which sensor is not closing as it is easy to see physically. The purpose of the sensors is just to activate the printer which can't be done unless all 6 are active or would this be cleaner to do through programming. Unless you mean to pick up faults in the wiring or components?
Making provision at the design stage for fault diagnosis during commissioning and during operation will keep your service engineers happier ! Even if it is "one off" that you you are building and you will be maintaining, I would still think about "designing for fault finding".
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

TecHnoGuy
Posts: 20
Joined: Fri Feb 07, 2020 9:06 am

Re: Wiring inductive sensors in series

Thu Feb 13, 2020 8:55 am

emma1997 wrote:
Wed Feb 12, 2020 6:46 pm

If OPs don't bother to attach specs I'm not going to bother hunting them down.
Sorry I had seen other posts on the forums where people had not provided any information on the component they were trying to connect but it was usually sorted whenever they provided a link so i thought that would suffice. (here's a direct link to the data sheet if that's any easier; https://files.pepperl-fuchs.com/webcat/ ... 0130000135)
emma1997 wrote: I did not have time to hunt down specs for your specific part but if they work like industry standard they internally measure change in frequency to detect metal. Output is usually open collector. My platform was AVR (Arduino type chip) but a Pi is surely capable. Principles are the same.
emma1997 wrote:
You might be right about not understanding details. It's been a few years but I recall there were a couple basic types: 2 wire and 3 wire. That first needed a load and the second external power. Some worked off 3v others used 24v. I didn't need to know much more to finish the project.
Yes it is a 2 wire sensor which detects metal, with the default output open.
PeterO wrote: Making provision at the design stage for fault diagnosis during commissioning and during operation will keep your service engineers happier ! Even if it is "one off" that you you are building and you will be maintaining, I would still think about "designing for fault finding".
PeterO
Thanks I'll keep this in mind, it will probably ease some headaches further down the line.

TecHnoGuy
Posts: 20
Joined: Fri Feb 07, 2020 9:06 am

Re: Wiring inductive sensors in series

Thu Feb 13, 2020 8:58 am

From what I have gathered I think I should be able to run the sensors from the 5V pins on the Pi. Then I would connect each to a GPIO input pin and ground with a potential divider to step it down below 3.3v.
Pi_Sensor-Circuit_2.png
Pi_Sensor-Circuit_2.png (39 KiB) Viewed 388 times
Does this look like it should work?

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Wiring inductive sensors in series

Thu Feb 13, 2020 9:18 am

ShortCircuit.png
ShortCircuit.png (45.08 KiB) Viewed 378 times
The basic idea is good, but there are a few extra connections you don't need !
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

TecHnoGuy
Posts: 20
Joined: Fri Feb 07, 2020 9:06 am

Re: Wiring inductive sensors in series

Thu Feb 13, 2020 10:09 am

PeterO wrote: The basic idea is good, but there are a few extra connections you don't need !
PeterO
Ah yes whoops, I had a feeling there was something off about it.
Pi_Sensor-Circuit_3.png
Pi_Sensor-Circuit_3.png (38.86 KiB) Viewed 364 times
More like this instead.

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Wiring inductive sensors in series

Thu Feb 13, 2020 10:23 am

Looks good. The only thing I would do differently is to use 2k2Ω and 3k3Ω in the voltage divider. Why ?
1) 5 * 3.3/5.5 = 3V which will give better noise immunity that 2.5V.
2) It draws less current from the 5V, current that ultimately ends up as heat in the resistors. Using 500Ω+500Ω the maximum dissipation will be 150mW vs 27mW with 2k2Ω+3k3Ω.
E&OE
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Return to “Beginners”