Description
5X00119G01 Communication Subroutine
The 5X00119G01 communication subroutine is responsible for communicating with the host computer and transmitting the fault data stored in the data area to the host computer in batches through the serial port. Every time the host computer sends a transmission command (represented by the integer 255), the PLC determines whether the received character is a transmission command in the receive interrupt procedure, and if it is, it sets the transmission command flag M6.0 and calls the communication subroutine in the main procedure.
5X00119G01 Define the pointer tran_pointer to point to the first address of the data to be transmitted, its initial value is &VW4000, i.e., it points to the first address of the data area. Define the variable count to record the number of transmissions. In the communication subroutine, firstly, the reception of the free port is stopped, and then the data of 200 bytes with the pointer tran_pointer as the first address is transferred to the send buffer, and then it is sent out through the serial port with the send command.
Every time the 5X00119G01 sends data, the pointer tran_pointer is moved down 200 bytes, the variable count value is added 1, and M6.0 is reset. When the host computer sends out the 26th transmission command, the 5000 bytes of the data area VW4000 ~ VW8998 in the PLC have been sent out, and then the rated voltage, rated current, rated active power, rated reactive power, and the pointer index are sent out, the count value is cleared to zero, and the pointer tran_pointer is re-initialised, and the M6.0 is reset. At this point, a complete fault data transmission process is over.