Content
## Introduction
I created a client program that communicates with PLC and MC protocol using Java.
The corresponding standard is part of the MC protocol (3E frame) commands.
## Operating Environment
* PLC
* Mitsubishi Electric Q03UDV CPU
* Computer
* Windows 11 Pro
* Oracle OpenJDK 25
### Installing Java on the Computer
Since the program is written in Java, it is necessary to install software that runs Java (JDK).
For example, please download and install Java from the following site.
https://www.oracle.com/jp/java/technologies/downloads/#jdk25-windows
## Operation Confirmation Steps
Sample programs are stored in the [src/mc3eprotocol/sample] directory.
When confirming operation, please change the IP address and port number in the program to those of the actual device, and then execute the program.
### Setting the PLC's IP Address
For Q03UDV, please refer to the following article to set the IP address and other settings for the PLC. If you are using another model, please gather information separately.
Qiita - [@satosisotas Built-in Ethernet settings for testing SLMP communication in Works2](https://qiita.com/satosisotas/items/38f64c872d161b612071)
The settings that must be done are as follows:
* IP address
* Port number (TCP)
* Allow writing while RUN
* Reset the CPU
### Operation Confirmation Steps
If git is installed in the operation confirmation environment, you can download the program as follows.
If git is not available, you can download this repository as a ZIP file and extract (unzip) it in your preferred location.
Additionally, a JAR file is also provided.
```powershell
# Download from GitHub
> git clone https://github.com/work-motonaga/mcprotocol-java.git
# Change directory
> cd mcprotocol-java
```
Here, [ClientSample.java](src/mc3eprotocol/sample/ClientSample.java) (only for connection and disconnection) is being executed.
```powershell
# Compile
> javac -d bin -sourcepath src src/mc3eprotocol/sample/ClientSample.java
# Execute
> java -cp bin mc3eprotocol/sample/ClientSample
```