Local Autonomous Data Acquisition System

The enterprise purchased NEKST-M monitoring posts of domestic production from Next Technologies. To ensure visualization of the operation of pumping units,
fire and burglar alarms, the presence of voltage on the starters, the temperature in the room, the emergency water level. The heart of NEKST-M is ATMEGA 1280, and this fact is encouraging in terms of the possibility of creating your own kit for specific needs.

The task was set in the shortest possible time and at minimal cost to create a fully autonomous local dispatching system for specific needs. The base is a microcontroller. Development, manufacturing, created by the staff itself.

The system should work without dependence on cellular networks, servers, the Internet and the permitting system for the use of radio frequency resources, do not use computers in the operation of control and management systems or maximum periodic use of laptops, without access to objects for a long time (6-9 months). The network configuration has a radial structure. The data is collected at one point and then sent for processing through conventional communication channels or in the form of a hard copy.

The system should provide:

  • control of the operation of pumping units
  • technological automation
  • protection from the consequences of emergency conditions
  • emergency signaling
  • running time calculation
  • calculation of the amount of electricity consumed
  • equipment temperature control
  • security and fire alarm
  • periodic remote data acquisition
  • unknown requirements in the future

Working conditions:

  • coverage area 1 sq. km.
  • line of sight between objects
  • temperature from +50 to -50 C
  • humidity up to 100%
  • biologically active deposits (mold, sulfate reducing bacteria)
  • vibration, no more, machines of 1-2 classes according to GOST ISO 10816-1-97
  • electromagnetic environment - switching of electric motors by KT 6053 contactors, RVS-DN soft starter, SIEMENS MICROMASTER PID control equipment, radiation in the ISM and GSM range according to the requirements for these devices, manual arc welding on site
  • overvoltage of the network, short-term interruptions in power supply, lightning surges, phase imbalance in the event of a break in the wire of overhead lines in distribution networks of 6-10 kV.

Despite such stringent requirements, the implementation is quite simple with a phased solution of the problem.

Taking into account everything, the Arduino Nano 3.0 board became the “brain” of the conceived. The shawl from "Robotdyn" has an ATMEGA 328 controller, the necessary voltage regulator 3,3V on
current 800 mA and converter on CH340G UART-USB.

First of all, operating time counters were created as the most relevant. Previously used industrial meters assembled on PICs with a transformerless power supply circuit failed due to voltage surges during the year of operation. Only those connected using home-made power supplies for a voltage of 5V remained intact. To speed up installation and universality of connection, the signal about the status of the units is taken from the terminals of the switching devices, i.e. registration of the presence of the 1st phase of the voltage with a three-phase supply of 380V. To coordinate with the controller, an intermediate relay with a 220V winding or an optocoupler made up of an LED and a GL5516 photoresistor or an optocoupler PC817 is used. All variants were tested in operation. The LED is powered by a rectified voltage with a current limit using two capacitors SVV22 rated for 630V connected in series for safety in case of accidental checking of the circuits with a megohmmeter.
Reading hours of operation using the ST7735S LCD screen, transmitting real-time data via radio channel using the E01-ML01DP05 module at a frequency of 2,4 MHz. This device contains nRF24L01+ chip and RFX2401C transceiver amplifier,
output power up to 100 mW. Helical antennas designed for the desired range in the online calculator Site. The choice of the type of antennas is due to the exclusion of receiving singly reflected waves from the surrounding metal structures. Antenna parts are printed on a 3D printer. The current state of the counters is stored in the EEPROM of the controller itself and is restored in case of an unexpected power outage. Time intervals for counting are provided by the RTC chip DS3231 in the form of a module with a backup battery. The PSU uses 3 modules, the actual pulse source 220/5V HLK-PM01 600mA, a converter from 1-5V to 5V HW-553 и 03962A - battery controller pattern protection against short circuit, overdischarge and overcharge. All components were purchased on the Aliexpress website.

Bread boardLocal Autonomous Data Acquisition System
Counter 4-channel. There are LC filters at the inputs to protect against interference over a twisted-pair communication line. Data on the state of control objects are constantly read 1 time per second, displayed in color on the LCD. The readings are updated and written to the non-volatile memory every 36 seconds. 36 seconds is 1/100 of an hour, which is the format in which the data is required. Every 12 sec. there is a transfer of information about the number of seconds of work for each control unit. EEPROM memory has a limited number of write-erase cycles, according to the manufacturer, 100000 times. The worst option is when at least one cell is constantly being updated. The volume of the 1st counter is 4 bytes, this is a number of the long format, 4 counters, a total of 16 bytes is occupied by one record. The length of the microcircuit memory is 1024 bytes, after 64 entries of 4 counters, the recording will start over. In the EEPROM library, the EEPROM.put method does not write, if the value of the cell and the information being written matches, there will be no cell degradation. As a result, the guaranteed operating time of the memory will be more than 7 years. The time of possible, but not guaranteed work can be much longer.

