-2
\$\begingroup\$

enter image description herehttps://www.partsim.com/embed/#102528

I made the following cirucit. Pin 1 2 and 3 are connected to microcontroller output pins. Pin 4 is where I want to measure a voltage. Only one pin (1,2,3) is high (3.3V) at a time.

My intend was to get 3 different voltages (pin 1 750mV, pin2 500mV, pin3 250mV). But of course this circuit does not work.

How could I achieve something like this?

Best Regards!

edit: I does not work because I get 0 V for Pin3 High, -250mV for Pin2 and 250mV for Pin1


Thank you all.

I did a combination of the suggestions of Eugene Sh an st2000. Took the resistor ladder with diodes to prevent current into the Pins.

\$\endgroup\$
14
  • \$\begingroup\$ Please embed your circuit into the question. \$\endgroup\$
    – Eugene Sh.
    Commented Jan 16, 2018 at 16:15
  • \$\begingroup\$ sorry the link did not work. \$\endgroup\$
    – epgrape
    Commented Jan 16, 2018 at 16:16
  • 1
    \$\begingroup\$ You can augment it with opamp similar to this :ikalogic.cluster006.ovh.net/wp-content/uploads/8bitdac_2.jpg \$\endgroup\$
    – Eugene Sh.
    Commented Jan 16, 2018 at 16:27
  • 1
    \$\begingroup\$ how can you ask for this pin 1 750mV, pin2 500mV, pin3 250mV, when you have this Only one pin (1,2,3) is high (3.3V)? .... it is not clear what you are asking. \$\endgroup\$
    – jsotola
    Commented Jan 16, 2018 at 16:42
  • 1
    \$\begingroup\$ Suggestion: Study the Resistor Ladder page on Wikipedia. \$\endgroup\$
    – Finbarr
    Commented Jan 16, 2018 at 17:04

1 Answer 1

1
\$\begingroup\$

My intend was to get 3 different voltages ... How could I achieve something like this?

Consider tying 4 resistors of known values together and measuring the voltage at that point. Connect 1 of the 4 resistors to ground. Connect the other 3 resistors each with a unique resistance to 3 different GPIO pins of the embedded processor. Most embedded processor GPIO pins are programmable as output-high, output-low & inputs. Program only 1 of the 3 different GPIO pins as an output-high. Program the other 2 as high impedance inputs. The measured voltage should reflect the voltage divider created between the pin configured as an output-high and ground through the 2 resistors which make up the divider. Repeat this pattern for the other 2 GPIO pins. The voltage should be unique for each of the 3 GPIO pins if you have chosen 3 unique resistor values for the resistors connected to the GPIO pins.

If the embedded processor is not capable of programming pins as high impedance inputs, add a diode in series with each of the 3 resistors already attached to the 3 different GPIO pins. Arrange the diode such that the Anode is closest to the GPIO pin. Now when 1 of the 3 GPIO pins is programmed to the high state that pin's diode will be forward biased and will influence the measured voltage where all the resistors converge. The other 2 GPIO pins are programmed to the low state and the connected diodes will be in reversed bias and will not allow current to flow. Therefore the other 2 GPIO pins will not influence the measured voltage where all the resistors converge. Program a different GPIO pin high while all other GPIO pins are low and epeat the voltage measurement. Do this for each GPIO pin.

\$\endgroup\$
3
  • \$\begingroup\$ @egrape: Note that any load you apply to the mid-point of a voltage divider will be seen as an additional resistor in parallel with the bottom resistor, so will affect the voltage at that point. If the top resistor is a high value, like 200K, you can only draw a tiny current from the voltage divider without making a significant change in the output voltage. \$\endgroup\$ Commented Jan 16, 2018 at 16:43
  • \$\begingroup\$ I do not have the possibility to change the Pin Direction unfortunatly. \$\endgroup\$
    – epgrape
    Commented Jan 16, 2018 at 16:51
  • \$\begingroup\$ @epgrape, you can add a diode to each digital output pin that is forward biased when the pin is high and reversed biased when the pin is low. I can add this to my answer if you wish. \$\endgroup\$
    – st2000
    Commented Jan 17, 2018 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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