cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to build a network of microcontrollers usign USART 1-Wire communication?

Luis Ber
Associate II

Hello,

I need to build a simple communication network to send a small information bytes between a Master and three different Slaves. In the following way:

0693W000001qtUsQAI.jpg

I have thought that maybe 1-wire communication will be a good choice for this type of transmission and network.

Is it possible to perform this communication using USART 1-Wire communication of the stm32?. I have seen that this option is possible using CubeMX. I'm using STM32F746ZET6 as Slaves microcontrollers and STM32F1 as a Master microcontroller.

Do you see some kind of problem with this configuration? Any comment, suggest or opinion will be very appreciated.

Thank you.

Luis

3 REPLIES 3
Jack Peacock_2
Senior III

Assuming you mean the Maxim/Dallas 1-wire serial interface then yes it is possible to do what you describe, although there are simpler solutions. I assume you are not actually powering the remote nodes since an STM32F7 requires too much power for a 1-wire power source.

You will need to configure the USART in half-duplex mode. RX has to be disabled during transmits or you get a loopback. TX will require an open collector buffer, since open drain mode is often not supported on STM32 USARTs (see errata sheets). The RXD pin can be tied to the output of the TX buffer but you might have to deal with inverted polarity if the TX buffer is an inverted (7406 type driver). You will need pull-up resistors at each end of your cable to provide some kind of termination.

You might consider using half-duplex RS-485 instead. Speeds are far higher (up to 1Mbaud), greater distance, less bus loading (16 to 64 nodes) and vastly improved signal integrity with a differential wire pair vs. open collector. There's a reason you don't see a 1-wires type of interface used for networking.

Jack Peacock

berendi
Principal

You don't want 1-Wire.

While a 1-Wire master is possible to implement on a UART (but CubeMX/HAL would rather get in the way), the slave side would present some difficulties. I don't think it's supported by CubeMX, where did you see it? It is not meant for MCU-to-MCU communication, there are more straightforward ways to do it.

You want LIN instead, or at least something resembling it.

With some precautions, LIN can operate on a half-duplex serial port of each node. You would be responsible to switch the port direction. I would recommend placing some resistors in series between the nodes to protect the ports, and choosing the port speed accordingly. CubeMX apparently does not support this mode either. If the nature of the connection between the nodes does not reasonably allow direct connection, you can use cheap dedicated LIN transceivers.

Piranha
Chief II

I guess "1-Wire" here is not as 1-Wire specific protocol, but just a single line communication. If that's the case, then I'm not sure if it's the best solution, but it definitely can be done even with half-duplex UART. There is a similar solution already in use in Trinamic stepper drivers. For example look at TMC2209 datasheet section 4:

https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2209_Datasheet_V105.pdf

Use STM32 UARTs in half-duplex mode with a single hardware pin. Configure master pin as push-pull with pull-up. Configure slave pins as push-pull and put a 1k series resistor for each slave. And you can take an inspiration for a protocol also from them.

I am actually successfully driving one such driver from a STM32L4 exactly this way. =)