Arduino Tutorial:Using STONE HMI make speed curve recording
Home technology Arduino Tutorial:Using STONE HMI make speed curve recording

Arduino Tutorial:Using STONE HMI make speed curve recording

16 min read
0
59

The real time tach curve is created using the Real-time curve control of the STONE serial screen. The Real-time curve control of the 5.6 inch serial touch screen STVI056WT-01 can draw 8 real time trend lines at the same time, and you can see a nice animation effect after completion. However, there is no detailed description of the Real-time curve control and no video tutorial. All the contents found in the user manual are extracted from Figure 1, Figure 2 and Figure 3 below; the meanings of the parameters extracted from the Real-time curve parameter setting interface of the STONE GUI Designer software platform are shown in Figure 4 – Figure 8.

(Figure 1: Real-time curve control parameter settings)

After choosing to create the Real-time curve control in the software STONE GUI Designer software menu Variable Configuration (D) and setting the parameters, you still need to program the data at each point on the curve using the instructions in Figure 2 to depict the trend of the physical quantity (RPM). Regarding the use of the instruction in Figure 2, the following points need to be noted.

  1. like the 0x82 instruction, two bytes of header and one byte of length are required in front of instruction 0x84.

2, the instruction 0x84 is followed by a byte (8-bit) channel mode, each bit of 1 corresponds to the need to follow the data, and the low channel data in the front, the high channel data in the back, in order.

3, each data are two bytes, is a 16-bit unsigned integer.

4, assuming that the header byte is A5 5A, send 3 points of data to channel 0, the instruction is: A5 5A 08 84 01 00 01 00 02 00 03. where 0x08 is the length of the subsequent, 0x84 after 0x01 means that only the data of channel 0 is sent, the next 0x00 0x01 is the first point data, 0x00 0x02 is the second point data, 0x00 0x03 is the third point data.

5, the instruction to send a point data to channel 3 is: A5 5A 04 84 08 00 A1 . Where 0x04 is the length, 0x08 is the data of channel 3 only, 0x00 0xA1 is the data.

6, to channel 0 and channel 1 at the same time to send a point data instruction is: A5 5A 06 84 03 02 01 04 00. where 0x03 represents channel 0 and channel 1 have data, 0x02 0x01 is the channel 0 data, 0x04 0x00 is the channel 1 data. 

(Figure 2: Real-time curve control data write command)

(Figure 3: Instructions for using the Real-time curve control)

(Figure 4: Real-time curve control’s setup page in STONE GUI Designer software – Y_Central)

(Figure 5: Real-time curve control’s setup page in STONE GUI Designer software – VD_Central)

Y_Central in Figure 4 is the pixel point of the Y-axis origin of the curve from the top of the screen, which specifies the Y-axis reference of the curve for this channel. VD_Central in Figure 5 is the vertical translation of the curve; the larger the value, the more the curve is translated downward.

(Figure 6: Real-time curve control settings page in STONE GUI Designer software – Magnification N)

(Figure 7: Real-time curve control settings page in STONE GUI Designer software – Channel channel)

Regarding the calculation of amplification N in Figure 6, the maximum speed of this project is 640, and the peak of the set curve is 50, taking the translation VD_Central = 0, then N = 256*50/640 = 20. 

(Figure 8: Real-time curve control in STONE GUI Designer software settings page – horizontal interval -X_lattice)

The lateral interval in Figure 8 is important and is what sets the distance between two points in the lateral direction of the curve. In the case of sending data one point at a time, it also determines the speed of the curve’s advance in the X-axis direction. As in Figure 9, when the curve goes to the far right end, it will automatically move left as a whole and the top point will disappear.

(Figure 9: Actual effect of 1 channel of Real-time curve control)

(Figure 10: Actual effect of 2 channels of Real-time curve control)

(Figure 11: Design interface for 2 channels of Real-time curve control)

 

