Electronic – How to detect Serial or TTL signal for a PIC

picserialttl

I have a Microchip PIC with UART support. If i understand correctly, the UART is able to natively handle the TTL serial signal.

I'm expecting input signal that should be TTL (0/5V), but it could be RS232 (+/-13V).

  1. What would be the best way to handle both different signals. Anyway to auto detect the (incoming) signal?
  2. Or should i have a manual switch that allows for signal selection?

I was thinking of using a something like a MAX3232, but i'm not sure what would happen if that IC gets a TTL signal.

Thanks!

Best Answer

Simple steps as follows...

The first step is to disable the driver attached to the PIC (No point damaging the equipment with excessive voltage)

Then monitor the in coming signal from the device and detect if they are Negative Wiki RS232 Voltage wave form

Then decide which mode the PIC should use. TTL is only positive. RS232 has a good -V and +V swing around 0V. It may be a good idea to detect more than -1V just in case of noise etc.