circuit diagramLocal Autonomous Data Acquisition System
Program in Arduino IDE//12 bytes (328%)

#include // core graphics library
#include // Hardware-specific library
#include
#include
#include
#include
#include
RF24 radio(9, 10); // radio object for working with the RF24 library,
// and pin numbers nRF24L01+ (CE, CSN)
#include
DS3231 rtc(SDA, SCL);
Time t;

//#define TFT_CS 10
#define TFT_CS 8
#define TFT_RST -1 // you can also connect this to the Arduino reset
// in which case, set this #define pin to -1!
//#define TFT_DC 9 // DC=RS=A0 - options for the designation of the output for selecting the command or data register.
#define TFT_DC 3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

// Option 2: use any pins but a little slower!
#define TFT_SCLK 13 // set these to be whatever pins you like!
#define TFT_MOSI 11 // set these to be whatever pins you like!
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
#include

byte shift = 52;
byte pinState;
unsigned long pump[4];// array with 4 seconds counter values
float m = 3600.0;
unsigned int address = 0;
int rc;// variable for counters
unsigned long sumprim = 0;
unsigned long sumsec = 0;
byte i = 0;
byte k = 34;
unsigned int z = 0;
byte b = B00000001;
byte pumrcounter[4]; // array for storing object states, 1- off, 0- on.
int start = 0; //

void setup () {

rtc.begin();
radio.begin(); // Initiate nRF24L01+
radiosetChannel(120); // data channel (from 0 to 127).
radio.setDataRate(RF24_250KBPS); // data rate (RF24_250KBPS, RF24_1MBPS, RF24_2MBPS).
radio.setPALevel(RF24_PA_MAX); // transmitter power (RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm,
// RF24_PA_HIGH=-6dBm, RF24_PA_MAX=0dBm)
radio.openWritingPipe(0xAABBCCDD11LL); // Open a pipe with an identifier for data transfer

// To set the time, uncomment the necessary lines
//rtc.setDOW(1); // Day of the week
//rtc.setTime(21, 20, 0); // Time, in 24 hour format.
//rtc.setDate(29, 10, 2018); // Date, October 29, 2018

tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
// Use this initializer (uncomment) if you're using a 1.44" TFT
//tft.initR(INITR_144GREENTAB); // initialize a ST7735S chip, RED rcB tab
tft.setTextWrap(false); // Allow text to run off right edge
tft.setRotation( 2 ); // for BLACK PCB and RED tft.setRotation(0) or not.
tft.fillScreen(ST7735_BLACK); // clear screen

DDRD=DDRD | B00000000;
PORTD = PORTD | B11110000;//software pullup is working, high level-
// controlled objects "do not work", "4" is written to all 1 senior ports D, there is no counting.

for ( rc = 0; rc < 4; rc++)
{
tft.setCursor ( 3, rc * 10 + shift ); // displaying the position numbers of control objects
tft.print(rc + 1);
}

tft.setCursor(12, 0); // output 3 lines of text
tft.println("DEVELOPERS & BUILD"); // to praise yourself loved ones
tft.setCursor(24, 10); // or malicious copyright
tft.print("DEVELOPER MM");
tft.setCursor(28, 20);
tft.print("BUILD-ER DD");

//data recovery////////////////////////////////////////////// ///////////

for ( z = 0; z < 1023; z += 16 ) { // Loop through all cells of her industry
//and writes to an array of 4 pump variables, 4 bytes each counter, because
// variable unsigned long. There are 4 counters, one record of all 4 takes 16 bytes.
EEPROM.get(z, pump[0]); // so, without the for loop, less volume
EEPROM.get(z+4, pump[1]);
EEPROM.get(z+8, pump[2]);
EEPROM.get(z+12, pump[3]);

// assigning a new next value of the sum of 4 counters
sumprim = (pump[0] + pump[1] + pump[2] + pump[3]);

// compares the new value of the sum of 4 counters in the sumprim variable with the previous value in the variable
// sumsec and if the previous sum is less than or equal to the new sum, a new greater than or equal to is assigned
// sumsec value.

if ( sumsec <= sumprim ) {
sumsec = sumprim; //

//and the current value of z is assigned to the address variable, z is the address of the beginning of the block in 16 bytes of 4 values
// counters written at the same time (because when polling a port, all 8 bits of it are written simultaneously,
// including our required high 4 bits of port D).
address=z;
}
}

// once again accessing the eeprom memory at the address of the beginning of the block of 16 bytes from 4 values ​​of the counters recorded
// last, i.e. values ​​before shutting down or rebooting due to a hang. Recording the latest
// counter values ​​into an array of 4 variables pump.

EEPROM.get(address, pump[0]);
EEPROM.get( address + 4, pump[1]);
EEPROM.get( address + 8, pump[2]);
EEPROM.get( address + 12, pump[3]);

address += 16; // increase the address for writing the next block without overwriting the data of the last record

// end of data recovery///////////////////////////////////////////// ///////////////////

attachInterrupt(0, count, RISING); // pin D2, enable interrupts, every second they come
// pulses from RTC DS3231 from SQW output

wdt_enable(WDTO_8S); // start the watchdog timer, restart the controller in case of a freeze, time,
// for which it is necessary to issue a command to reset the timer wdt_reset( and avoid rebooting during normal operation - 8 sec.
// for tests, it is not recommended to set the value to less than 8 seconds. In this case, the timer is reset in the pre-
// tearing, and it is every second.

}

