This article aims to assist in the development of automation projects using Arduino UNO, along with Action₀NET SCADA software. We introduce introductory concepts so that the user can create increasingly elaborate applications.
We use as a hardware a system consisting of an Arduino UNO, a led, and a resistance with a value of 280Ω. The objective of this project is to develop a system in which the user can carry out the activation of the led.
Initially, include the necessary libraries so that the code to be inserted into the Arduino UNO works properly through the Modbus protocol. This is in the package appended to this article (ModbusSlave.zip). To add the library, open the Arduino setup program, go to Sketch> Include Library> add library.ZIP and browse to the folder where the library is located.
In the same folder in which the library is located is the Arduino code of this article.
At the beginning of the code you find the definitions of imported libraries:
Then, two parameters of the libraries are declared modbusDevice e modbusSlave:
In the setup() function, information is listed in the following order: the function responsible for setting the slave identification address, the output variable address, the serial communication speed, and the Arduino's physical output.
slave._device = ®Bank;
The contents of the loop() function defines the dynamics of turning the LED on and off.
byte D13 = regBank.get(13);
if (D13 <= 0 && digitalRead(13) == HIGH)digitalWrite(13,LOW);
if (D13 >= 1 && digitalRead(13) == LOW)digitalWrite(13,HIGH);
Now we will perform the Arduino UNO interaction with Action₀NET.
Create a new project. Open the Action₀NET application, access New Project, and after filling in the project data, click Create New Project. Then create a tag that will be used to control the led. Go to Edit> Tags> Objects and set up the cited columns as:
Then, access Edit > Devices > Channels, click Create new and configure as follows:
In the created line, click in the field Protocol Options and define the following configuration:
Click Settings and define the configuration according with the following parameters:
Note: the Com field must be configured according to the standard Arduino port used.
Access Edit > Devices > Nodes and click New. Follow the setup:
Click the PrimaryStation field and enter the value set for the slave address, in this case: 1.
Access the Points column, and in TagName, enter the name of the tag you created. The line will be configured as follows:
A click on the Address field will reveal the types of Modbus protocol operations:
In this example, the Coils type will be used. In the Address field, enter the address set in the previous code (13). Look at the final dot image:
Execute the application, access Run > Startup. Check the option fields as shown:
Click Run Startup: a comunicação entre o Action₀NET e o Arduino será iniciada.
In the Watch screen, open after the end of the execution, the LED can be activated by changing the value of the Arduino tag to 1 or 0.
Default Project (Arduino)
Attached to this article, there is a project that can be used as a model, in which already are screens configured for desktop and mobile applications.