Modbus Master Speed

For general Flowcode discussion that does not belong in the other sections.
steve001
Valued Contributor
Posts: 185
http://meble-kuchenne.info.pl
Joined: Wed Jan 13, 2021 7:15 pm
Has thanked: 81 times
Been thanked: 30 times

Re: Modbus Master Speed

Post by steve001 »

Hi Seokgi,

I am not around much next week.

you said in your original post

"HMI : Serial_3 : Modbus RTU via RS-232(1ea)(Slave)" and that it does not work on the HMI.

are you using RS232 for this ? - i have no experience using modbus over RS232, as far as i have seen they are either RS484, LON or TCP/IP


I am trying to go down the route of proving if its your project, or the modbus interface. (have seen this countless times )

My next port of call, would be

Check slave 6 & 7 together and see if you can get communication's

Are you reading lots of registers on slave 6 ?
It could be the system is timing out before all the information is processed and sent.
Then in turn processed by the master In this case try and increase the time delay on a time out.

viktor_au wrote:
Sat Sep 02, 2023 12:34 am

I would like to use the Modbus but my knowledge is not good enough. That is the reason
to learn as much as possible.

the wiki is a good resource

https://www.flowcode.co.uk/wikiv9/index ... s:_System)
Steve

seokgi
Posts: 192
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 5 times
Been thanked: 7 times

Re: Modbus Master Speed

Post by seokgi »

This is read from my PIC MCU.
Modbus Poll using reads for testing.
The 7th device is read well by adjusting the delay time in Modbus Poll.

MCU Serial _ 3 : connect Device #6 ~ #12 (Digital Input(40001) 4 ea, Digital Output(40001) 2 ea, Analog Input(40001, 40002) 1 ea)(RS-485)
Modbus Address : DI 40001, DO 40001, AI 40001, 40002, Only 1 or 2 address per Device
MCU Serial _ 4 : Connect to HMI via RS-232
MCU Serial _ 1 : Connect Device #1 ~ #5 Using 40001 address via RS-485

And I tried changing the terminal resistance, but it didn't work.

Thank you.

seokgi
Posts: 192
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 5 times
Been thanked: 7 times

Re: Modbus Master Speed

Post by seokgi »

Hello?
I think I'm halfway through this. The reason is somewhat strange, but it works faster and more accurately than before.

This was solved by repeating the initialization operation.

I describe my program here for reference for others.

I set up the Modbus master as shown in the picture.
Init.jpg
Init.jpg (117.98 KiB) Viewed 4417 times
Then, the component module was initialized, and a timer interrupt was used to generate an interrupt of about 1 second and call the Modbus master subroutine.
Interrupt.jpg
Interrupt.jpg (87.07 KiB) Viewed 4417 times
If the call time is too fast, the system seems to freeze.



And it seems to work only if it is initialized in the called routine. If I do not initialize it, sometimes it seems to operate normally,
but previous data is loaded.
Routine.jpg
Routine.jpg (132.84 KiB) Viewed 4417 times

seokgi
Posts: 192
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 5 times
Been thanked: 7 times

Re: Modbus Master Speed

Post by seokgi »

I tried many things. However, MCU speed is still poor and sometimes unreadable.
Perhaps timing is the issue.

Still no way. I'm looking for another way.

Please Help me.

Thank you.

seokgi
Posts: 192
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 5 times
Been thanked: 7 times

Re: Modbus Master Speed

Post by seokgi »

Can you please advise how to speed up the MCU? It's so hard. Modbus Master still operates too slowly.

Thank you

seokgi
Posts: 192
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 5 times
Been thanked: 7 times

Re: Modbus Master Speed

Post by seokgi »

I cannot edit components.
Please help me how to fix the component and I will fix it.
Is there no way?

Please help me.
Thank you.

BenR
Matrix Staff
Posts: 1895
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 491 times
Been thanked: 664 times

Re: Modbus Master Speed

Post by BenR »

Hello,

It's tricky for me to comment as there's a lot going on in your program. There are two modbus masters, a modbus slave, GPS and a UART all taking part of the runtime.

What might be handy is to try and find out what is taking up the majority of the runtime. So you start a high speed timer running and increment a counter. You look at the counter when uyou start a macro and then again when you end a macro and this will tell you how many interrupt ticks you spent in that function. With some trial and error you should be able to trace what is taking up the majority of the time.

In the ModBusMaster_Local_3 macro you have seperate read functions for holding registers 8, 9, 10, 11 and 14. Then two seperate write functions for 12 and 13. The reads and writes could all be done in single functions to speed things up significantly. I've attached an updated version of your file with this function improved.
230901_Freezer-MCU-Serial.fcfx
(52.9 KiB) Downloaded 175 times

The macro ModbusSlave_HMI_4 could undergo a similar optimisation to cut down the number of transactions required from 8 to 2.

viktor_au
Posts: 23
Joined: Wed Jul 12, 2023 7:09 am
Has thanked: 5 times
Been thanked: 5 times

Re: Modbus Master Speed

Post by viktor_au »

Hi seokgi
As I understand the HMI (monitor?) waits for the external Modbus Master request and after this request arrives and if the Slave b_HMI_Incoming (ack=OK) ,Slave sets 6 registers, etc.
Is the main problem here in the communication between the MCU: 24FJ512GB610 (as Modbus Master) and HMI monitor (as Modbus Slave)?
Can I ask a question about this HMI monitor?
What kind is it?
What brand?

seokgi
Posts: 192
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 5 times
Been thanked: 7 times

Re: Modbus Master Speed

Post by seokgi »

Thanks for your reply.
However, each address of ModBusMaster_Local_3 you modified must have a different Slave ID.

HMI (Touch Screen) operates in Modbus Master Mode.

https://www.cimon.com/introduction/hmi
Brend Name : Cimon. XPanel 15 Inch Touch Screen.

Thank You.

LeighM
Valued Contributor
Posts: 411
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 76 times
Been thanked: 226 times

Re: Modbus Master Speed

Post by LeighM »

Just to add to what Ben said. Another generic debug trick is to wrap sections of code, or functions, in a LED on, LED off. If you have some spare outputs. Then monitor with a scope, or even an LED, the brightest will be where your program is spending most time.

Post Reply