IOT

Arduino pump control+ STONE HMI display

The blade intelligent regulation system is a patented technology, which is used in the mainstream control system of various large, medium and small hydropower stations and pumping stations.  This project uses the reliable serial industrial touch screen as the man-machine interface to display daily parameters and real-time blade dosage, output power, instant flow and other information, as the operation effect display.  In addition, the working condition log and fault alarm form are also planned, and the standby button is reserved.  The project uses the serial touch screen for data display and slide indication display. The accessories are as follows:  

  1. STVI056WT-01 serial touch screen and STONE adapter board V1.2;  
  2. Matching Arduino control board;  

Brief description of the interface function of intelligent blade regulating control system.  

There are three buttons on the home page, which can be pressed to enter the corresponding hydropower station system, pump station control system, and the user guide interface (with spare buttons). The user guide interface shows the framework of the demo system, as shown in the following figure:

(Home interface of Enlegi Blade Intelligent Adjustment Control Demonstration Software)

At the interface of control system of hydropower station, there are start and stop buttons and display of status, rating (including rated voltage, rated power and rated speed) and control value (including pitch Angle of propeller blade and output power).  In addition, there can also be other page jump buttons (such as home page, working condition log, fault alarm and other standby buttons). In working condition log and fault alarm page, there can be a back button to return to this page.  The diagram below:

           (Intelligent control display interface of hydropower station)

Pump station control system interface function description. The diagram below:

                            (Function interface of pump station control system)

In the functional interface of the pump station, the mode can be changed and the power supply of the whole system can be switched on and off to display the actual simulated parameters (such as blade dosage, immediate flow rate, output power), and other interfaces can be switched (such as working condition log, fault alarm report). At the same time, system values (total number of blades, rated power, set flow rate) can also be displayed.  Other interfaces can also have, such as working condition log (contents can be ordered number, occurrence time, event details, notes), fault alarm (contents can be ordered number, occurrence time, alarm details, alarm code, etc.), the two interfaces can have a return button, can return to the pump station functional interface.  

Working idea:  

Serial port screen serves as man-machine interface and communicates with Arduino development board. The board accepts button commands of touch screen and transmits data to serial port touch screen for synchronous display.  Slider scale is designed to display power changes dynamically. Icons of power switch, power knife, mode switch and mode knife are designed to generate ICON files and animate the action effects of power supply and mode.  In addition, in the Arduino demo program, variable memory is used to read instructions to obtain the state of power supply and mode, so as to control the simulation of output data and output the actual quantity window to the serial port screen.  

Work steps:  

  1. Setting up hardware;  
  2. A) Connect the Arduino development board and USB to the serial port conversion board;  
  3. B) Connect the STONE touch screen with the USB serial port download board and the USB to serial port adapter board;  
  4. C) Connect the serial port screen and the Arduino development board power supply;  

3, through serial command debugging, and then programming to achieve pump station control and hydropower station control demonstration functions.  

 Next, document the specific development process.

First, set up the hardware connection.  

Do a good job of connecting all parts according to the working procedures:

Next, make the ICON indicator picture.  

The buttons and knife ICONS used in this project are made as follows:  

(Pump station control switch, knife animation ICON file 8. ICO list browse diagram)

In the menu bar of STONE TOOL BOX (GUI Design software), click Icon generation Tool under Tool (T) menu to pop up Icon Tool dialog box. Click “choose image path” at the bottom of the dialog box to select Icon image path.  Click the button “Generate ICON file” to package the BMP files in the path to Generate the “.ico “file recognized by the STONE TOOL BOX (GUI Design software) platform. Click the button” Preview “to view the ICON list in the imported”.ico “compressed file.  

Button to animate BMP Icon, pixel as above (Produced Variable Icon control, the size of the same position should be the same), pump station control 8 cut pictures into the same folder.  Then, on the left side of the STONE TOOL BOX (GUI Design software) screen, select the Icon page card and Add it to the compressed 7. Ico file using the “Add Icon” button under “Icon List”.  Put all the 6 pictures of the control switch state of the hydropower station into another folder and arrange them in order 1-6.  Create the “6. Ico” file, and then on the left side of the STONE TOOL BOX (GUI Design software) screen, select the Icon page card and Add the zipped “6. Ico” file using the “Add Icon” button under “Icon List”.  

