Modbus master component Time out response

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

tello
Posts: 90
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 13 times
Contact:

Modbus master component Time out response

Postby tello » Wed Apr 27, 2016 12:49 pm

Good morning guys again.
I implemented the modbus component in my project.
I have a Modbus slave emulator for testing. the emulator receives the query and responds but the teacher always gets time out.
Someone has made some example to understand my mistake?

Thank you
Attachments
captura envio modbus.jpg
(89.78 KiB) Downloaded 2612 times

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: Modbus master component Time out response

Postby Benj » Wed Apr 27, 2016 3:45 pm

Hello,

Please can you attach the Flowcode file and we will investigate for you.
These users thanked the author Benj for the post:
tello (Thu Apr 28, 2016 7:57 am)
Rating: 5%
 

EtsDriver
Valued Contributor
Valued Contributor
Posts: 437
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 348 times
Been thanked: 228 times
Contact:

Re: Modbus master component Time out response

Postby EtsDriver » Wed Apr 27, 2016 5:56 pm

Hi!
Hard to say, but if this is your main loop: seems like youre missing the modbus master initialize function.
These users thanked the author EtsDriver for the post (total 2):
Benj (Wed Apr 27, 2016 5:59 pm) • tello (Thu Apr 28, 2016 7:57 am)
Rating: 10%
 
Ill just keep the good work up!

tello
Posts: 90
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 13 times
Contact:

Re: Modbus master component Time out response

Postby tello » Thu Apr 28, 2016 12:34 pm

Hi guys.
Attached the program modbus master file.
In the Main routine, I Initialize including Modbus Master.
I found out a curious thing, when sending only a register (PresetSingleRegister) responds sending me the same thing.
When I'm sending four registers (PresetMultipleRegisters) responds with an error "03 = Illegal Data Value. A value Contained in the query data field is not an
allowable value for server (or slave). This
Indicates a fault in the structure of the remainder
of a complex request, the implied Such As That
length is incorrect. It does NOT mean Specifically
That a data item in a storage Submitted for register
has a value outside the expectation of the
application program, since the MODBUS protocol
is unaware of the significance of any individual
value of any special register ".

Why does this happen?? are the same records with the same structure.

I have also the problem that the pic does not recognize the slave response and delivery time out error.

Benj take the opportunity to ask, when we have the new component Modbus Slave ??

Thank you so much
Attachments
modbus_PRESETSINGLEREGISTER.jpg
(219.86 KiB) Downloaded 2587 times
modbus_presetmultipleregister.jpg
(298.18 KiB) Downloaded 2587 times
MB_Master_18F23K22_R0.fcfx
(32.89 KiB) Downloaded 161 times
These users thanked the author tello for the post:
EtsDriver (Fri Apr 29, 2016 8:29 pm)
Rating: 5%
 

EtsDriver
Valued Contributor
Valued Contributor
Posts: 437
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 348 times
Been thanked: 228 times
Contact:

Re: Modbus master component Time out response

Postby EtsDriver » Thu Apr 28, 2016 8:51 pm

Changed your flowchart to modbus ascii and captured message:
First sending the "ARRAY[0]" and then the whole array... (Putty output on the right-->)
fc6_mb_Ascii.JPG
(50.1 KiB) Downloaded 2571 times


Compared to MBpoll the Flowcode seems to send it differently? Heres mbpoll sending only one:
mbp1.JPG
mbp1.JPG (73.04 KiB) Viewed 8975 times

Here im sending using mbpoll software the value 65535 over my "loopback" com adapters, to see what ASCII comes out. Settings are Modbus ASCII over serial, ID 1, function 16 - write multiple registers, start address 1, quantity 4.

And here we send multiple:
mbpoll multiregisters.JPG
mbpoll multiregisters.JPG (68.2 KiB) Viewed 8975 times


Any ideas/traces to the problem here Matrix team?

I tried deconstructing the messages the MB master component sends...

Code: Select all

:01 10 0001 0004 PP PPPP PPPP PPPP PPP2
01 SLAVEID
10 PRESET MULTIREGISTER (FC16)
0001 START ADDRESS
0004 REGISTERS TO WRITE
PP NUMBER OF DATABYTES TO FOLLOW

PPPP VALUE FOR 0X0001
PPPP VALUE FOR 0X0002
PPPP VALUE FOR 0X0003
PPP2 VALUE FOR 0X0004
     CRC MISSING
   
:01 06 0001 PPPP PK

01 SLAVEID
06 PRESET SINGLE REGISTER (FC6)
0001 DATA ADDRESS OF THE REGISTER (+40001 OFFSET), WILL WRITE REGISTER 40002
PPPP THE VALUE TO WRITE
PK CRC VALUE


It might be that the FC16 is just missing the number of data bytes to follow, and thats why the slave is not answering anything (as the message is "seemingly" missing CRC/or is too short)?

helpful page to understand modbus bit easier :)
These users thanked the author EtsDriver for the post (total 2):
tello (Fri Apr 29, 2016 8:20 am) • Rudi (Tue May 03, 2016 12:00 am)
Rating: 10%
 
