Description
PFEA113-65 3BSE028144R0065 Data Handling Procedures
PFEA113-65 3BSE028144R0065 A MSComm control, a timer control (Timer1) and two button controls (Command1 and Command2) are designed in Form1. Command1 is the start button, i.e. when pressed, it starts to communicate with PLC and read the data therein, Command2 is the display button, i.e. when pressed, it calls Form2 and displays the waveform curves of each running quantity.
PFEA113-65 3BSE028144R0065 Set the Interval property of Timer1 to be equal to 500, the InputMode property of MSComm to be binary, and the RThreshold property to be equal to 5010. the timer sends the transmit command every 500 milliseconds, and when it is sent for the 26th time, it turns off the timer. At this point the receive buffer will receive 5010 bytes of data and trigger the OnComm event of MSComm. A picture box control (Picture1) is designed in Form2 to display graphics.
PFEA113-65 3BSE028144R0065 In the OnComm event subroutine, the data in the receive buffer is sequentially allocated to the global arrays U_data, If_data, P_data, Q_data, and Ug_data, and then the percentage value is calculated based on the rated value of the respective run. The first 350 bytes of each array need to be adjusted according to the pointer Index by moving the data in the array subscript range Index to 349 to the front and the data in the subscript range 1 to Index-1 to the back.