Emm Emm -4 years ago 621
C# Question

How to link Beckhoff TwinCAT 3 to a Visual Studio HMI created in C#?

I am quite new in TwinCAT 3 and .NET framework. I am trying just to create an HMI with a button and link it to a variable in TwinCAT 3. I am controlling by TwinCAT 3 a Beckhoff output card (EL2014) so I have created the following variable named "Out_1" and linked it to one card output:

Variable configuration

Variable properties:

enter image description here

The code of the button is:

private void button1_Click(object sender, EventArgs e)
{
TwinCAT.Ads.TcAdsClient tcAds = new TwinCAT.Ads.TcAdsClient();
tcAds.Connect(301);

tcAds.WriteSymbol("TIRT.Task 2.Outputs.Out1", true,
reloadSymbolInfo: true);
}


The following message is appearing:

Additional information: Ads-Error 0x710 : Symbol could not be found.

The symbol name used to access de variable is not correct and I don't really know how may I write it.

Does anyone know how can I access this variable?

Thank you very much.

Answer Source

If you leave out the "TIRT" it will work, eg "Task 2.Outputs.Out1".

Be sure that "Create Symbols" is checked when you double click on the task:enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download