How to use Twido Macros Comm with Ethernet Communication?
Goals and Symptoms
This document describes how to build a small application that will use Twido Macros Comm to exchange data with one or more Ethernet devices.
Facts and Changes
Hardware used: TWDLCAE40DRF or TWDLCDE40DRF (only this hardware can be used with this application)
Software used: TwidoSuite version 2.31.04
Causes and Fixes
Given below is the step by step procedure on how to build the application:
- 1. Under the Describe tab, double-click on the Ethernet port.
2. Enter the IP address of your Twido controller.
3. Enter the IP address of your slave devices. If you have only one slave, fill only the first line. Please notice the Index number, it will be used in the next step in the field called Network address, for the corresponding IP address.
4. Select the Program tab on the top-left, Configure tab on the top-right, Advance object, Macros Comm and check Conf check box for Comm 0 and Comm 1.
Network address 1 corresponds to IP address 192.168.100.31.
Network address 2 corresponds to IP address 192.168.100.32.
Our example will use Network address 1 for Comm 0 and Network address 2 for Comm 1.
5. We will read /write two words from each IP address 192.168.100.31 and 192.168.100.32. The table below allocates %MW words for the Macros Comm and those %MW words should not overlap with other macros or be used for something else in the program.
Start address: %MW starting address of the table
Number of words: number of %MW words allocated starting with the starting address.
In our example, for Comm 0:
C_RDNW: Start address 0 or %MW0, we read two words. The number of reserved words is N+7 or 2+7=9, from %MW0 to %MW8
C_WRNW: Start address 10 or %MW10, we write two words. The number of reserved words is N+9 or 2+9=11, from %MW10 to %MW20
- In our example, for Comm1:
C_RDNW: Start address 30 or %MW30, we read two words. The number of reserved words is N+7 or 2+7=9, from %MW30 to %MW38
C_WRNW: Start address 40 or %MW40, we write two words. The number of reserved words is N+9 or 2+9=11, from %MW40 to %MW50
6. When you check the Symbols check-box, it will fill the symbol name for some of the reserved %MW words. You will have to move some values in some of those words with your program and use others to read the values returned:
- Address of first word to be read (the address in the slave device)
- Address of first word to write (the address in the slave device)
- Value of first word to write (in the register located in the slave). When more than one register is written use the next register (e.g. Value of first word to write, %MW16, the second value will be in %MW17)
- Value of first word read (from the register located in the slave). When more than one register is read use the next register (e.g. Value of first word read, %MW7, the second one will be in %MW8)
7. You can execute only one Macros Comm function at a time. The attached program example has logic that will make sure only one Macros Comm function is active at a time.
8. Explanation of the Macros Comm syntax:
C_RDNW 0 2: it uses Macro Comm 0 and it reads two words
C_WRNW 1 2: it uses Macro Comm 1 and it writes two words
.This completes the step by step procedure on how build an application that will use Twido Macros Comm to exchange data with one or more Ethernet devices.
(Removed File URL: 212676_E0D2/Twido_Macros_Comm_Ethernet_resolution.zip)(Removed Image URL: /PubResEXPORT.nsf/2b87ee90be777fc085257c28006ee4ef/26ebaa7190afe12dc1257bc30012081a/fl_block_5/0.106?OpenElement&FieldElemFormat=gif)(Removed File URL: 212676_E0D2/Twido_Macros_Comm_Ethernet_program.zip)(Removed Image URL: /PubResEXPORT.nsf/2b87ee90be777fc085257c28006ee4ef/26ebaa7190afe12dc1257bc30012081a/fl_block_5/0.AF6?OpenElement&FieldElemFormat=gif)
Legacy KB System (APS) Data: RESL212676 V1.0, Originally authored by TVe on 10/05/2013, Last Edited by TVe on 10/05/2013
Related ranges: Twido