2024-07-23 01:40 AM
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!
Solved! Go to Solution.
2024-07-23 06:51 PM
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.
2024-07-23 02:49 AM
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
2024-07-23 03:13 AM
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.
2024-07-23 03:17 AM
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.
2024-07-23 06:29 PM
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!
2024-07-23 06:34 PM
Thank you for your advice!
We will think about change the MCU to a larger-RAM one.
But we still have the doubt about the MCU selection.
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!
2024-07-23 06:36 PM
Thank you for your advice!
We will think about changing the MCU to a bigger one.
2024-07-23 06:51 PM
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.
2024-07-23 07:47 PM
Thank you for your answering!
Your answer really helped us.
We will try to implement this timeout function by software.
2024-07-24 02:19 AM
@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:
But, as @jlag said, that's just a "nicety" - nothing that you couldn't also achieve using other standard means.