Now import the image Icon into STONE TOOL BOX (GUI Design software) and make the function button.  

The method of 9-variable-animation icon.wmv is still adopted in this project to realize the animation function.  The screenshot of parameter setting is as follows:  

            (Attribute diagram of Variable ICON of hydropower station)

From left to right are the ICON parameter Settings of the three variables of the hydropower station function page: start, stop and state.  Their memory addresses are set to the same (0x0039) and their data ranges ar e the same, so their changes are synchronized.  Icon files are 6. Ico, and the corresponding Icon serial numbers are 1 and 2, 3 and 4, 6 and 5 respectively, which are selected according to the actual state.  

The button state animation effect is achieved through incremental buttons.  The following figure shows the parameters of the increment button on the left and the decrimination button on the right. The address is 0x0039, both of which are the same as that of the Variable ICON.

(Attribute diagram of incremental button with the same memory address)

(Variable ICON attribute diagram of button knife status of pump station)

From left to right are the ICON parameter Settings of the four variables of the pump station function page: power button, power knife, mode knife and mode button.  Here, both Icon files are 8.ICO, and their data range is the same, in which the memory address of the same will be changed synchronously.  

Button state animations are also implemented with incremental buttons.  In the following figure, the left side of the power supply reduction button and the right side of the mode increment button are the parameters of the power supply reduction button. The addresses are the same as the above Variable ICON, respectively 0x0009 and 0x000A.  This is More than the limit processing mode of a ping-pong button.

(Incremental button attribute diagram of pump station button state Variable ICON Variable with the same memory address)

In addition, the output power of the pump station is displayed using a sliding icon, as shown in the figure below:

Its parameter attributes are:

(Sliding icon of output power of pump station — property box of Slider scale)

The icon of this Slider scale control is called in the official DEMO 24.ico. The method to add 24.ico file is the same as above.  The memory address of this Slider Scale control is 0x0180, which can be written in the MCU program with 82 instruction (as shown in the above picture, the range is set to 0-100) to change the position of the icon.  

In particular, the status of power supply and mode buttons in this project is read out from the memory address 0x0009, 0x000A and 0x0039 of the serial port screen through 83 instruction. 

The instructions used are as follows:  

A5 5A 04 83 00 09 02  

The feedback of serial port screen is as follows:  

A5 5A 08 83 00 09 02 00 01 00 02  

The following 00 01 is 2byte data of 0x0009, 00 02 is 2byte data of 0x000A.  

Read instruction 0x0039 as:  

A5 5A 04 83 00 39 01  

The feedback of serial port screen is:  

A5 5A 06 83 00 39 01 00 01 or  

A5 5A 06 83 00 39 01 00 02  

There are five data addresses to write to: 0x0020, 0x0160, 0x0180, 0x0260, 0x0280.  

Whereinto, the leaf dosage address is 0x0020, a 2-bit integer number of 2 bytes.  It can be transmitted to the touch screen display through the serial port.  

To pass 11 to the touchscreen data variable display, use the following command:  

A5 5A 05 82 00 20 00 0B  

Programming debugging.  

The code is as follows:  

/*

  frank8

  STONE and arduino COMM,enlaiji yepian system.

  Turns on an LED on for one second, then off for one second, repeatedly.

  The address 0x0020 is address of num of YePian;

  The address 0x0160 is address of now LiuLiang;

  The address 0x0180 is address of Bengzhan outpower;

  The address 0x0260 is address of Jiejujiao;

  The address 0x0280 is address of water outpower;

  The address 0x0009 is bengzhan power key;

  The address 0x000A is bengzhan mode key;

  The address 0x0039 is water power key.

  This example code is in the file of frank.  20210611

 */

