Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[PC-1405] Opta: Extended Ethernet.begin() Method for Modbus TCP and PLC IDE Tutorial #1347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
jcarolinares merged 1 commit into main from taddy/opta-modbustcp-plcide-updateV1
Sep 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ We highly recommend reviewing [this tutorial](https://docs.arduino.cc/tutorials/

To configure the Modbus TCP communication, we need to know the IP address of each OptaTM. When OptaTM is connected to a computer using the RJ-45 cable and the Ethernet switch, and the ethernet configuration is left as default, an IP address is automatically provided to OptaTM by the external *Dynamic Host Configuration Protocol (DHCP)* server. You will need to scan for the address and use that IP address as the device address of OptaTM. To find the automatically assigned IP address, it is possible to use this [scanner](https://angryip.org/) to identify the address.

OptaTM can also be configured manually with a specific IP address. This method is viable to assign devices with specific addresses to operate under certain policies if required. For this configuration, the IP setting must be defined by using the sketch found within the `Resources` tab of the PLC IDE. The following image shows what the configuration could look like inside the sketch.
OptaTM can also be configured manually with a specific IP address using __Ethernet.begin()__ method. This method is viable to assign devices with specific addresses to operate under certain policies if required. For this configuration, the IP setting must be defined by using the sketch found within the `Resources` tab of the PLC IDE. The following image shows what the configuration could look like inside the sketch.

![OptaTM Manual IP Configuration](assets/opta_plcide_ipconfig.png)

***The __Ethernet.begin(ip, dns, gateway, subnet)__ method postpones initialization for 60 seconds when the RJ45 cable is found to be disconnected or when Ethernet settings, such as the IP address, are improperly configured. The __Ethernet.begin(NULL, ip, dns, gateway, subnet, connection_timeout)__ method can be used to extend initialization process and tweak the `connection_timeout` value. This parameter sets the timeout period for the Data Layer connection to be established.***

If the IP address for OptaTM is set manually, it is necessary to configure the Ethernet interface on your computer by introducing a manual IP address setting under *IPv4*. The information set under the IPv4 configuration follows the gateway setting. A stable connection with OptaTM using the PLC IDE is essential for project development. The following image shows a configuration example on Windows 11 operating system:

![Windows IP Manual IP Configuration](assets/plcide_ip_manual_config.png)
Expand Down Expand Up @@ -207,9 +209,11 @@ In the sections that follow, the configuration of each OptaTM, based on its des
#### Modbus TCP Server OptaTM
<br></br>

To set OptaTM as a Modbus TCP Server, navigate to the `Ethernet` tab located in the `Resources` panel of the PLC IDE. Since the `Modbus TCP Slave` mode is always enabled, you don't have to change any setting in the current window. However, certain properties are essential for OptaTM to work properly with Modbus TCP, thus it requires the subsequent configuration.
To set OptaTM as a Modbus TCP Server, navigate to the `Ethernet` tab located in the `Resources` panel of the PLC IDE. Since the `Modbus TCP Slave` mode is always enabled, you don't have to change any setting in the current window. Ethernet properties are essential for OptaTM to work properly with Modbus TCP, thus it requires a proper Ethernet configuration.

When initializing a project file in PLC IDE, Ethernet properties within the sketch are commented out. These lines should be uncommented to activate the configurations. Once this is done, the sketch should be manually downloaded to OptaTM through the `OptaTM Configuration` window.

The Modbus TCP Server OptaTM will employ the following Ethernet properties.
The Modbus TCP Server OptaTM will employ the following Ethernet properties within the sketch.

```arduino

Expand All @@ -227,8 +231,6 @@ void setup()

These properties — `ip`, `dns`, `gateway`, and `subnet` — are provided as arguments to the `Ethernet.begin()` method, setting its properties for OptaTM. It can be adjusted as per your preference or based on network prerequisites. For instance, `ip(192, 168, 1, 2)` denotes the IP address assigned to the Modbus TCP Server OptaTM.

When initializing a project file in PLC IDE, certain essential lines within the sketch are commented out. These lines should be uncommented to activate the configurations. Once this is done, the sketch should be manually downloaded to OptaTM through the `OptaTM Configuration` window.

The following image shows the `Status variables (volatile)` window. Here, we will define the `cnt` variable, assigning its access address and datatype for Modbus TCP transmission.

![Arduino PLC IDE - OptaTM Server Status Variable](assets/opta_plcide_server_statVar.svg)
Expand Down

AltStyle によって変換されたページ (->オリジナル) /