Connect with us

Set Arduino pin to High Impedance (floating)

Discussion in 'Microcontrollers, Programming and IoT' started by sirch, Jan 28, 2013.

Scroll to continue with content
  1. sirch

    sirch

    109
    1
    Dec 6, 2012
    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?

    [​IMG]
     
  2. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    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.
     
  3. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,419
    2,790
    Jan 21, 2010
    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.
     
  4. sirch

    sirch

    109
    1
    Dec 6, 2012
    Thanks for the help guys, input, low it is
     
  5. sirch

    sirch

    109
    1
    Dec 6, 2012
    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?
     
  6. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,419
    2,790
    Jan 21, 2010
    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,
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-