// Pin 13 has an LED connected on most Arduino boards.

// give it a name:

int led = 13;

int iYePian = 0;          //0x0020 for The num of YePian!

int iGongLu = 0;        //0x0180 for The GongLu!

int iLiuLiang = 0;      //0x0160 for The now LiuLiang!

int iJiao = 0;            // 0x0260 for The JieJuJiao!

int iGongLuWater = 0;      //0x0280 for The Water GongLu! value is 0-50000!

int iLed = 1;            //delay time num.

int iNum = 0 ;      //read in char num.

int iNum2 = 0;      //read in char num2 for ShuiDianZhan!

int iPower = 2;    //key statue 0x0009

int iMode = 2;      //key statue 0x000A

int iPowerWater = 2;      //key statue 0x0039

// the setup routine runs once when you press reset:

void setup() {                

  // initialize the digital pin as an output.

  pinMode(led, OUTPUT);     

  Serial.begin(115200);  // Open the serial communication function and wait for the serial port to open  

while (!Serial) {

    ; // wait for serial port to connect. Needed for Leonardo only

  }  

}

// the loop routine runs over and over again forever:

void loop() {

  int inChar;

    if (iLed == 900)  {     

//——- read 0x0009 and 0x000A value———- 

            Serial.write(0xA5);       //”A5″ is 165

            Serial.write(0x5A);       //”5A” is 90

            Serial.write(0x04);      //lenght

            Serial.write(0x83);      // read!

            Serial.write(0x00);     // address of bengzhan power key!

            Serial.write(0x09);     // address of bengzhan power key!

            Serial.write(0x02);      // 0x0009(power) and 0x000A(mode)

//———STONE return value will be “A5 5A 08 83 00 09 02 00 01 00 02”——

     }

/*——————————————————————————-*/     

    if (iLed == 800)  {     

//——- read 0x0039 value———- 

            Serial.write(0xA5);       //”A5″ is 165

            Serial.write(0x5A);       //”5A” is 90

            Serial.write(0x04);      //lenght

            Serial.write(0x83);      // read!

            Serial.write(0x00);     // address of ShuiDianZhan Power key!

            Serial.write(0x39);     // address of ShuiDianZhan power key!

            Serial.write(0x01);      // 0x0039(power key) 

//———STONE return value will be “A5 5A 06 83 00 39 01 00 01 “——

     }

  // Read the message sent by the serial port:

  if (Serial.available() > 0)   {    inChar = Serial.read();  }

  if (inChar == 0x09)  {  iNum = 1 ; }

  if ((inChar == 0x02)&&(iNum == 1))  {  iNum = 2 ; }

  if ((inChar == 0x00)&&(iNum == 2))  {  iNum = 3 ; }

  if ((inChar == 0x01)&&(iNum == 3))  {  

      iNum = 4 ;

      if(iPower != 1){

          iPower  = 1 ;    //power ON!

          iLiuLiang = 10 ;

          iGongLu = 50 ;

          iYePian = 10 ;         

      }

   }

   if ((inChar == 0x02)&&(iNum == 3))  {  

      iNum = 4 ;

      iPower  = 2 ;      //power OFF!

      iLiuLiang = 0 ;

      iGongLu = 0 ;

      iYePian = 0 ;

   }

   if ((inChar == 0x00)&&(iNum == 4))  {  iNum = 5 ; }

   if ((inChar == 0x01)&&(iNum == 5))  {  

      iNum = 0 ;

      iMode  = 1 ;    //Mode is Good!

   }

   if ((inChar == 0x02)&&(iNum == 5))  {  

      iNum = 0 ;

      iMode  = 2 ;    //Mode is OFF!

      if(iPower == 1)iGongLu = 60 ;   //GongLu is set 60%!

   }

  //——————0x0009 and 0x000A key read ok! iPower\iMode ok!—————————-

   if (inChar == 0x39)  {  iNum2 = 1 ; }

  if ((inChar == 0x01)&&(iNum2 == 1))  {  iNum2 = 2 ; }

  if ((inChar == 0x00)&&(iNum2 == 2))  {  iNum2 = 3 ; }

  if ((inChar == 0x01)&&(iNum2 == 3))  {  

      iNum2 = 0 ;

      if(iPowerWater != 1){

          iPowerWater  = 1 ;    //power ON!       

          iJiao = 0 ;

          iGongLuWater = 0 ;

      }

   }

   if ((inChar == 0x02)&&(iNum2 == 3))  {  

      iNum2 = 0 ;

      iPowerWater  = 2 ;      //power OFF!

   }

  //——————0x0039  key read ok! iPowerWater ok!—————————-

  delay(1); 

  iLed += 1;   

  if (iLed == 500)  {  

      digitalWrite(led, HIGH);                 // turn the LED on (HIGH is the voltage level)

                  //delay(500);               // wait for a second, Range:200-2000

           if(iPower == 1)  { 

               iYePian += 1;                      //range:1-20

               iLiuLiang += 1;                    //range:1-20

               if(iMode == 1)  iGongLu += 5;    //range:1-20

           }   

           if(iYePian >= 14 )  {  iYePian = 10;  }   

           if(iGongLu >= 70)  {  iGongLu = 50;  }   

           if(iLiuLiang >= 14)  { iLiuLiang = 10;  }   

           if(iPowerWater == 2)  { 

               iJiao += 1;                      //range:1-20

               iGongLuWater += 2;                    //range:1-20

           }   

           if(iJiao >= 60 )  { 

               iJiao = 0; 

               iGongLuWater = 0; 

           }   

  }    

  if (iLed >= 1000)  {    

      digitalWrite(led, LOW);                 // turn the LED off by making the voltage LOW

                  //delay(500);               // wait for a second, range:200-2000

      iLed = 1;

            Serial.write(0xA5);       //”A5″ is 165

            Serial.write(0x5A);       //”5A” is 90

            Serial.write(0x05);

            Serial.write(0x82);

            Serial.write(0x00);     // address of YePian

            Serial.write(0x20);     // address of YePian

            Serial.write(0x00);

            Serial.write(iYePian);

            Serial.write(0xA5);       //”A5″ is 165

            Serial.write(0x5A);       //”5A” is 90

            Serial.write(0x05);

            Serial.write(0x82);

            Serial.write(0x01);    // address of GongLu

            Serial.write(0x80);    // address of GongLu

            Serial.write(0x00);

            Serial.write(iGongLu);

            Serial.write(0xA5);       //”A5″ is 165

            Serial.write(0x5A);       //”5A” is 90

            Serial.write(0x05);

            Serial.write(0x82);

            Serial.write(0x01);    // address of LiuLiang

            Serial.write(0x60);    // address of LiuLiang

            Serial.write(iLiuLiang);      //LiuLiang is 2800–3200

            Serial.write(0x80);            

            Serial.write(0xA5);       //”A5″ is 165

            Serial.write(0x5A);       //”5A” is 90

            Serial.write(0x05);

            Serial.write(0x82);

            Serial.write(0x02);    // address of ShuiDianZhan JieJuJiao

            Serial.write(0x60);    // address of ShuiDianZhan JieJuJiao

            Serial.write(0x00);

            Serial.write(iJiao);

            Serial.write(0xA5);       //”A5″ is 165

            Serial.write(0x5A);       //”5A” is 90

            Serial.write(0x05);

            Serial.write(0x82);

            Serial.write(0x02);    // address of ShuiDianZhan out Power

            Serial.write(0x80);    // address of ShuiDianZhan out Power;

            Serial.write(iGongLuWater);      //ShuiDianZhan out Powe is 0–32000

            Serial.write(0x00);            

  }    

Finally, record the video online. 

Connect the power supply and communication, connect the Arduino development board to the serial port communication, observe the functional interface of hydropower station and pumping station on the serial port screen, touch the switch to check the effect, and slide the icon and data are normal.  

Source: Plato Data Intelligence