CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Inductive Sensor connected to PIC design question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ed_Banses



Joined: 15 Sep 2005
Posts: 15

View user's profile Send private message

Inductive Sensor connected to PIC design question
PostPosted: Thu Dec 01, 2005 3:09 am     Reply with quote

Hi all,

I am starting a new project where I have to interface some inductive sensors (4 in total) with a PIC microcontroller.
These sensors are powered to 24V and they have a digital output that change from 24V to 0V when it detects metal in its magnetic field.
My problem is that the PIC I/O are 5V max and the sensor works with 24V. I am quite new with electronic designs and I don't know what could be the best idea to do that, an optoisolated connection, some resistors to divide the voltage.
In addition to this the environment where the system would be installed is very noisy, there are some motors and the distance to connect the sensors and the PIC could be quite large (up to 20m).
Please advise with any idea because I am quite loose with this.
Thanks a lot in advance.
Eduardo
Paolino



Joined: 19 Jan 2004
Posts: 42

View user's profile Send private message

PostPosted: Thu Dec 01, 2005 4:04 am     Reply with quote

This item has been discussed here http://www.ccsinfo.com/forum/viewtopic.php?t=19999&highlight=
Maybe it can be useful also for you. Take a look.
Best wishes.

Paolo.
Ttelmah
Guest







PostPosted: Thu Dec 01, 2005 5:00 am     Reply with quote

First comment. Attenuate the signals (for whatever interface you use), close to the PIC. This way, noise is attenuated at the same time.
Second comment. Opto-isolation, is a seperate matter. It's advantage (and _need_), is if the supply feeding the sensors, is not the same supply to that feeding the PIC, it allows the two units to 'not care' what voltage difference exists between the ground lines on the systems.
Third comment. There may well be regulations _requiring_ isolation. I this is an industrial instalation especially, this may well be the case.
Now some more general comments:
The 'nature' of the noise sources may well change what is the best solution.
Are you sure the outputs pull 'up' as well as 'down'. Many sensors or this sort, have 'open collector' outputs, and require a resistive 'pull up' to provide 24v. What current can the outputs drive?.
In many cases, for this type of connection, 'fail safe' connections will be needed, where the computer can tell if the connection is broken, or the connections 'default' to the state resulting in systems being disabled. This may increase the complexity of what has to be built.
Now, if the outputs genuinely do pull up to 24v, and can source 20mA, consider adding an IC, like the LM317, wired as a constant current source, to deliver this current (the connections would be, feed the 'signal' into the 'input' connection, have a 62R resistor between the 'out', and the 'adj' pin, and feed the connection from the adj pin to your wires (yes you take the current from the 'adj' pin - seems odd, but this is how to build this!). Have the ground connection, and this signal fed through your wires.
Then at the PIC, have a 220R resistor, and feed the ground connection to the bottom of this, and the 'signal' to the top. Add your own signal 'trap' at this point (I'd suggest a MOV, at the very least).
Now the LM317, will generate a current of 20.1mA, when the signal goes high. Across the 220R resistor, this will give a voltage of 4.44v, a nice detectable level, and this will stay the same if the resistance of the wiring changes (this is why such 'current loops', are commonly used for signalling).
Now this is a very crude solution, but ought to be fairly reliable. However you need to consider the other points I raised, before going this way...

Best Wishes
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu Dec 01, 2005 9:23 am     Reply with quote

You might want to consider a sensor (proximity sensor) that uses a transistor output. The sensor runs on 24V but the transistor simply pulls the output to ground. This would enable you to connect the output directly to an input pin and have a pullup resistor tied to 5V. When the output goes inactive the signal will simply be pulled high by the resistor. Automation Direct (automationdirect.com) has several prox. switches that might work for you.

Ronald
Ed_Banses



Joined: 15 Sep 2005
Posts: 15

View user's profile Send private message

PostPosted: Thu Dec 01, 2005 10:07 am     Reply with quote

Thanks a lot for your responses!!!
There are very good ideas.
The sensor I am evaluating now is pepperl flutch NBN2-8GM50-E2
http://www.pepperl-fuchs.com/selector/gui/show_product_detail.kly?selected_prod_id=25499&lang=ENG
I have some questions:
1.- My plan is use the same power for the PIC and the sensor (just using a power regulator for the PIC), so shall I need a opto-isolator in a my application? Because the GND would be the same for PIC and sensor.
2.- Ronald, is the sensor I selected one with transistor output? Can you make me a little draw about the conection with the PIC?
Thanks a lot again.
Eduardo
Ttelmah
Guest







PostPosted: Thu Dec 01, 2005 11:11 am     Reply with quote

For me, that link fails. However a search on the part number gets to the product. The 'key' in in their device 'selector' page, where you can specify the output 'type'. The one you are looking at is a 'three wire' interface, which means the signal pulls both ways. If instead you chose 'NPN' for the product output, this is the 'open collector' output, that I talked about, and is being referred to by Ronald Nielsen. With this, you can use 5v signalling directly, rather than having to convert. Seriously though, the current looped interface, will be more reliable, and even better if you isolate the supplies. Personally, I'd consider running the PIC and it's circuitry off a small 24v to 5v isolated inverter module, feeding the signals as current loops, and only having one point where the 0v rails join.

Best Wishes
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Thu Dec 01, 2005 3:26 pm     Reply with quote

You can convert 0-24V digital signal to 0-5V signal with a zener or a calmping diode. Both circuit diagrams can be found in this post http://www.ccsinfo.com/forum/viewtopic.php?t=24772&highlight=zener. However, in the noisy environment I would recommend optoisolating the sensors. The additional benefit is that digital optoisolators will take care of the level translation as well.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Dec 02, 2005 8:13 am     Reply with quote

kender wrote:
You can convert 0-24V digital signal to 0-5V signal with a zener or a calmping diode..


I would recommend a voltage divider instead of a Zener clamp to make sure a logic zero stays a zero. The divider is also cheaper :-)
_________________
The search for better is endless. Instead simply find very good and get the job done.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Dec 02, 2005 11:52 am     Reply with quote

The NBN2-8GM50-E2 is a PNP output configuration. This will pull the output UP to the power supply Positive voltage (24VDC). If this is connected directly to an input it will fry the micro-controller. I had a co-worker that replaced a sensor with the wrong output configuration and did just that. He let out the magic smoke. A NBN2-8GM50-E0 is an NPN output configuration. It will pull it's output LOW to ground and allow you to connect it directly to an input. When the output turns off it will float so you'll need to make sure you have a pull-up resistor on it.

Ronald
Ed_Banses



Joined: 15 Sep 2005
Posts: 15

View user's profile Send private message

PostPosted: Mon Dec 05, 2005 7:21 am     Reply with quote

Thanks a lot for all the replies!!!
I will go to get the optoisolated inputs with current limitation, looks as the best solution!!
Thanks again.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group