Do you give me some concept to do it? I use s7.net lib to communicate between PLC and myPC
Plc plc = null;
plc = new Plc(CpuType.S71200, "192.168.0.1", 0, 1);
public initPLC()
{
try
{
plc.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public void setTimer(double value)
{
aTimer = new System.Timers.Timer(value);
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = true;
}
private void OnTimedEvent(Object source, ElapsedEventArgs e)
{
if (plc.IsConnected)
{
RefreshValue();
}
}
private void RefreshValue()
{
ushort value1 = 0;
ushort value2 = 0;
bool[] tagArr = { false, false, false, false };
try
{
value1 = (ushort)plc.Read("DB4.DBW0"); //value1
tagArr[0] = true;
}
catch (Exception)
{
tagArr[0] = false;
}
//func
try
{
value2 = (ushort)plc.Read("DB4.DBW2"); //value2
tagArr[1] = true;
}
catch (Exception)
{
tagArr[1] = false;
}
try
{
bool _bit = (bool)plc.Read(DataType.Input, 0, 0, VarType.Bit, 1);
}
catch (Exception)
{
}
}
Let me tell you, this rate of data isn´t possible by direct reading your plc. The best rate I think you can read direct by your PLC is something about 10~20ms. For high speed monitoring data, you must need a specific DAQ module.