As in Figure 10 and Figure 11, the curves of the two channels should be made into two Real-time curve controls, the top one is channel 0 and the bottom one can be channel 1. The curve data transfer command 0x84 does not require a normal memory address, but is represented by a byte of 8 bits immediately after, each bit represents a channel, bit 1 means that 2 bytes of that bit will be transferred later Data, bit 0, means no transmission. The data is the low channel in front and the high channel in the back.

 

The code demonstrated in the video is as follows:

/*

  frank9

  STONE and arduino COMM, the Real-time Curve play at program..

  Turns on an LED on for one second, then off for one second, repeatedly.The LED tell our that the soft running ok!

  The sample has two curves.The red curve is speed, the yellow curve is power of YanMo!

  

  This example code is in the file of frank.  20210617

 */

 

// 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 iLed2 = 1;            //delay time num.   50ms do a point. 

int iLed3 = 0;            //delay time num.   50ms do a point. 

int iLed4 = 0;            //delay time num.   50ms do a point. 

int iCurve0 = 0;            //The value of curve0.   50ms do a point. 

int iCurve1 = 0;            //The value of curve1,.   50ms do a point. 

int iFlag0 = 1;         // The flag of the curve0 + or -; .1 is up,0 is down.

int iFlag1 = 1;         // The flag of the curve1 + or -; .1 is up,0 is down.

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);  // 打开串口通讯功能等待串口打开

  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 == 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 information sent by the serial port:

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

  

 /*

   save a bak.

   because can have a read key and have a work of key.

   the program is a HMI that a key of input do a work of peplose.

 */ 

 //————————————————————————————

 //—————————-0x0039 key read begin———————————–

  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;   

  iLed2 += 1;         // 50ms do a point.

 // iLed3 += 1;         // 50ms do a point.

 

  

  //——————————————————————————————–

  //———————————50ms do a point begin————————————–

    if (iLed2 == 50)  {  

           iLed2 = 1;

           iLed4 += 1;         // 50ms do a point.  

           

           if(iFlag0 == 1){

                iCurve0 += 1;         // 50ms do a point.  

                if(iCurve0 >= 150){

                    iFlag0 = 0;         // The iCurve0 turn down!. 

                } 

           }

           if(iFlag0 == 0){

                iCurve0 -= 1;         // 50ms do a point.  

                if(iCurve0 <= 1){

                    iFlag0 = 1;         // The iCurve0 turn up!. 

                } 

           }

           

           

           if(iFlag1 == 1){

                if(iLed4 >= 3){

                  iCurve1 += 1;         // 50ms do a point.  

                  iLed4 = 0;

                }

                if(iCurve1 >= 50){

                    iFlag1 = 0;         // The iCurve1 turn down!. 

                } 

           }

           if(iFlag1 == 0){

                if(iLed4 >= 3){

                  iLed4 = 0;

                  iCurve1 -= 1;         // 50ms do a point.  

                }

                if(iCurve1 <= 1){

                    iFlag1 = 1;         // The iCurve1 turn up!. 

                } 

           }

           

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

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

            Serial.write(0x06);

            Serial.write(0x84);      //write to curve!

            Serial.write(0x03);     // The curve path,

            Serial.write(iCurve0);  // N=1,

            Serial.write(0x00);

            Serial.write(iCurve1);

            Serial.write(0x00);            

      

    }

  

  //——————————-50ms do the point end—————————————

  //——————————————————————————————-

  

  

  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(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);

            

  }    

            

}

 

Finally, online debugging.

The STONE GUI Designer software GUI software edited the screen file download, arduino code file upload, connect the power supply, communication, and turn on the machine to observe the real-time speed curve depiction and forward movement to achieve the expected effect.

(online tuning attempts)

LINK

Purchase: https://store.stoneitech.com/

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also

Essentials To Be Included In An Estimate

When creating an estimate, it is important to remember to include all of the essential inf…