This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

By registering to the eWON TechForum, you agree to the HMS Privacy Policy.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

eWON TechForum is meant to answer all questions concerning the development realized with or in an eWON device, in collaboration (or not) of Talk2M service, destined to take advantage of IIOT... This targets coding (Basic, Java, HTML, ...), viewON, APIs, Flexy oriented questions.

If you need help to set up an eWON device, establish a connection from/to an eWON, Cosy 131 related matters... please refer to your eWON distributors first as he is probably the best choice to quickly troubleshoot configuration issue.

If you are not sure, post your questions into the relevant section here under and someone will guide you so you can receive the correct answer.

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write successive registers in Modbus in one Modbus exchange

if you want to specifically write 6 successive registers in Modbus, you can only do it by using BASIC scripting.
Indeed if you try to do it by simply writing values into Modbus Tags as quick as possible (through BASIC, OPCUA,...), the eWON will perform the writings one by one.

Here is an example using the BASIC functions IOSend/IORcv to trigger a modbus writing to multiple sucessive registers (here 6 registers) :

REM  ****************************************************************
REM  WriteModbusRegister     --> Modbus function 16
REM  B$             is the Slave address of the device
REM  WriteRegAddr   is the register address to Write
REM  Z$             is the DATA to write (multiple of 16bits)
REM  ****************************************************************

 B$ = "100,"
 WriteRegAddr = 19
 Z$ = SFMT 1234,10,2 //Value1 = 1234
 Z$ = Z$ + SFMT 456,10,2
 Z$ = Z$ + SFMT 65535,10,2  
 Z$ = Z$ + SFMT 65535,10,2  
 Z$ = Z$ + SFMT 65535,10,2  
 Z$ = Z$ + SFMT 65535,10,2//Value   

 debug = 1
 A$ = Chr$(16)
 a% = WriteRegAddr
 a% = a% AND 65535
 A$ = A$ + Chr$(a%/256)+Chr$(a% MOD 256)
  a% = LEN(Z$)
  A$ = A$ + Chr$(0)+Chr$(a%/2) //Quantity
  A$ = A$ + Chr$(a%) //Byte Count
 A$ = A$ + Z$
 a% = Iosend "MODBUS",B$,A$

 if (debug) then
   for i%=1 to LEN(A$)
     X$ = SFMT j%,30,0,"%X"
     print X$;" ";
   next i%
   print ""
   print B$
 b% = Iorcv a%,1
 If b%=-1 Then
   Goto Wait_IO_End_2
 B$ = Iorcv a%

 if (B$=A$(1 to 5)) then
   print "Write OK"
   print "Write Failed"
 if (debug) then
   Print Len(B$);" bytes received"
   for i%=1 to LEN(B$)
     X$ = SFMT j%,30,0,"%X"
     print X$;" ";
   next i%
   print ""
Hi Simon,

Thanks that will be useful. Can flexy read multiple registers into an array, can't find info in the manuals?


Hi Simon,

Can this be adapted to read data from a RTU slave using the serial port, then write to another slave device via the same serial port ?

Cheers M

1. I guess you mean reading multiple register by bloc ? Yes, eWON does that automatically (Default 10 registers in a bloc) and you can customize it using the advanced parameter "MaxDeltaRagX" where X must be replaced by the topic letter.
2. Yes you can do that. Just define the Tags for reading and then adapt the script (replace the 65535 by the Tag value) to write all the Tags in once in the other slave.

Is it possible to write several holding registers, followed by a coil write (in this order), in JAVA, while still using integrated ModBus IO/server for other various reads ?

Other option, I only need to ensure the holding registers are written to ModBus slave before trying to write to coil, how long
shall I wait before writing to coil, using the ModBus IO server tags ? In other words, how often the IoServer/Modbus agent process the
write requests ? Is this somehow linked to the Modbus polling frequency ?


Write operation are executed spontaneously when you update the Tag, independently of the polling cycle.
So if you do :
HoldingTag1 = 123
HoldingTag4 = 1234
CoilTag1 = 1

The write requests will then be processed in the same order.


Possibly Related Threads...
Thread Author Replies Views Last Post
  Maximum Modbus RTU Device Connected to eWon instruaravind 14 3.766 18-02-2019, 11:32 PM
Last Post: simon
  Poll multiple serial Modbus networks with a Flexy. FromTicket 14 6.267 04-02-2019, 11:31 PM
Last Post: simon
  Write into a Tag after a group of flags are stored correctly voto 0 275 18-09-2018, 03:35 PM
Last Post: voto
  Registers vs Coils Josh 5 910 11-05-2018, 08:04 PM
Last Post: simon
  Multiple Holding Registers insyncs 2 797 29-04-2018, 08:47 AM
Last Post: insyncs
  Modbus Server Max Tags Quiles85 2 724 04-04-2018, 04:19 PM
Last Post: Quiles85
  Double Float via Modbus alex barnaba 1 1.365 09-11-2017, 11:21 AM
Last Post: simon
  Modbus on Serial Ports insyncs 4 1.889 21-10-2017, 10:29 PM
Last Post: insyncs
  Modbus ASCII IOServer for eWON simon 6 3.127 15-09-2017, 10:06 PM
Last Post: simon
  Modbus Float representation frhu 1 1.103 14-07-2017, 05:01 PM
Last Post: simon

Forum Jump:

Users browsing this thread: 1 Guest(s)