cancel
Showing results for 
Search instead for 
Did you mean: 

HW design

NASI
Senior

Hello, 

I have to design a circuit and I need help. 

There are two external devices, which the third device with MCU STM32F105 has to find out which of them is connected to it. 

Two external devices have signals:

- 24v or non-connected 

- Ground

I can maybe use a voltage divider, but the issue is "non-connected" signal.

Anyone can help me?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

If I understand correctly, the external devices each have two connections/wires. One is connected to GND, the other is either open or connected to 24V - right?

If that's the case, your only chance is to check the connection to GND of the external devices. So that we don't get confused here, we rename signal GND to the first external device at the connector to GNDext1.

You disconnect GNDext1 from the GND of the STM32 board at the connector.

Then you connect GNDext1:

  • via a pull-up to VDD of the STM32,
  • to the drain of a small n-channel logic-level MOSFET and
  • to one of the ADC inputs of the STM32.

The source of the MOSFET then needs to be connected to GND of the STM32 board and the gate is controlled by a GPIO the STM32.

By disabling the MOSFET (gate = low) and measuring the ADC voltage, there are then two possibilities:

  • ADC input ~ 0: device is connected
  • ADC input ~ VDD: device disconnected

For the normal state, simply switch the MOSFET back on.

Of course you have to do the same with the 2nd channel, i.e. GNDext2.

Does it answer your question?

Good luck!

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6
Peter BENSCH
ST Employee

If I understand correctly, the external devices each have two connections/wires. One is connected to GND, the other is either open or connected to 24V - right?

If that's the case, your only chance is to check the connection to GND of the external devices. So that we don't get confused here, we rename signal GND to the first external device at the connector to GNDext1.

You disconnect GNDext1 from the GND of the STM32 board at the connector.

Then you connect GNDext1:

  • via a pull-up to VDD of the STM32,
  • to the drain of a small n-channel logic-level MOSFET and
  • to one of the ADC inputs of the STM32.

The source of the MOSFET then needs to be connected to GND of the STM32 board and the gate is controlled by a GPIO the STM32.

By disabling the MOSFET (gate = low) and measuring the ADC voltage, there are then two possibilities:

  • ADC input ~ 0: device is connected
  • ADC input ~ VDD: device disconnected

For the normal state, simply switch the MOSFET back on.

Of course you have to do the same with the 2nd channel, i.e. GNDext2.

Does it answer your question?

Good luck!

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
NASI
Senior

Thank you @Peter BENSCH​ 

Thank you for your answer. Please correct me if I didn't understand you answer.

Is it the circuit you suggest?

0693W00000JPrr9QAD.png 

Lets assume that there is one device (Device1) and the device (STM32) has to find out which signal is connected to it.

0693W00000JPrCaQAL.pngWould you please look at the follow circuit and let me know if it will work.

0693W00000JPrOMQA1.pngThank you.

Picture 1 is what I described, based on your first description.

In picture 2 you have tried to clarify your constellation a little, but it is still not clear.

Is the GPIO part of Device 1 or part of an independent device?

Do you want the GPIO to detect:

  • the presence of 24V or
  • the presence of GND or
  • neither 24V nor GND?

Picture 3 definitely does not work:

  • the 24V is at the LED of the optocoupler without current limitation, which will destroy it
  • the PMOS is always disabled

Please make a drawing where the possible cases are clearly visible.

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
NASI
Senior

Picture 3 is wrong, my fault.

The GPIO is part of Device 1.

I want the GPIO to detect:

  • the presence of 24v and disconnected signal (these two signals have to be detect similarly, High or Low) and
  • the present of GND

Please see if this picture makes sense.

0693W00000JPsWbQAL.png 

Peter BENSCH
ST Employee

You can determine this with two measurements:

  1. If GND is identical for both sides, you can check the presence of the connection to GNDext with a GPIO as described above.
  2. You can measure the 24V via a voltage divider. If no 24V are connected, you will measure (almost) zero volts.

For both measurements you need either two ADC inputs or an external analogue multiplexer.

Good luck!

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
NASI
Senior

Thank you @Peter BENSCH​