Must I use a MCU supporting Modbus?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 1: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.
- Labels:
-
STM32F0 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 6: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 2: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
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 3: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 3: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.
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 6: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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 6: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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 6:36 PM
Thank you for your advice!
We will think about changing the MCU to a bigger one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 6: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-23 7:47 PM
Thank you for your answering!
Your answer really helped us.
We will try to implement this timeout function by software.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-07-24 2: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.
A complex system designed from scratch never works and cannot be patched up to make it work.
