Ty Chris,
Pretty sure it is not overwritting it.
Im out for the afternoon, but will double check tonite.

Will keep you informed.

Best regards

Get Outlook for Android<https://aka.ms/ghei36>

________________________________

Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer
462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com
From: Christofer Dutz <[email protected]>
Sent: Sunday, February 14, 2021, 10:58 AM
To: [email protected]
Subject: AW: TwinCAT ADS - Write value to PLC

Hi Patrick,

I thought I had tested writing of values via ADS … will re-test.

But when writing you have to be sure the PLC doesn’t overwrite this value 
internally.
I remember when I tried „overriding“ outputs of PLCs with a written value. In 
the end it turned out that the value was overwritten, but the PLC program just 
set it to it’s original value as part of the program execution.

Chris


Von: Patrick Boisclair <[email protected]>
Gesendet: Sonntag, 14. Februar 2021 16:26
An: [email protected]
Betreff: TwinCAT ADS - Write value to PLC

Hi all,

I’m using the TwinCAT ads driver with the 0.8.0 realease of PLC4X. I can read 
all the values from the PLC without issue, but writing doesn’t seem to work.
I don’t know what Im doing wrong.

Here is the writing code:
        PlcDriverManager driver = new PlcDriverManager();
        try {
            PlcConnection plcConnection = driver.getConnection(
                    
"ads:tcp://10.10.11.77?sourceAmsNetId=172.29.64.1.1.1&sourceAmsPort=32&targetAmsNetId=5.62.206.200.1.1&targetAmsPort=851");



    if (!plcConnection.getMetadata().canWrite()) {
      return;
    }


  PlcWriteRequest.Builder builder = plcConnection.writeRequestBuilder();
          builder.addItem("lightToggle", "MAIN.E_Lum_1:BOOL", true);
          PlcWriteRequest request = builder.build();

          request.execute().whenComplete((response, exception) -> {

            if (exception == null)
              System.out.println("WRITING DONE....");
            else
              exception.printStackTrace();
          });

If I change the “MAIN.E_Lum_1:BOOL” to a value that doesn’t exists I get a 
error saying me the name is invalid which is fine and tells me its really 
communicating with the PLC.

Now, when using the good name, I don’t get an exception and I see thee “WRITING 
DONE…” in the console. However, the value is unchanged in the Beckhoff PLC.

Is there anything I don’t understand ??
Thank you very much !!!


Here’s the Beckhoff PLC setup:
[cid:[email protected]]
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer
[cid:[email protected]]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>


Reply via email to