ModBus Topic

HI

I’m using IO server TCP Modbus on Ewon Flex205 and using two topic A & B. I need to retrieve topic B on a event which I can manage but I wonder which syntax to use in my script.

My goal is to activate topic B and the tags related to it only. Can you tell me which syntax? Thanks in advance.

The reason is that the slaves are not always online and cause error com on the Flex205.

Hello Marc,

Given what you are working on, you may do a ONCHANGE on a Status tag. Then do a conditional loop for checking if the status tag shows communication for that topic

I would review the IO Server documentation and the reference manual for BASIC IDE

I do understand the ONCHANGE commande wich I already used but as far as the IORCV and IOSEND commande is not very clear to me. I took the example from the programming reference guide and need to read a tag on a specific salve. Can you give me a bit explanation on it

Thank’s for your help

Ex: Tag = IOSEND MODBUS,21,40021

MODBUS: is the IOServerName in the IO server setup
21: is the salve adresse
40021: is my tag reference

TestIO:
// The following creates the Modbus command
a$ = chr$(4) + chr$(0) + chr$(0) + chr$(0) + chr$(1)
// Initiate the Modbus request on slave 21
a% = IOSEND “MODBUS”, “21”, a$

a% = IOSEND IOServerName, Address, IoCommand

That bit of BASIC IDE is used when you want to the FLexy to send a command to the Modbus slave. The IOSend sends the transaction and results are recieved.

Hi Kevin

To solve my problem of geting this error mbsios-Modbus Enter slow poll mode (Address 7 - 192.168.10.10) from the ewon log, because like Iwould like to use scripting to solve the proble. In fact I have 7 station wich come alive once in a wild only to transmit an even. Using IORCV and IOSEND would it solve that error.
Script:

ONCHAGE “Tagname”,“goto read_station1”

read_station1:
a$ = chr$(4) + chr$(0) + chr$(0) + chr$(0) + chr$(1)
a% = IOSEND “MODBUS”, “21”, a$
a% = IOSEND MODBUS,40021
END

Hello Marc,

That error indicates there is an issue with communication between our Flexy and the PLC. If you are getting that error, then the BASIC script might not be able to transmit correctly.

Can you attach aback up with support files?

Hi Kevin
Sorry about the delay, yes, I do understand, but I want to read that PLC only when I get the flag which I receive from that PLC which is offline most of the time

I took the example, and can you tell me what is wrong with my code. Need to read 40022 registers from that Modbus PLC at station 20.

TestIO:
// The following creates the Modbus command
a$ = Chr$(22)
// Initiate the Modbus request on slave 20
a% = IOSEND “MODBUS”, “20”,a$
Wait_IO_End:
b% = IORCV a%, 1 // read the status
IF b% = -1 THEN
GOTO Wait_IO_End // If idle then loop
ENDIF
b$ = IORCV a% // Read the result and free the slot
PRINT LEN(b$)
PRINT b$
END

A post was split to a new topic: Multiple Modbus IO Servers