0
\$\begingroup\$

I'm trying to repair an old circuit based on the Micro-controller S87C751 interfaced with an inductive proximity sensor similar to one already posted here

NPN Sensor

The sensor is powered +24V.

I followed the circuit paths from the sensor until the input of the Micro controller and i found it wired in the following way:

enter image description here

The uC is powered +5V.

As you can notice, the circuit designer used a PNP transistor combined with an NPN transistor.

My questions are:

1/ What is the purpose of this transistors combination ?

2/ Is it a level shifter ? if yes, is it really necessary ? As i already seen Arduino interfaced with such sensors with only a pull-up resistor not matter power source of the sensor.

3/ During simulation in Proteus ISIS, i simulated the inductive proximity sensor as a switch. the circuit didn't work, and i get always 0V at the uC input, what could be wrong with my drawing?

Thank you in advance for your help.

EDIT:

  • I plan to use the following level shifter using two NPN TRs instead of an PNP-NPN TRs, is it possible ?

  • I would like to include an LED in this circuit that gets ON when there is Metal detected to save one of the pins of the uC, how can this be possible? i tried including it however a voltage drop will occurs so i'll not get the 5V output.

2 NPN level shifter

\$\endgroup\$
1
\$\begingroup\$

Is it a level shifter ?

Yes

if yes, is it really necessary ?

Yes, if the sensor output is push-pull, i.e. it drives the output high as well as low.

Microcontroller inputs generally can not tolerate inputs higher than Vcc + 0.6V, which would either be 3.9V for a 3.3 V microcontroller, or 5.6V for a 5V microcontroller. (The extra 0.6V is due to an internal diode on the input.)

Occasionally you will see 3.3V microcontrollers with "5V tolerant" inputs but that's as much margin as you will see.

If you go above the Vcc + 0.6V maximum, the pin will start to draw excessive current and eventually the microcontroller will be toast.

So a 24V input would fry your micro pretty quickly.

However based on the spec sheet linked to in the comments, it appears the output is open-collector ("NPN NO"). When the sensor is activated, the output is grounded, and if it is not activated, the output is floating and a pull-up resistor is needed to pull the input high. So the supply voltage (24v) never appears at the input.

In this case you don't need any level shifting, just a pull-up resistor to VCC on your microcontroller (+5V or 3.3V) l, NOT to the brown wire like in your drawing. Just to be safe, you should wire up the sensor and when it is activated, you should measure 0 volts between the black wire and the blue wire (ground).

\$\endgroup\$
  • \$\begingroup\$ I understand, however, you can check in this link an Arduino board input directly interfaced with an inductive proximity sensor powered with higher power than of Arduino and using only a pull-up resistor. www.youtube.com/watch?v=soJ4czkKpT4 \$\endgroup\$ – Vander_kw Sep 29 '15 at 13:29
  • \$\begingroup\$ Why using a PNP-NPN transistors ? why not using two NPN transistors ? I edited my post where can you check my new proposed level shifting based on two NPN transistors. \$\endgroup\$ – Vander_kw Sep 29 '15 at 13:43
  • \$\begingroup\$ @Vander_kw In the video, since he is using a pull-up resistor to +5, this indicates to me that the sensor output is open drain, i.e. if it is activated, the output is grounded, and if it is not activated, the output is floating and the +5 from the resistor pulls the input high. So the 9v never appears at the input. (If it wasn't open-drain, there would be no need for the pull-up resistor, and if it was there, you would have +5v on one side and +9 on the other when the sensor was not activated. \$\endgroup\$ – tcrosley Sep 29 '15 at 14:58
  • 1
    \$\begingroup\$ Both of these are open collector, as I surmised. You don't need any level shifting, just a pull-up resistor to VCC on your microcontroller (+5V or 3.3V) like in the video (NOT to the brown wire like in your drawing). Just to be safe, you should wire up the sensor and when it is activated, you should measure 0 volts between the black wire and the blue wire (ground). \$\endgroup\$ – tcrosley Sep 29 '15 at 19:46
  • 1
    \$\begingroup\$ I edited my answer to include this information. \$\endgroup\$ – tcrosley Oct 1 '15 at 22:01
1
\$\begingroup\$

During simulation in Proteus ISIS, i simulated the inductive proximity sensor as a switch. the circuit didn't work, and i get always 0V at the uC input, what could be wrong with my drawing?

I think you may be missing a resistor from Q3's collector to Vcc. Also the MCU input needs a pull-up resistor.

All other questions are contingent on your circuit being correct which it cannot be as mentioned above. However I will say this, if the contact is attached to 24V and you fed that to a micro then micro = dead.

\$\endgroup\$
  • \$\begingroup\$ I double checked the circuit, there is no resistor from Q3 to Vcc, same case for the MCU, due to their internal high impedance maybe? \$\endgroup\$ – Vander_kw Sep 29 '15 at 13:26
  • \$\begingroup\$ Maybe you have the transistor collectors and emitters reversed? \$\endgroup\$ – Andy aka Sep 29 '15 at 14:28
  • \$\begingroup\$ I tried in the two cases, no luck, however, with the proposed NPN to NPN level shifting circuit that i just posted, it is working in simulation, as the sensors are expensive, i won't take the risk for now until I'll be sure that my circuit is fine in terms of currents peaks. What do you think about it, please? \$\endgroup\$ – Vander_kw Sep 29 '15 at 17:10
  • \$\begingroup\$ Can you re-check that R8 in the first schema is actually how you show it. I suspect it goes to Vsupply and the base of Q2 goes to the emitter of Q3. \$\endgroup\$ – Andy aka Sep 29 '15 at 19:47
  • \$\begingroup\$ Same result, i don't know why but this level shifting circuit is not necessary as i tried tcrosley suggestion above by interfacing the sensor directly to the MCU with a pull-up resistor, it worked without problem. \$\endgroup\$ – Vander_kw Oct 1 '15 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.