Professional Documents
Culture Documents
Proceedings of Spie: Data Communication Between Panasonic PLC and PC Using Environment
Proceedings of Spie: Data Communication Between Panasonic PLC and PC Using Environment
SPIEDigitalLibrary.org/conference-proceedings-of-spie
ABSTRACT
With the gradual promotion of Microsoft .NET platform, C# as an object-oriented programming language based on the
platform has been widely used. Therefore, more attention is concentrated on how to achieve the communication between
Panasonic PLC and PC efficiently and fast in C#.NET environment. In this paper, a method of using SerialPort control
which could be used for achieving communication between PLC and PC is introduced. Meanwhile, the reason of
abnormal thread when displayed the receiving data in form is analyzed and the programming method to solve the
problem of thread safety is designed. Achieving the communication of Panasonic PLC and PC in C#.NET environment
can give full play to the advantages of the .NET framework. It is practical, easy communication, high reliability and can
combine with other measurement and calibration procedures effectively and conveniently. Configuration software is
expensive and can only communicate with PLC separately, but these shortcomings can be solved in C#.NET
environment. A well-designed user interface realized real-time monitoring of PLC parameters and achieved management
and control integration. The experiment show that this method of data transfer is accurate and the program’ running is
stable.
Keywords: Panasonic PLC, C#.NET, SerialPort
1. INTRODUCTION
In the process of modern industrial measurement, the integration of measurement and control is the most effective means
to realize industrial automation. In this respect, measuring and testing technology will play a more important role and get
greater development. In the control system, more and more people using PLC as the controller, which is more convenient,
especially in the aspect of position, speed and torque. The Panasonic PLC, with its perfect function, small size and low
price, are increasingly applicated in the modern industry control system[1]. But it also has the disadvantages of poor data
management ability, can’t provide humanized interface etc. Therefore, we need to make up for these shortcomings and
give full play to its performance with the help of communication between PLC and PC. Communication between PC and
PLC is realized in two ways, which are configuration software and high level language. Though configuration software
is convenient, we need to pay the high cost of software, and secondary development is limited. In the software
development industry today, combined the visual operation of VB with the efficiency of C++, C# becomes the preferred
language of .NET development with powerful operation ability and innovative language features[2]. In many
measurement and control system, we need to combine other procedures developed for C# with PLC control, to make the
system not only can collect and store data in time, but also for advanced data processing, to achieve the integration of
measure, control and management and better complete the operation. Therefore, it’s very important to realize the
communication of Panasonic PLC and PC in the C#.NET environment.
Begin
N
Send and receive data
Y
Finish
Fig 1. system flow chart
3.1 Nameplace
The namespace of SerialPort class is SerialPort.IO.Ports. This new framework can not only access to the serial port on
your computer, but also communicate with serial devices. If you want to use SeriaiPort class, you should add “using
Sytem.IO.Ports;” in the front of the program.
3.2 The parameters of the serial port setting
First, you should get the serial port name of the current computer in the form load and display in comboBox control.
string[] portNames = SerialPort.GetPortNames();
False
Control.Invoke.Required
True
This.Invoke(new
SetTextCallback(AppendTextBox),readBuffer)
Finish
Fig 2. implementation schematic
Receive data procedures are as follows:
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
int rslength = 0;
bool loop = true; // Judge whether the data of the receive buffer is all received
SerialPortIsReceiving = true; // the bool type of judge whether the serial port is processing data
try
{
Thread.Sleep(30);
while (loop)
{
if (serialPort1.BytesToRead == rslength)
{
loop = false;
}
else
{
rslength = serialPort1.BytesToRead;
// Get the number of bytes of data in the receive buffer
}
Thread.Sleep(30);
}
serialPort1.Read(readBuffer, 0, rslength); // Read the receive buffer data
serialPort1.DiscardInBuffer();//Clear the receive buffer data
rslength = 0;
AppendTextBox(readBuffer);
}
catch { }
finally
{
SerialPortIsReceiving = false;
}
}
delegate void SetTextCallback(byte[] readBuffer);
4. CONCLUSION
In this paper the author described the communication between Panasonic PLC and PC through the analysis of the
Panasonic PLC communication protocol and the argument of data transmission process of SerialPort controls. In this
method designed a good application software platform to control Renishaw XL-80 interferometer and Panasonic
FPGC32TH model PLC in the laser tracker calibration device. By that the correctness and reliability of communication
design method proposed in this paper have been verified.
REFERENCES
[1] Wang Huatang. Application of Japan's Panasonic PLC. Modern Business Trade Industry. Papers 9, 350-
351(2008)
[2] Wang Wenquan. Implementation of Serial Port Communication System Based on SerialPort. Science and
technology square. Papers 5, 21-23(2011)
[3] Panasonic Programmable Controller FPΣ User's Manual [S]
[4] Li Deqi. C # Programming [M]. Beijing: Science Publishers, 2005.
[5] PENG Wei. Serial Communication Programming of Thread-safe Based on .NET Platform,Journal of Hubei
University of Technology, Papers 27(2), 34-39(2012)