Maker Pro
Maker Pro

Set Arduino pin to High Impedance (floating)

sirch

Dec 6, 2012
109
Joined
Dec 6, 2012
Messages
109
The circuit shown below is for a 40kHz ultrasonic rangefinder. I have put together a variation of the circuit using an Arduino and not including the I2C code/connector (the original code is in Assembly with which I am not too familiar so I am rewriting it).

The reciever section includes 4 Op Amps, the middle two of which are supposed to provide selectable gain. I am assuming that I need to toggle the resistsors from High Impedance to Low (ground) to change the gain and I can set the relevat pins to OUTPUT, LOW to ground them.

My question is how do I set the pins back to floating in on the Arduino? Would it be enough to set it to HIGH or INPUT?

cache.php
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
That's an intersting idea.

On the AVR (and in general), you set I/O pins to the high impedance state by turning OFF the corresponding bit in the DDR (data direction register) for the port.

For the AVR, you also have to ensure that the output state for the port, in the PORTn register, is 0; if it's 1, a weak pullup is enabled on the pin, which you don't want. You'll have to set the outputs to 0 anyway on these pins, because when the DDR bits are set, you want the pin to output a low state.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Setting it to high (as an output) is going to drive it to the positive rail.

Making it an input will allow it to float. Beware of internal pull-ups though. If the pin is an input, but is set to 'High' via the digitalWrite function, this will enable a 20k resistor pulling up to the positive rail. So set them to low (as well as an input) to make them truly float.
 

sirch

Dec 6, 2012
109
Joined
Dec 6, 2012
Messages
109
Hi Again, hope you don't mind me asking another question about the circuit I posted above. The output of IC2C (pin 8) goes to two diodes which I assume form a basic rectifier across the IC2A op amp inputs. The question is what does IC2A do and what should I expect the output to look like, given that the input is a 40kHz pulse?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
It looks like an overcomplicated Schmitt trigger.

I'm not sure what the diodes do that could not be achieved with selection of resistors to set the hysteresis,
 
Top