Ill just keep the good work up!

tello
Posts: 90
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 13 times
Contact:

Re: Modbus master component Time out response

Postby tello » Fri Apr 29, 2016 9:32 am

Thank you.
I understand the plot of sending Flowcode FC16 and you are right, not the data "number of records" I think it's a component failure.
In this case it must be repaired to be used.

I do not understand because I have TimeOut failure in PresetSingleRegister when this frame is correct.

Thanks once again
Attachments
FC16 Modbus.jpg
FC16 Modbus.jpg (193.77 KiB) Viewed 8959 times
These users thanked the author tello for the post (total 2):
EtsDriver (Fri Apr 29, 2016 8:27 pm) • Rudi (Tue May 03, 2016 12:00 am)
Rating: 10%
 

tello
Posts: 90
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 13 times
Contact:

Re: Modbus master component Time out response

Postby tello » Tue May 03, 2016 9:34 am

Good morning Benj
I wonder if it is possible to repair the component block Modbus master "Presetmultipleregisters" is very important for my project.
Not because I find fault with it modbus Timeout response.

Thank you

tello
Posts: 90
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 13 times
Contact:

Re: Modbus master component Time out response

Postby tello » Wed May 04, 2016 9:37 am

Hi guys.
I still have the problem of fault block time out modbus master, someone knows where you can set the time of failure time out ??
Thank you

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: Modbus master component Time out response

Postby Benj » Wed May 04, 2016 11:31 am

Hello,

You are right it seems the byte count was missing from the PresetMultipleRegisters command.

The attached component should hopefully fix this. Simply drop the component into your "Flowcode 6/Components" directory before starting Flowcode for the changes to be loaded.

Modbus.fcpx
(16.61 KiB) Downloaded 164 times


The Modbus slave component does need finishing, I just need some time to have a good run at it, hopefully soon.
These users thanked the author Benj for the post:
tello (Wed May 04, 2016 12:05 pm)
Rating: 5%
 

tello
Posts: 90
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 13 times
Contact:

Re: Modbus master component Time out response

Postby tello » Wed May 04, 2016 2:11 pm

Hi Benj.
thank you very very much.
Well now send data to Modbus slave and the slave responds ok.
there is one thing I do not understand. When the master sends the data block and the slave responds, the block is stopped for 2,474s, what is the reason ??
With this pause my program is very very slow.
when it receives the response from the slave should immediately move to the next block, if no response is received then you must wait for the time out.

You know it makes that pause ??

Thanks
Attachments
MODBUS CAPTURA.jpg
(183.99 KiB) Downloaded 2485 times
These users thanked the author tello for the post:
Rudi (Thu May 05, 2016 8:15 pm)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: Modbus master component Time out response

Postby Benj » Wed May 04, 2016 5:08 pm

Hello,

It looks like the receive may be waiting even after the reply is received for some reason. I've re-structured the receive code to try and get the code to return as soon as there is a time out and also dropped the reply time out from 250ms to 120ms.

Modbus.fcpx
(16.63 KiB) Downloaded 141 times


Let me know how your getting on.
These users thanked the author Benj for the post (total 2):
Rudi (Thu May 05, 2016 8:12 pm) • tello (Fri May 06, 2016 1:49 pm)
Rating: 10%
 

tello
Posts: 90
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 13 times
Contact:

Re: Modbus master component Time out response

Postby tello » Fri May 06, 2016 2:01 pm

hi Benj.
The new component is much faster than the previous but still have a very large pause 1,14sec after receiving the response from the slave.
You can add a variable to adjust the timeout or time out after receiving the answer ??
My big problem is that the micro does two UART communications and also checks and evaluates the data, if a pause or a delay occurs, the micro does not work on your other tasks and are very important.

Deputy capture the graph of time.

Thanks again for your time, I feel very proud to have flowcode, there are a great team in your work.

thanks, thanks and a thousand thanks
Attachments
captura recepcion modbus.jpg
(84.52 KiB) Downloaded 2432 times

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: Modbus master component Time out response

Postby Benj » Mon May 09, 2016 1:02 pm

Hello,

Any chance I can see your program?

The component should return immediately after the reply so I am wondering if you are maybe calling the GetResponse macro again after the PresetMultipleRegisters command. I've looked in the program above and you don't seem to be doing this.

Of course it could be something wrong in my time out logic so I will go back through and see if I can spot anything further for you.
These users thanked the author Benj for the post:
tello (Mon May 09, 2016 3:35 pm)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: Modbus master component Time out response

Postby Benj » Mon May 09, 2016 1:16 pm

This component now has a new property named Receive Timeout. You should be able to adjust this until the delay has been eliminated.

Modbus.fcpx
(16.7 KiB) Downloaded 165 times


Still not sure why we are not jumping out of the routine at the right time.
These users thanked the author Benj for the post:
tello (Mon May 09, 2016 3:35 pm)
Rating: 5%