Sign in to follow this  
Followers 0
BlurDavinci

Twido with Modbus 485 using EXCH2

15 posts in this topic

Hi: I have 6 unit of scale with Modbus RTU acted as Slave, with Twido as Master. I'm trying to figure out how to use EXCH2 (Using Port 2) to Send Query to Slave and Write Value to Scale. the Syntax of Exchx: [EXCHx %MWi:L] where: x = port number (1 or 2) L = number of words in the control words and transmission and reception tables I read through the Manual, I understand NOTHING! The Control Table : Command and Length, What Command? There is no Detail. The Example is far worst, the Explanation is near to Zero! LD 1 [%MW0 := 16#0106 ]----> What is 01? What is 06? [%MW1 := 16#0300 ]-----> ? [%MW2 := 16#0203 ]------>? [%MW3 := 16#0000 ]------> [%MW4 := 16#0004 ]-----> 4 word ? I guessed? LD 1 AND %MSG2.D [EXCH2 %MW0:11] LD %MSG2.E ST %Q0.0 END I'm Stuck! Can Someone Help?

Share this post


Link to post
Share on other sites
Hi The EXCH2 command works. I had used it, once, for fetching data from five ATV38 VFDs acting as Modbus slave devices. I had followed the instructions given as per the manual and used in ladder logic. As much as I remember, the first word contains the Modbus code for writing/reading data, the second is for no of registers to be used, then the data to be sent, starting address of the source....something like that. I agree that the example is difficult to follow, I used it once and it worked. Besides, there is no other explanation or example available on the topic!! I would suggest that you go through the manual again. The details on the contents of the registers to be used are given in there. Good Luck! Regards Mandar.

Share this post


Link to post
Share on other sites
Hi: Now I'm able to Read single/multi word, Write Single Word BUT..............................NOT MULTIPLE WORD!? LD 1 [%MW0 := 16#010C ] [%MW1 := 16#0007 ] [%MW2 := 16#0210 ] [%MW3 := 16#0010 ] [%MW4 := 16#0009 ]-----> Start Address MW9 (400010) [%MW5 := 16#0004 ]-----> 2 Word [%MW6 := 16#6566 ]-----> First Word Value [%MW7 := 16#6768 ]------> Second Word Value LD 1 AND %MSG2.D [EXCH2 %MW0:11] LD %MSG2.E ST %Q0.0 Can some one tell me where is the Bug? Have some one experience this kind of Problem?

Share this post


