Input/Output in the same port

Hello,
I start saying that I don’t have experience with microcontrollers and with Arduino. I'm working on a project to develop a new device and I'm considering buying a microcontroller on Arduino card. I would need some advice.
In my application I would need to use the same port as input and output, not at the same time. An example of application might be:

  • the port provides 5 V output for 100 microseconds;
  • waiting time of about 10 microseconds;
  • the port reads the incoming signal for another 100 (or 90) microseconds;
  • again 5 V output and so on ...
    Is it feasible, even in terms of switching rate of the port from output to input?
    What card would you recommend?

Thank you very much

Davide

A clarification, I forgot to write: the 5 V I would like to output are 5 Vac (30 to 70 kHz) and, consequently, also the read signal will be ac (same frequency)

A microcontroller outputs only DC voltages. In the case of a 5V Arduino, it is either 5V or 0V.

Some microcontrollers have a DAC (digitial to analog converter) and can output a range of positive voltages.

On most microcontrollers, any I/O pin can be switched from output to input, very rapidly.

AC voltages cannot be measured, only positive voltages.

Thank you very much for your answer.

So, to generate a 40 kHz square wave I could change from 0 V to 5 V every 12.5 microseconds; that signal would excite my system for 100 microseconds, and then I could switch the port to read the response of my device for the next 100 microseconds. The reading will be digital, I suppose. I mean, by reading fast enough I could reconstruct the response to the 40 kHz signal, but, since the response signal will be quite low (some mV) I will need a ADC before.

Am I right?

I mean, by reading fast enough I could reconstruct the response to the 40 kHz signal, but, since the response signal will be quite low (some mV) I will need a ADC before.

On the Arduino Uno, the ADC takes by default about 110 microseconds to do a conversion. Higher sample rates are possible, with loss of resolution.

On the Arduino Uno, the ADC takes by default about 110 microseconds to do a conversion. Higher sample rates are possible, with loss of resolution.

1. Default clkADC = clkSYS/128 (lcd.print(ADCSRA, 16) = 1000 0111)) = 125 kHz

2.; Normal conversion time for the ADC is 13 clkADC cycles

3. So, the conversion time stands as: 13x(1/125000) = 104 uS.

//---------------------------------------------------------------------------------

4. I would appreciate if you kindly explain with example the meaning of:Higher sample rates are possible, with loss of resolution.

Thanks in advance.

The tradeoff between sample rate and resolution is discussed in the microprocessor data sheet, ADC section.

davide_PdP:
In my application I would need to use the same port as input and output, not at the same time

I think you mean pin, not port. In a microcontroller is port is a set of pins, usually of related function,
that map to a memory address in the address-map of the processor.

Yes you can change a pin from input to output and back again however you like.

Thank you all for the answers. So, I have to pay attention to the ADC sampling rate.
I will see what I manage to do and, in case, I will come back to ask for further help