2023-04-27 04:04 AM
I have a device made of two modules. Each module has its own ST microcontroller, family is STM32L476. They are connected together with a cable of 2-2.5 meter coated, most likely, with a silicone tube.
I need to make the two microcontrollers communicate with each other and I do not expect a frequency higher than 10kHz. UART would be the easiest choice but I am a bit confused.
Do I need to add any other physical IC interface for making the MCU communicate with each other or the MCUs already have an embedded interface and so connecting the UART/USART pins via 2 cables is enough? I imagine TX1 pin->RX1 pin and TX2 pin ->RX2 pin.
Thank you :)
2023-04-27 04:07 AM
Of course. All STM32 have UART interface and what you need is configure UART on each board. Yes, you need only 2 wires :)
2023-04-27 04:11 AM
Thank you for your reply :). So you think that just using the 2 wires, 2-3 meters long, does not affect the signal integrity?
2023-04-27 04:19 AM
It depends. See discusion about this on stackexchange:
https://electronics.stackexchange.com/questions/31949/maximum-cable-length-for-3-3v-uart-signals
2023-04-27 04:32 AM
Directly connecting the MCU IOs over a few meters is a good way to kill stuff - unless it's really in controlled lab only, but even then:
ESD, wrong cabling / connectors, ground loops, ...
So you should at least provide some protection (resistor + diode minimum), I would prefer some real IO drivers plus protection, which could be easier replaced in case of damage than the STM32.
2023-04-27 04:43 AM
Thank you for your answer. So, if I understood correctly, you would use something like RS-232 Interface IC in both boards? FYI, the 2 boards will be within 2 enclosures and "only" the cable will be exposed.
2023-04-27 05:51 AM
That would depend on the actual cable length.
If it's only for lab use and only a few meters, even some 3.3V line driver would be good enough, it doesn't need to be an RS232 IF - on the other hand, these are cheap and don't have too many pins.
Just don't connect the MCUs directly.
And "only" the cable... no connectors?
And are you sure there will be no ground loop? Think about where the power supply for each board comes from, even different mains wall socket in the same room might cause trouble, depending on what else is supplied.
2023-04-27 06:29 AM
You need 3 wires, not 2. Ground must be connected, too. Other than that - it will surely work in the lab or on your desk, but not necessarily in a noisy environment. For real world applications, use RS232 or RS485 transceivers.
2023-04-27 07:45 AM
I support the differential idea, using RS485 transceivers.
2023-04-27 07:54 AM
+1 on RS232 usage, would provide some protection on the pins/connectivity.
Many of the transceivers can support to 1 Mbps rates, depends on capacitors/specifications.
Some transceivers also can provide a signal to indicate if the cable is attached, or not, and an enable pin to save power.
+1 on Ground loops and related issues. Differential pairs might be appropriate.