# Is it possible to toggle a pin between “ground” and “not connected”?

I am trying to control a pump (ismatec ecoline V380) from a microcontroller (xmc4300, infineon) using an analog interface.

The pump takes several inputs, most importantly: the speed (from a current loop, 4-20mA.) But also, using another pin, you can determine the pump direction. According to the instructions of the pump, if this pin is in an "open position", the pump operates clockwise, whereas when conneted to ground, it pumps counter-clockwise.

Now my question is, if there is a possibility to implement this direction control using a digital output pin of my microcontroller?

I tried to toggle the output to high and low, but the pump only pumps in one direction. Therefore, the "high" state is not similar to "open," is it?

• Something that provides the possibility of a high impedance output will be useful. Sometimes called tristate. – uglyoldbob Apr 17 at 12:23
• Check what voltage the pump puts to the control pin! If the µC would output a 'high' at the same voltage that the pump puts the pin to, there would be no difference between open-circuit and logic 'high'. Apparently, the 'high' voltage of the µC's output is seen by the pump as a 'low' voltage which strongly indicates that the pump puts out (significantly) higher voltage (5V? 12V? something else?) than the µC and shouldn't be directly connected to the µC. Use a transistor (bipolar npn or N-channel MOSFET). – JimmyB Apr 17 at 14:50

According to the data sheet for the xmc4300 the io pin is tri-stated when set to input. So you could output a zero to this pin and toggle between input (tri-state) and output (low).

However. You may wreck the micro if you do so. When you tri-state the pin (toggle to input) the voltage on the pin will rise up to whatever the pump control pin pulls it up to. This could be 12V for example. Your micro's input pin would see 12V and surely fry.

You should use an npn transistor to pull low/tri-state the pump's control pin. And ensure that the transistor has a higher voltage rating than whatever the pump pulls the pin up to.

simulate this circuit – Schematic created using CircuitLab

Yes. What you need to look for is an open-collector or open-drain output. This kind of output pin can only pull the output low, it cannot drive the output high. These kinds of pins are used for I$$\^2\$$C communication interfaces, for example. Some microcontrollers will allow you to configure a generic I/O pin as having an open-collector characteristic.

If you can't find a microcontroller with such a pin, you can add an NPN or NMOS transistor with emitter/source tied to ground. Use the collector/drain as the output.

With a little more work, as uglyoldbob suggested, you can simply change the direction of a normal I/O pin from output to input when you want it to be "disconnected".