I decided to create an alliance between arduino and Master Scada.
Why Master Scada? I will answer: Master Scada works through its own OPC server with a lot of settings, which allows you to have a good look at the process of polling channels (well, it's free for 32 channels).
For the test, I used two HC-04 ultrasonic rangefinders and the arduino uno board.
')
Transmission carried out by modbus protocol.
To use the SimpleModbusSlaveV9 library in arduino, you need to install it first.
Sketch embedded in arduino:
// connect the library
#include <SimpleModbusSlave.h>
// declare variables
#define echoPin 2
#define trigPin 3
#define echoPin1 4
#define trigPin1 5
enum
{
ADC_VAL,
PWM_VAL,
HOLDING_REGS_SIZE = 4 // enter the number of channels
};
unsigned int holdingRegs [HOLDING_REGS_SIZE];
void setup ()
{
modbus_configure (& Serial, 115200, SERIAL_8N2, 1, 2, HOLDING_REGS_SIZE, holdingRegs); // enter the polling speed
modbus_update_comms (115200, SERIAL_8N2, 1);
// for ultrasound sensors
pinMode (trigPin, OUTPUT);
pinMode (echoPin, INPUT);
pinMode (trigPin1, OUTPUT);
pinMode (echoPin1, INPUT);
}
void loop ()
{
int duration, cm;
digitalWrite (trigPin, LOW);
delayMicroseconds (2);
digitalWrite (trigPin, HIGH);
delayMicroseconds (10);
digitalWrite (trigPin, LOW);
duration = pulseIn (echoPin, HIGH);
cm = duration / 58;
int duration1, cm1;
digitalWrite (trigPin1, LOW);
delayMicroseconds (2);
digitalWrite (trigPin1, HIGH);
delayMicroseconds (10);
digitalWrite (trigPin1, LOW);
duration1 = pulseIn (echoPin1, HIGH);
cm1 = duration1 / 58;
delay (100);
// Received values are passed to OPC
modbus_update ();
holdingRegs [1] = cm1; // address 1
holdingRegs [2] = cm; // address 2
holdingRegs [3] = cm; // address 2
}
Next, configure the OPC. Select the port number and polling rate:

Create a device set the response time and the polling period:

Add Tags, for each parameter has its own tag. Enter in the column the value corresponding to the holdingRegs []:

And run:

Now move on to setting up MasterScada.
We connect the OPC server with the scud to draw the mnemonic scheme for visualization:

And run:

No failures were found; in the future, connecting sensors with a current output of 4-20 mA and using the arduino platform as a module for data collection and display at small objects.
If anyone is interested I can describe the exchange of arduino + Delphi