Maker Pro
Maker Pro

Set Arduino pin to High Impedance (floating)

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
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
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.
 
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
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