Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how to use Proximity Inductive Sensor in Pic18F4550

Status
Not open for further replies.

Ragens

Member
hi,

I already search around and i never see a example code for Proximity Inductive sensor including it circuit. If i want use it in PIC18F4550 how should i setup it? example code with description? i also try to simulate in proteus but can not find inductive sensor so i quite blank what to do.

Im beginner in MCU so not much coding i know. Type of coding only i understand a bit is Micro C Pro...

Thank
 
You can get two types of proximity sensors.. PNP or NPN... I connect them via a suitable transistor to clean the switching... Also they always need 9 volts + to run so the transistor acts as a level converter as well.

Once this is understood I use a switch in ISIS to simulate them..... If you need a series of pulses then you can use the pattern generator to simulate a variable input....

Here is how I read a NPN sensor

prox wiring.PNG
 
Last edited:
how u can get that sensor in proteus? all i found is temperature sensor... i want to simulate in proteus to check code can work or not and check it voltage( i want run 3 of them via USB by using voltage pump)... any example coding for them? i can't find in library of MikroC Pro For PIC software and google...
 
I didn't say I used the sensor in ISIS...
Once this is understood I use a switch in ISIS to simulate them.....

As the input will be on or off you only need a switch to mimic them....
 
there are proxy sensors with analog output but...
things that have analog output are not called "switch".
 
Right!!! I misunderstood...... You are talking about a distance sensor.... A proximity sensor is just a switch.. It detects the presence of metal objects.

A distance sensor detects the "proximity" of other objects.... These output an analogue output relative to a close by object...
 
Analog sensors typically have an output which is 4-20mA, 0-20mA, 0-10V, 0-5V etc.
You should be able to simulate such an output in Proteus using standard models of current source or voltage source.
 
this proximity sensor detect metal object with max range 4mm and vol min 10 max 30... i do not know where to start...
 
this proximity sensor detect metal object with max range 4mm and vol min 10 max 30... i do not know where to start...

Can you show me a link!!! The 4mm proximity switches I use are on/off types
 
those are also on/off type (which is most common)....
 
hi im working on a project wher i need to use a proximity sensor and i wonderd if there are any difference in using a pnp and npn when it comes to the circuit and what type of transistor is the best to use for a 12 volt setup ?? i guess a TIP41C could be used ...
 
PNP and NPN are just types of output (otherwise sensors are the same), which is the final switching element. they both can be NO (normally open) and NC (normally closed). products with NPN output are common in Japan, PNP in the rest of the world. NPN is simpler to interface to MCU because you just need pullup resistor to Vcc (5V or 3.3V for example). if you don't care about isolation, this shows one possible way to connect the two. i added wire colors. they are standard regardless if the sensor are pre-wired or have quick disconnects.

the connections are exactly the same for 12V if sensors can operate at reduced voltage (many do).
edit:
sometimes sensors also have fourth wire (white). this can have different functions but most common one is another output (perhaps NC, analog etc.)
 

Attachments

  • pnp-npn.png
    pnp-npn.png
    10.5 KB · Views: 3,536
Last edited:
PNP and NPN are just types of output (otherwise sensors are the same), which is the final switching element. they both can be NO (normally open) and NC (normally closed). products with NPN output are common in Japan, PNP in the rest of the world. NPN is simpler to interface to MCU because you just need pullup resistor to Vcc (5V or 3.3V for example). if you don't care about isolation, this shows one possible way to connect the two. i added wire colors. they are standard regardless if the sensor are pre-wired or have quick disconnects.

the connections are exactly the same for 12V if sensors can operate at reduced voltage (many do).
edit:
sometimes sensors also have fourth wire (white). this can have different functions but most common one is another output (perhaps NC, analog etc.)

Hmm i though the voltage on the signal line was equal to the voltage used to operate the switch and for the once i will get it operate on voltages from 6 to 36 volts and for my use it wil be 12 to 14.8 volts
and that was the reason why i mentioned using a transistor like a tip41C to switch the signal voltage to the MCU.. anyway what is the best option using resistors or a transistor ???
 
i don't quite understand what you mean by that.

1. industrial sensors have certain ratings including operating voltage and you better stick to the specs. i don't recall proxy sensor that will operate on less than 10V.

2. you do not get signal level equal to supply voltage of the sensor. sensors like this may be called a 'switch' but unless they have relay output, you do not get output that is comparable to mechanical switch. PNP output sensors powered by 24V, have output of maybe 22V. without any load you may read that as something closer to 24V but again, without load, this is hardly usable. reason for significant drop is configuration of the output circuit - even though it is commonly referred to as "PNP" it is not an open collector PNP but rather common collector NPN (just like in UDN driver arrays). one of the reasons is that this configuration offers some protection.

3. things mentioned in 1 and 2 are about sensors (they are used as inputs to MCU). when you mention TIP41C, i guess you want to use it with an output of a MCU (please clarify). in that case you need to identify few things like load current, transistor, gain, voltage level of MCU output, current rating of MCU output etc. in practice it is common to assume that gain is 10 so that transistor is in saturation when on. in simplest case one would compute base resistor using Ohms Law:

R = V/I

where
R is resistor value in Ohms
I is resistor current (not more than max current MCU output can handle)
V is voltage drop across resistor. it can be computed as difference between MCU output level and Vbe of a transistor.

for example some arbitrary MCU is powered by 5V, outputs are at 4.5V when high while driving max output current od 20mA.
assuming your transistor has Vbe = 0.7V then smallest resistor value is

R>= (4.5-0.7)/0.02 = 3.8V/0.02A=190 Ohm.

since we assumed gain of 10, this will work fine with load that draw I=20mA*10 = 200mA

driving 'PNP' output stage with supply voltage such as 6-36V you need level shifter. in simplest form that would be two transistors and two resistors. basically it is just cascade of what we just used, the only difference is is that second transistor is PNP (which also adds to gain of output stage) and it connects to output power rail (6-36V in this case).


either way, finding the best depends on what you want to do with it. if you need more help, you need to be specific.
 
Sorry looks like i did missunderstood something about the sensors and how they work and as i had a closer look at the drawing you provided i think i got it .. anyway i'm going to use a 12 volt source and i guess bot the 12 and 5 volt (the signal voltage ) need to share the same ground connection .. correct me if i'm wrong ...
 
that is the simplest slution - have both sources share common. if you want isolation you can use additional optocoupler and resistor.
 
that is the simplest slution - have both sources share common. if you want isolation you can use additional optocoupler and resistor.
Then i got it right :) any sugesstion on what optocoupler to choose for the type of application i'm working on ?? I have done some googling and have found a few but most of em looks to be used for switching Triacs ...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top