chandra pal

chandra pal

  • NA
  • 85
  • 4k

C# connection with Mitsubishi PLC

Mar 30 2018 6:07 AM

Hi all, I am using Q series PLC, connected to PC with MxComponent software.It is connecting successfully when we open the application and after 50 to 60 minutes and it does not reconnect again...

To connect again we need to close the application and reopen. Please help on this, I am also giving the code here to connect.Please help on this. Thanks in advance.

Code Here

private bool PGetIntValue(int lptxt_SourceOfIntValue, out int iGottenIntValue)
{
iGottenIntValue = 0;
//Get the value as 32bit integer from a TextBox
try
{
iGottenIntValue = Convert.ToInt32(lptxt_SourceOfIntValue);
}

//When the value is nothing or out of the range, the exception is processed.
catch (Exception exExcepion)
{
MessageBox.Show(exExcepion.Message,
Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}

//Normal End
return true;
}

private void PLCconnect()
{
int iReturnCode;
int iLogicalStationNumber;
if (PGetIntValue(1, out iLogicalStationNumber) != true)
{
return;
}
axActUtlType1.ActLogicalStationNumber = iLogicalStationNumber;
// axActUtlType1.ActPassword = txt_Password.Text
iReturnCode = axActUtlType1.Open();
if (iReturnCode == 0)
{
//Connected
lblStatus.Text = "Connected";
lblStatus.ForeColor = Color.Green;
}
else
{
//Not Connected
lblStatus.Text = "Not Connected";
lblStatus.ForeColor = Color.Red;
}
}