Skip to main content
Associate
July 23, 2024
Solved

Must I use a MCU supporting Modbus?

We are planning to make a board using a STM32 MCU in a Modbus application. What we need is a Modbus-RTU. We found that STM32F030 can satisfy our needs and cheap enough but it does not support Modbus. Could we use STM32F030 in this case by special software additional design or we should find another MCU supporting Modbus? If we could use it then we need support about the additional software design. Would you please support us?

Thank you!

This topic has been closed for replies.
jlagBest answer
Associate III
July 24, 2024

MCU support on the micro sounds like a 'nice to have’. I have implemented Modbus RTU on countless microprocessors (that have a UART of course). If the MCU doesn’t support a settable RX timeout ISR you can implement one with a hardware timer. Receive one char at a time and wait to see if there is a timeout before the next. Getting the timing for the timeout correct is a little tricky (based on baud rate) but it is all in the specification. The baud rates are magnitudes higher now then when Modbus was first implemented, so the criticality of the timeout framing has been less of a factor for us.

10 replies

Andrew Neil
Super User
July 23, 2024

At the physical layer, Modbus-RTU is just a UART link - isn't it?

https://www.rtautomation.com/technologies/modbus-rtu/

https://en.wikipedia.org/wiki/Modbus#Modbus_RTU

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Associate
July 24, 2024

Thank you for answering my question!

We know that Modbus-RTU is a UART link, but we found that some MCUs(For example:STM32L031K6) supporting Modbus have 2 register-bits for the Modbus mode. They are RTOEN and RTOIE. Refer to the Reference Manual, these 2 bits need to be set to activate. But we couldn't find the same register-bit in STM32F030's document.

Can we achieve the function by software without the register-bit? Are there some knowhow documents about this issue?

Thank you and best regards!

Senior III
July 23, 2024

32F030 has less RAM, better to go with 32F103.  Anyway better to do a prototype with a standard board. Normally modbus uses rs485 interface. Do you need to add rs232 to rs485 converter. 

"If you feel a post has answered your question, please click ""Accept as Solution""."
Andrew Neil
Super User
July 23, 2024

Indeed - always best to start with a bigger chip, then optimise down if necessary/possible, than to start with a too-small chip and get stuck in a dead-end!

And definitely start on standard dev-board.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Associate
July 24, 2024

Thank you for your advice!

We will think about changing the MCU to a bigger one.

jlagBest answer
Associate III
July 24, 2024

MCU support on the micro sounds like a 'nice to have’. I have implemented Modbus RTU on countless microprocessors (that have a UART of course). If the MCU doesn’t support a settable RX timeout ISR you can implement one with a hardware timer. Receive one char at a time and wait to see if there is a timeout before the next. Getting the timing for the timeout correct is a little tricky (based on baud rate) but it is all in the specification. The baud rates are magnitudes higher now then when Modbus was first implemented, so the criticality of the timeout framing has been less of a factor for us.

Associate
July 24, 2024

Thank you for your answering!

Your answer really helped us.

We will try to implement this timeout function by software. 

Andrew Neil
Super User
July 24, 2024

@PacteraHW2018 Note that all replies are public - everyone can see everything - so there's no need to repeat stuff in multiple replies.

 


@PacteraHW2018 wrote:

We found that some MCUs(For example:STM32L031K6) supporting Modbus have 2 register-bits for the Modbus mode. They are RTOEN and RTOIE. Refer to the Reference Manual


Indeed:

AndrewNeil_0-1721812594613.png

But, as @jlag said, that's just a "nicety" - nothing that you couldn't also achieve using other standard means.

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Associate
July 24, 2024

Thank you very much for your reply.

I have got it!