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.


Hardware Definition


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.


KUxpZy2FnoU-tq-OUaKBiFhqRJ-VI7zv_Q.png


Arduino Code 


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:


#include <modbus.h>

#include <modbusDevice.h>

#include <modbusRegBank.h>

#include <modbusSlave.h>  


Then, two parameters of the libraries are declared modbusDevice e modbusSlave:


modbusDevice regBank;

modbusSlave slave;


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.


void setup()

{

regBank.setId(1); 

regBank.add(13);

slave._device = &regBank;

slave.setBaud(9600);

pinMode(13,OUTPUT);

}


The contents of the loop() function defines the dynamics of turning the LED on and off.


while(1){

byte D13 = regBank.get(13); 

if (D13 <= 0 && digitalRead(13) == HIGH)digitalWrite(13,LOW); 

if (D13 >= 1 && digitalRead(13) == LOW)digitalWrite(13,HIGH); 

slave.run();  


Action₀NET Configuration


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:


Name: Arduino

Type: digital


Then, access Edit > Devices > Channels, click Create new and configure as follows:


18VmNcyUATeZCX-xtU9oBoWRB_Gil8_Yow.png


In the created line, click in the field Protocol Options and define the following configuration:


BdC8NSEKGYELFfvMpOwBnTktBeyaR-Is5w.png


Click Settings and define the configuration according with the following parameters:


uBsuLb4LQeNycOATF-DVpBodWH5pyaq2aQ.png


Note: the Com field must be configured according to the standard Arduino port used.


Access Edit > Devices > Nodes and click New. Follow the setup:


1e69RCBwYkpHU5qzOcR0m2TZIZMf_AXerQ.png


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:


9KMczqULjMRWObTzmH_rfhpodQaG98mp5Q.png


A click on the Address field will reveal the types of Modbus protocol operations:


-P3AyU_RHjDzEk1YFUbaJZ7p0WrgxdwWjA.png


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:


zjzSaHz0jAyErZZlU1Sq-4CRFXM9DctvYQ.png


Execute the application, access Run > Startup. Check the option fields as shown: 


9qTDRjKDqLupZGwov91xcS9GSZOuTZNYeA.png


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.