Link to post
Share on other sites
HI! I have the same problem. Can someone tell me what it mean`s [%MW0 := 16#010C ]. Does that mean that the Hexa value 010C write`s into MW0 or somethiing else? What is sent [EXCH1 %MW0:11] ? How can I read/write with Twido from a modbus address 116385 from another PLC that is not twido? LD 1 [%MW0 := 16#010C ] [%MW1 := 16#0007 ] [%MW2 := 16#0210 ] [%MW3 := 16#0010 ] [%MW4 := 16#0009 ] [%MW5 := 16#0004 ] [%MW6 := 16#6566 ] [%MW7 := 16#6768 ] LD 1 AND %MSG1.D [EXCH1 %MW0:11] LD %MSG1.E ST %Q0.0 Please help me Thank you

Share this post


Link to post
Share on other sites
sorry for my english.......... You may understand the meaning of each word of the EXCH table just seeing how is composed the modbus request. You may see on modbus.org Anyway the standard modbus query is as follow: reading multiple words (function code 03) 1 MSB slave address 1 LSB function code (HEX) 2 start address (HEX) 3 number of words writing multiple words(function code 16 = 10 HEX) 1 MSB slave address 1 LSB function code (HEX) 2 start address (HEX) 3 number of words 4 number of bytes 5 first value 6 second value ... In the Help of Twido soft are described all the common "standard modbus query" : function 01-02-03-04-05-06-15-16 and the related EXCH table Moreover the Twido attaches in the head of the query 2 words for configuring the port (Modbus RTU the first MSB always 01) and the table of words used for EXCH function. The second word is used only for RTU protocol configuration (offset) In your example Mw0 -> 01 = send/receive; 0C = 12 bytes (starting from MW2 to MW7 = modbus query) Mw1 -> 00 = no offset for received data; 07 = delete the seventh byte of the query during the transmission Mw2 -> 02 = slave address; 10 = function code 16 (write multiple register) Mw3 -> 0010 = first word address in the slave (%Mw16) Mw4 -> 0009 = number of words to be written ????????????? Mw5 -> 0004 = number of bytes to be written ??????????? Mw6 -> 6566 = first word value (%mw16 in the slave) Mw7 -> 6768 = second word value (%mw17 in the slave) Error: Mw4 -> you want to write 9 words but the length of the query is not correct (Mw0 = 0C 12 bytes only). You should set Mw0 = 01 1A (26 bytes from Mw2 to Mw14) Mw5 -> the number of bytes is always = Mw4 x 2 (9 x 2 = 18)

Share this post


Link to post
Share on other sites
Thank you! But I don`t have two Twido controllers. I have one Twido, wich will be a slave and I have one Konc plc wich will be a master. How do I configure a modbus communication of a twido. (it is not the same as the two twido described in the manual). Please help me. Please LP Edited by Marjan

Share this post


Link to post
Share on other sites
com1 default settings is modbus slave, if you use the function EXCH1 automatically com1 will become modbus master. You have not to configure nothing on modbus slave device but the protocol (speed , parity etc etc) You have not to write any line in the software. So you just configure with Twidosoft the protocol of the com1 identical to the modbus master device and nothing else. Remember the cable has the particularity that pin 5 and 7 (mini DIN) must be connected together to the common of the circuit (only for com1 rs485 modbus protocol). Pin 1 and 2 are A+ and B-

Share this post


Link to post
Share on other sites
Hi! And how can I write a value 1 from a modbus master (Twido) to a modbus slave (may plc) to a modbus address 3D? Help, please Thank you

Share this post


Link to post
Share on other sites
following the example of the help of twidosoft: LD 1 [%MW0 := 16#010A ] [%MW1 := 16#0007 ] [%MW2 := 16#0x10 ] set the correct slave address x=??? [%MW3 := 16#003D ] [%MW4 := 16#0001 ] [%MW5 := 16#0002 ] [%MW6 := 16#0001 ] LD 1 AND %MSG1.D [EXCH1 %MW0:10] LD %MSG1.E ST %Q0.0 I think this example should run

Share this post


Link to post
Share on other sites
Thank you! I have another question. I have a LCD display for Twido and I am sending values to plc in MW. I am comparing these words with %SW51 (RTC) wich is hex, but the MW are DEC. How can I converse MW (DEC) to HEX? Have a nice day

Share this post


Link to post
Share on other sites
The RTC system words are not simply HEX but BCD format, So Twido has two instruction for convert from integer to BCD ITB and from BCD to integer BTI

Share this post


Link to post
Share on other sites
I have a new problem with modbus. I am reading 4 DI, writing 5 DO and reading 1 AI from a slave device. The code for reading DI is: LD 1 [%MW0 := 16#0106 ] [%MW1 := 16#0300 ] [%MW2 := 16#0D01 ] [%MW3 := 16#4000 ] [%MW4 := 16#0001 ] [%MW5 := 16#0002 ] [%MW6 := 16#0001 ] LD 1 AND %MSG1.D [EXCH1 %MW0:10] LD 1 [%MW10 := 16#0106 ] [%MW11 := 16#0300 ] [%MW12 := 16#0D01 ] [%MW13 := 16#4001 ] [%MW14 := 16#0001 ] [%MW15 := 16#0002 ] [%MW16 := 16#0001 ] LD 1 AND %MSG1.D [EXCH1 %MW10:10] ..... and so on for other signals. WHY ARE SOME OF THE DATA LOST IN TRANSMISSION OR RECEPTION (SOME OF THE DI ARE NOT READ OR SOME OF THE DO ARE NOT SET)?

Share this post


Link to post
Share on other sites
LD 1 [%MW0 := 16#0106 ] [%MW1 := 16#0300 ] [%MW2 := 16#0D01 ] you are reading from slave 13 a bit (%M or %Q) [%MW3 := 16#4000 ] at this address [%MW4 := 16#0001 ] one bit [%MW5 := 16#0002 ] no need to wirte this word. In here you'll receive the answer 0D01 [%MW6 := 16#0001 ] no need to wirte this word. In here you'll receive the answer 0001 LD 1 AND %MSG1.D [EXCH1 %MW0:10] in %MW7 you'll receive the value of the bit you ask for = or 00 or 01 For reading 4 DI write: [%MW0 := 16#0106 ] [%MW1 := 16#0300 ] [%MW2 := 16#0D01 ] if the slave supports code 02 you might read %I [%MW3 := 16#4000 ] [%MW4 := 16#0005 ] and you'll receive all value starting from %MW7 to %MW9

Share this post


Link to post
Share on other sites
This is really good advice - I cannot seem to figure out though why the returned data appears in %MW7 to %MW9. 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?

Share this post


Link to post
Share on other sites

I'm new to twido, on going through manual I understood we can communicate with meter. I am trying to communicate twido twdlcaa24drf with em 6400 meter via twdnac485t with exch instructions, I have configured as in manual example but unable to understand how to create animation table (control, transmission & reception ). Can anyone guide in creating one.

Thank you

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0