void loop () {
// empty cycle, there will be control over the open-phase operation of the electric motor
}

void count() {

tft.setTextColor(ST7735_WHITE); // set font color
t = rtc.getTime(); // read time
tft.setCursor( 5, 120 ); // set cursor position
tft.fillRect( 5, 120, 50, 7, ST7735_BLACK); // clearing the time output area
tft.print(rtc.getTimeStr()); // print the clock

wdt_reset(); // reset the watchdog timer every cycle i.e. second

for (rc = 0; rc < 4; rc ++) // start the cycle of checking if the state of the input
// port bits to previous read state of port D bits
{
pinState = (PIND >> 4) & ( b << rc );

if (pumrcounter [rc] != pinState) { // and if not, then
pumrcounter[rc] = pinState; // assigning a port bit state variable a new value 1/0
}
// indication of the state of control objects by color
// BLUE is a small glitch in the existing screen (or library?), mixed up RGB and BGR.
if (pinState == ( b << rc )) {
tft.fillRect(15, ((rc * 10 + shift)), 7, 7, ST7735_BLUE); // for low counting, change GREEN to BLUE
} Else {
tft.fillRect(15, ((rc * 10 + shift)), 7, 7, ST7735_GREEN); // for low counting, change BLUE to GREEN
pump[rc] += 1; // add 1 second to the running time counter
}
}

k++;
if (k == 36) {
k = 0;

tft.fillRect( 30, shift, 97, 40, ST7735_BLACK ); // clearing the running time output area
tft.fillRect( 60, 120, 73, 7, ST7735_BLACK); // and dates

tft.setCursor( 60, 120 ); // set cursor position
tft.print(rtc.getDateStr()); // display the date on the LCD screen

for (rc = 0; rc < 4; rc ++) //displaying operating hours in integers, tenths and
{
tft.setCursor ( 30, rc * 10 + shift );// hundredths of an hour with a screen shift down by 10 pixels
tft.println(pump[rc]/m);
}

// writing "raw" operating hours (in seconds) to EEPROM //////////////////////////////////////

for(rc=0; rc<4; rc++)
{
EEPROM. put(address, pump [rc]);
address += sizeof(float); // increment write address variable
}
}

// send data over the air from data indicating how many bytes to send.
if ((k == 6 ) || (k == 18 ) || (k == 30 )) {

unsigned long data;

radio.write(&start, sizeof(start));

for ( i = 0; i < 4; i++) {
data = pump[i];
radio.write( &data, sizeof( data));
}
}
}

Small remarks at the end. The account goes at a low logical level at the inputs.

Pull-up resistances R2-R5 36 kOhm for the option with photoresistors GL5516. In the case of a phototransistor optocoupler and a relay, put 4,7-5,1 kOhm. The Arduino Nano v3.0 bootloader has been replaced with an Arduino Uno using the TL866A programmer for the watchdog timer to work correctly. The fuses have been adjusted to operate above 4,3 V. The external reset circuit R6 C3 was not used. In the sample program, the transmitter frequency does not correspond to the unlicensed band, the 2,4 MHz band is limited to frequencies of 2400.0-2483.5 MHz.

The range of the E01-ML01DP05 transmitter is 2400-2525 MHz. The bandwidth of one channel is 1 MHz, when the speed is set as “RF24_2MBPS”, the specified radio.setChannel (120) channel and the next one will be occupied, i.e. the bandwidth will be 2 MHz.

Source: habr.com

Add a comment