Twido read 1 Modbus register of a meter via Ethernet to Modbus Gateway

james_rong007

Member
Join Date
Jun 2012
Location
Sydney
Posts
1
I have a twido TWDLCAE40DRF PLC, IP 192.168.0.1, connect to a network switch port 1.
Also, I have a modbus Power Meter (Device ID: 5, PLC try to read Holding register 400003 of the meter ) connect to a Ethernet to Modbus Converter, that converter IP is 192.168.0.2 and connect to the same netwotk switch port 2.

Is anyone know how to program in the twido PLC if I want to read the value of power meter register 400003 and save to %MW51 of the twido PLC?

I have configured Marco Comms 3 for ethernet port, also index 1 of remote device table is the power meter IP and device ID 5

Many thanks!
 
Last edited:
This is relevant to something I am trying to achieve, you are able to do it using the EXCH1 (possibly EXCH2 in your case since is the Ethernet port on the Twido) command and then reading the memory location the MODBUS response goes to - I cannot seem to figure out though where exactly the returned data appears however in the physical memory. For example I am trying to do the following which is read register 2130 on an energy meter configured as a slave using modbus (plenty of comments in there should explain some of what should be going on?):

(* SETTING DESIRED MEMORY WORDS TO SETUP MODBUS COMS*)
(* MW0:030F = RECEIVE 16 BYTES WHICH IS 1 INTEGER*)
(* %MW1:0000 = NO OFFSET OR DATA DELETE FOR RECIEVED DATA *)
(* %MW2:0852 = REGISTER 2130 IN SLAVE HOPEFULLY*)
(* %MW3:0010 = FIRST WORD ADDRESS IN SLAVE REFERENCED HOPEFULLY*)
(* %MW4:000F = READ 16 BYTES HOPEFULLY WHICH ON 16 BIT PROCESSOR SHOULD = 1 SIGNED INTEGER*)

[ %MW0 := 16#030F ]
[ %MW1 := 16#0000 ]
[ %MW2 := 16#0852 ]
[ %MW3 := 16#0010 ]
[ %MW4 := 16#000F ]
(* ERROR CHECKING*)
LD 1
AND %MSG1.D
(* PERFORM MODBUS READ FUNCTION TO RETURN FRAME 10 WORDS LONG*)
(* USE RETURNED VALUE WHICH SHOULD HAVE ADDRESS OF %MW7 (MW4 + 3 POSITIONS DOWN IN STACK AS PER MODBUS DATA DEFINITION *)

(* [ EXCH1 %MW0:10 ]*)

I cannot find the returned data though for some reason - is it not in %MW7 like I think it should be?
 
[ %MW0 := 16#0106 ]
[ %MW1 := 16#0300 ]
[ %MW2 := 16#0503 ]
[ %MW3 := 16#0852 ]
[ %MW4 := 16#0004 ]
LD %S4 and %MSG.D
[ EXCH3 %MW100:10 ]

Try this, and tell me is it ok. %MW7 is 2130.
I wrote it from memory, but it should do the trick. I put 4 words, because it is multiple, and %S4 because it is exchange, so you will receive data after sending is complete, and if you put short, it is always sending. EXCH3 is for Modbus TCP.

Best regards,
Vuckovic Goran.
 
Excuse me, I made typing error, [ EXCH3 %MW1:10 ] not [ EXCH3 %MW100:10 ]...

[ %MW0 := 16#0106 ]
[ %MW1 := 16#0300 ]
[ %MW2 := 16#0503 ]
[ %MW3 := 16#0852 ]
[ %MW4 := 16#0004 ]
LD %S4 and %MSG.D
[ EXCH3 %MW1:10 ]

Try this, and tell me is it ok. %MW7 is 2130.
I wrote it from memory, but it should do the trick. I put 4 words, because it is multiple, and %S4 because it is exchange, so you will receive data after sending is complete, and if you put short, it is always sending. EXCH3 is for Modbus TCP.

Best regards,
Vuckovic Goran.
 
I have tried this and it seems to send but not receive comunications as I am using port 1 (the MODBUS ethernet from port 3 I cannot get to work) so I cannot monitor the comunications using the same port (port 1). The comunications does not seem to work when I wire the connection for some reason, might be shorting pins 5 and 7 is wrong for some reason. The code looks correct so I am not sure now...
 
Modbus TCP can be used only through port 3. Do you have Ethernet? Have you configured Ethernet port? Do you have Ethernet interface or PLC with Ethernet port on board (TWDLC*E40DRF)?
 
We have a twido with an ethernet port on it (TWDLCAE40DRF) but since we only want to read a register from a meter I have not been using the ethernet port for MODBUS TCP and have only been trying to connect using port 1 and ASCII MODBUS. If we use the ethernet port I am not sure we can use MODBUS TCP to read registers from the 3 wire terminal on the energy meter we are using since I do not think the meter will be able to interpret TCP MODBUS through a router or switch which I think you need for TCP MODBUS?
 
Excuse me, I haven't read good your first email. I thought that you have modbus TCP, because you are wrote about Ethernet. So you are using classical RS485, through port 1 and you want to read slave 05, address 03. Uncheck everything regarding Modbus Comms, put in configuration generic modbus element and make it 9600E81 with address 05, and setup power meter in same manner. So you need 8 bits (RTU), not ASCII. Then write:
[ %MW0 := 16#0106 ]
[ %MW1 := 16#0300 ]
[ %MW2 := 16#0503 ]
[ %MW3 := 16#0002 ]
[ %MW4 := 16#0004 ]
LD %S4 and %MSG.D
[ EXCH3 %MW1:11 ].

In %MW7 register will be 40003...

Best regards,
Vuckovic Goran.
 
Hello,

Would the correct code be more like this:

[ %MW0 := 16#0106 ]
[ %MW1 := 16#0300 ]
[ %MW2 := 16#0101 ]
[ %MW3 := 16#0852 ]
[ %MW4 := 16#0004 ]
LD %S4 and %MSG.D
[ EXCH1 %MW0:9 ]

Since we are using port 1 and want slave 1 on the network, also would the memory registers read and written range from 0 to 9 instead of 1 to 11?

Thank you and regards.
 
I would like to read register 8A07, which should be placed in MW3, but since MW is signed format i can't access it.

Do you have any idea how to access larger registers?
 
Last edited:
8A07 is 35335, so you wan't to read input registers, not holding registers, then command should be 04 not 06. Address to read is then 1456 (35335-30001).
 

Similar Topics

Dear friend, how to read the input register (3xxxxx) of device from twido plc. i have tried the comm macro but it always read the holding register...
Replies
3
Views
1,563
Hi guys!! I'm New here and new with this type of plcs i have TWDLMDA40DTK and i need to get a copy of the program and i don't have an original...
Replies
6
Views
682
Good, how do I control through an Analog output of a valve, that is, open the valve from 10% to 10% until it reaches 100%, and then close it...
Replies
4
Views
2,225
Hi! I bought a secondhand Twido base unit to help me learn programming and also faultfind expansion modules (one of my customers machines uses...
Replies
4
Views
1,677
We're a second hand machinery merchant. We've just had a machine arrive that has a Schneider Twido TWDLCAA24DRF PLC and a Magelis XBT-R411 HMI...
Replies
4
Views
2,395
Back
Top Bottom