cancel
Showing results for 
Search instead for 
Did you mean: 

Must I use a MCU supporting Modbus?

PacteraHW2018
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions
jlag
Associate III

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.

View solution in original post

10 REPLIES 10

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

 

Techn
Senior III

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".

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.

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!

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!

PacteraHW2018
Associate II

Thank you for your advice!

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

jlag
Associate III

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.

PacteraHW2018
Associate II

Thank you for your answering!

Your answer really helped us.

We will try to implement this timeout function by software. 

@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.