1 Introduction
The φ1100mm large-diameter steel pipes, mainly used for oil pipeline laying, are made from plate material after welding. Other auxiliary processes and equipment include an internal slag cleaning machine for cleaning residual welding slag inside the pipe; an internal pipe dust collector; and an external welding slag cleaning machine. This system is the final process, mainly measuring the total weight and length of the steel pipe and storing the data.
2. Principle Design
2.1 Process Overview
The measurement system first uses a traverse trolley to place the steel pipe onto the conveyor rollers. Then, a detection switch sends a signal indicating the steel pipe has reached its position, which is transmitted to the system. A weighing device, located at the bottom of the steel pipe and lifted by a hydraulic cylinder, measures the weight of the pipe entirely by the weighing device. A load cell is installed on each of the left and right sides, and the system communicates with the industrial control computer via an RS232 serial port to transmit the weight value to the host computer. After weighing, the length measuring trolleys start simultaneously from both starting points and move towards each other. When approaching the end face of the steel pipe (signaled by a proximity switch), the trolleys decelerate. Upon reaching the end face, the trolleys stop, and the calculated length of the steel pipe is transmitted to the host computer.
2.2 System Composition
The control system uses proximity switches to collect field signals, which are then fed into a Siemens PLC 7-216 to perform logical operations. The results are output to a Yaskawa SGDM-04ADA drive controller, which in turn drives the measuring carriage via a gear and rack transmission from an SGMAH-04A motor. The drive system consists of two sets, located on opposite sides of the steel pipe, and the carriages move towards each other during operation. A hydraulic system drives the weighing device. The PLC and weighing device communicate serially with a host computer. The host computer software is written in Visual Basic, issuing commands and displaying the steel pipe weight and measured length in real time through a graphical interface. The system hardware consists of a Siemens PLC 6ES7216-2BD22-0XB0, a communication module 6ES7277-0AA22-0XBA, and an expansion module 6ES7223-1HF22-0XA0.
2.3 Working Method
The control system has three operating modes: manual, semi-automatic, and automatic. In manual mode, the measuring carriage and weighing device can be adjusted separately. In semi-automatic mode, the steel pipe can be measured in a single cycle, that is, the weighing and measurement will start when the start button is pressed, and wait for the next start command after the cycle is completed. In automatic mode, the steel pipe is measured continuously until the automatic stop button is pressed.
3 System Implementation
3.1 Sensor Communication Programming
The load cell used is the Zemic BM8H-5T from the USA. It connects to the Shenzhen Jieman Technology Co., Ltd. GM8803A load manager via a GM-JX-V signal distributor. The GM8803A ultimately communicates with the host computer via RS232 serial communication. The communication protocol follows the specifications in the instruction manual: a waveform rate of 9600 kbty, odd parity, 8 data bits, 2 station addresses, and 1 stop bit. The host computer communication protocol program is written in VB according to these specifications as follows:
3.2 Signal Conditioning
The distance traveled by the trolley is fed back by pulses from a rotary encoder and connected to the high-frequency counter terminal of the PLC. The count value indicates the distance traveled by the trolley, with a calculation accuracy of 0.01mm. Since the high-frequency counter used in the project is an ab quadrature input method, only a+, b+, and the common terminal need to be connected to the PLC. However, the servo controller's pulse output is a+a-b+b-z+z-. During debugging, it was found that the high-frequency count value of the PLC was unstable and had a large error, indicating interference. After analysis, it was determined that ab- was the interference source. Therefore, we adopted the circuit shown in Figure 1, using a comparator to compare a+a- and then connecting it to the PLC via a transistor switch. This solved the problem, both increasing the voltage and suppressing interference, achieving excellent results.
3.3 Coding Design
The rotary encoder at the rear of the servo motor has a resolution of 13 bits, or 2048 pulses/revolution. The motor speed is 3000 r/min, and the PLC's maximum capture frequency is 20 kHz. To achieve matching, the driver's PN201 division ratio is set to 400, resulting in 400 pulses/revolution. To further improve accuracy, a resolution of 4 times is used in the PLC, resulting in 1600 pulses/revolution. The distance traveled by each pulse is calculated based on the distance traveled by the motor-driven gears and rack in one revolution, thus yielding the displacement value. The servo system uses a multi-speed control method, with the P-SON, N-CN, and P-CL terminals combined and the following parameters set:
pn000.1 is set to 3 to enable multi-speed control.
Set pn201 to 400 to set the multiplier.
PN50C is set to 8FEA 41 terminal speed 1; 45 terminal speed 2; 46 terminal speed 3.
PN50A is set to ON at terminal 2801CN140; P-CON is invalid; forward rotation is disabled at terminal CN142.
PN50B is set to disable reverse rotation at terminal 8843CN143; alarm cleared at terminal CN144; P-CL and P-NL are invalid.
Setting pn50e to 0000 invalidates the corresponding terminal.
PN50F is set to 000125, and terminals 26 are for torque limit detection.
3.4 PLC Communication Programming
The PLC communicates with the host computer using a free port. The initialization program sets SM30 to 05, meaning each character is 8 bits, there is no parity, the baud rate is 19200, and it's in free port mode. The communication protocol is as follows:
All transmitted data are in the following format:
00h, Total bytes, (data), Checksum, ffh
The total number of bytes includes 00h to ffh, occupying one byte. The checksum is the XOR value of all data before the checksum (including 00h and the total number of bytes), occupying one byte. The following only describes the data bit format.
The number of bytes occupied by the data bits is uncertain, and the format is as follows:
a, (Number of messages sent)
Here, 'a' is a description of the data. If it is a command, then a = 07h; if it is data, then a = 15h. 'a' occupies one byte.
When a=07h, the number of data to be sent occupies one byte. The data description of the number of data to be sent is as follows:
01h - Connecting to a computer
After the equipment starts up, during operation, this command is sent to the computer once before each measurement. The response information sent back by the computer is the same as the data sent by the PLC, that is:
00h, 06h, 07h, 01h, 00h, ffh
If the PLC does not receive a response within 2 seconds after sending this command, it will send it again. If it still does not receive a response within 2 seconds, the PLC will automatically switch to self-storage mode, recording the measured length sequentially in its memory, and will not send another weighing command. If a response is received within 5 seconds, the PLC will first send the record in its memory to the computer, and then resume normal operation (i.e., the PLC will no longer self-storage, but will directly send the length data to the computer and send a weighing command every time it operates).
02h — Weighing command
The computer sends back the same response as the PLC. If no response is received within 2 seconds of sending the command, send it again. If no response is received within 2 seconds, abandon the attempt.
03h - Notification of incoming materials
No reply message
When a=15h, the number of bytes to be sent is undetermined. The data description for the number of bytes to be sent is as follows:
b, (bd1, bd2, bd3,…)
Among them, bd1, bd2, bd3, ... are BCD codes, that is, each byte is a number from 0 to 9, with the most significant byte first.
The explanation for b is shown in Figure 2.
Reply message:
00h, 06h, 15h, 04h, 17h, ffh
If no reply is received within 2 seconds of sending this data, send it again. If no reply is received within 2 seconds, abandon the attempt.
The Siemens S7-200 freeport partial coded communication PLC program is as follows:
The sbr1 subroutine 1 places the received characters into the receive buffer sequentially.
network1
ldsm0.0
incbvb100 receive byte count plus 1
Increment the receive buffer pointer of cdvd86 by 1
movbsmb2, *vd86 stores the received characters into the address pointed to by vd86.
int0
network1
ldb《》smb2,0 if not the starting character 0
creti interrupt return
network2
ldsm0.0movb0, vb100 will clear the receive byte counter vb100.
movd&vb100, vd86 pointer: vd86 points to the starting address of the receive buffer, vb100
callsbr1 stores the start character in the receive buffer (vb101).
atchint1, 8 receives character interrupt connected to int-1
int1
network1
ldsm0.0
callsbr1 stores the number of bytes in the received message data area.
movbsmb2, vb99 stores the number of bytes in the message data area in vb99.
movbvb99, vb90 checksum byte vb90 initialization
atchint2, an 8-character interrupt event connection to interrupt program 2
The interrupt routine for receiving data from the int2 data area.
network1
ldsm0.0
callsbr1 stores the received data into the receive buffer.
xorbsmb2 and vb90 perform a byte-by-byte XOR operation on the data area to calculate the checksum.
Decrement 1 by the decbvb99 data byte counter
network2
The ldsm1.0 zero flag sm1.0 = 1 indicates that vb99 = 0, and reception is complete.
atchint3, 8-character interrupt event connected to interrupt routine 3
int3
network1
If ldb《》vb90, smb2 has a verification error
atchint0,8 restart receiving
creti interrupt return
The NOT message has ended and the verification is successful.
callsbr1
callsbr6
4. Conclusion
This project designed and developed a weighing and measurement system for large-diameter steel pipes using PLC and Visual Basic tools. The system is stable and reliable, with high weighing accuracy and a length measurement accuracy of up to 0.01mm, fully meeting the process requirements. The system has both control and a complete human-machine interface, and has been recognized and praised by users during use.