You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by Patrick Boisclair <pb...@noovelia.com> on 2021/02/14 15:25:48 UTC

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:image001.png@01D702BB.1A317DF0]

Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer
462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com

RE: TwinCAT ADS - Write value to PLC

Posted by Patrick Boisclair <pb...@noovelia.com>.
Chris, here is what I found…
On the PLC Program, the value I was using was declared like this:

E_Lum_1 AT %I*:BOOL;                 --> NOTICE THE “AT %I*”

Now, I tried:

E_Lum_1:BOOL;

And all the sudden, everything works just fine. Here’s a JPEG of the UI (kafka consumer). Data is provided by a back-end app and PLC4X (of course) and producing the data into Kafka.

A big thank you for everything !




Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer
462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com
From: Patrick Boisclair <pb...@noovelia.com>
Sent: Monday, February 15, 2021 9:13 PM
To: dev@plc4x.apache.org; Christofer Dutz <ch...@c-ware.de>
Subject: RE: TwinCAT ADS - Write value to PLC

Hi Chris, ty you very much for your time and the video you provided.

I did the same thing as you and I’m seeing the exact same behavior.
When I stop the PLC program, I can see the value changing.

Again, ty you very much for your time. It is greatly appreciated.

Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer
[cid:image913998.png@35411A9F.F1F1AC50]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>
From: Patrick Boisclair <pb...@noovelia.com>>
Sent: Monday, February 15, 2021 3:04 PM
To: Christofer Dutz <ch...@c-ware.de>>; dev@plc4x.apache.org<ma...@plc4x.apache.org>
Subject: Re: TwinCAT ADS - Write value to PLC

Ty you very much Chris.
I’ll double check tonite or tomorrow morning.
Really appreciated !

Get Outlook for Android<https://aka.ms/ghei36>
________________________________
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer
[cid:image928764.png@8059E7F9.192FCCE8]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>
From: Christofer Dutz <ch...@c-ware.de>>
Sent: Monday, February 15, 2021 2:07:55 PM
To: dev@plc4x.apache.org<ma...@plc4x.apache.org> <de...@plc4x.apache.org>>; Patrick Boisclair <pb...@noovelia.com>>
Subject: AW: TwinCAT ADS - Write value to PLC

And I just did another check ...

I simply commented out the line in my program, wehre I explicitly set the value oft he variable and I could change it from the driver even in run mode. I did also set a breakpoint in the initialization code I had and I had the PLC stop on every cycle.

So @Patrick Boisclair please double check you are not simply overwriting the values again like I was.


Chris



-----Ursprüngliche Nachricht-----
Von: Christofer Dutz <ch...@c-ware.de>>
Gesendet: Montag, 15. Februar 2021 19:51
An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
Betreff: AW: TwinCAT ADS - Write value to PLC

Ok ... that was a quick one ...

I think I solved the mystery :-) ...

The driver is actually doing what it should and seems to be doing it correctly.
I tried my test again, but having stopped the PLC programm. I did that cause I wanted to prevent the value being overwritten by any form of PLC program.

And as soon as I stopped the program execution, I could see the watch expressions I had setup change their value as expected.

In my case I setup a predefined set of variables to pre-defined values in order to run some manually executed tests against the device.
I think this initialization is run for every CPU cycle and hereby overwriting the changes the driver is sending.

Here a little video: https://drive.google.com/file/d/12e0Q4ewf8rIdPFcNYscH7xq5j_6RxAGY/view?usp=sharing

Hope this helps,
      Chris



-----Ursprüngliche Nachricht-----
Von: Christofer Dutz <ch...@c-ware.de>>
Gesendet: Montag, 15. Februar 2021 19:41
An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
Betreff: AW: TwinCAT ADS - Write value to PLC

Hi all,

so I just setup the example and my Beckhoff PLC.
I can confirm that the value doesn’t change in the PLC. I used wireshark to inspect the communication between the driver and the PLC and the response to my write request is:

Frame 41: 96 bytes on wire (768 bits), 96 bytes captured (768 bits) on interface \Device\NPF_{7F615F1B-E091-421F-850E-2BC9EEC3A622}, id 0 Ethernet II, Src: Beckhoff_13:6a:a0 (00:01:05:13:6a:a0), Dst: GopodGro_02:d2:c7 (48:65:ee:12:d2:c7) Internet Protocol Version 4, Src: 192.168.23.20, Dst: 192.168.23.200 Transmission Control Protocol, Src Port: 48898, Dst Port: 50301, Seq: 51, Ack: 121, Len: 42 AMS
    AMS Target Net Id: 192.168.23.200.1.1
    AMS Target port: 65534
    AMS Sender Net Id: 192.168.23.20.1.1
    AMS Sender port: 851
    CmdId: ADS Write (3)
    StateFlags: 0x0005
        .... .... .... ...1 = RESPONSE: Set
        .... .... .... ..0. = NO RETURN: Not set
        .... .... .... .1.. = ADS COMMAND: Set
        .... .... .... 0... = SYSTEM COMMAND: Not set
        .... .... ...0 .... = HIGH PRIORITY COMMAND: Not set
        .... .... ..0. .... = TIMESTAMP ADDED: Not set
        .... .... .0.. .... = UDP COMMAND: Not set
        .... .... 0... .... = INIT COMMAND: Not set
        0... .... .... .... = BROADCAST: Not set
    cbData: 4
    ErrorCode: NO ERROR (0x00000000)
    InvokeId: 0x00000002
    ADS Write Response
        Result: NO ERROR (0x00000000)

So from a protocol point of view it actually accepted the request and at least said that it processed it correctly.
I’ll check if my demo program might be setup wrong.

Chris



Von: Patrick Boisclair <pb...@noovelia.com>>
Gesendet: Montag, 15. Februar 2021 19:16
An: Łukasz Dywicki <lu...@code-house.org>>; dev@plc4x.apache.org<ma...@plc4x.apache.org>
Betreff: RE: TwinCAT ADS - Write value to PLC

Hi Lukasz,

I tried a single write, no luck ☹

Ty for your feedback
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer [cid:image199837.png@8952B63E.E11BC000]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA noovelia.com<https://www.noovelia.com/>
-----Original Message-----
From: Łukasz Dywicki <lu...@code-house.org>>>
Sent: Monday, February 15, 2021 5:06 AM
To: dev@plc4x.apache.org<ma...@plc4x.apache.org>>; Patrick Boisclair <pb...@noovelia.com>>>
Subject: Re: TwinCAT ADS - Write value to PLC

I have one report from openHAB community that it is possible to write BOOL value just once, second and every next write does not pass. It does not even show up any traffic in Wireshark. I haven't confirmed cause yet.

I have not completed setting wiring and program for tests with CX (TC2) I got. I already found there is a trouble with reading of symbol table
(SYM_UPLOADINFO2) due to new IEC decoder. It seems that it attempts to read more than is available in underlying response from PLC.

Best,
Łukasz

On 15.02.2021 01:11, Patrick Boisclair wrote:
> Hi Chris,
>
>
>
> I double checked and the value I’m trying to write is most definitely
> not being overridden.
>
> I have tried with TwinCAT (within Visual Studio) and changed the value
> and it worked while the PLC program was running.
>
>
>
> If you need more info or input, just let me know.
>
>
>
> Ty very much
>
>
>
> Patrick Boisclair​
>
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
>
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> *noovelia.com* <https://www.noovelia.com/>
>
> *From:*Patrick Boisclair
> <pb...@noovelia.com>>>
> *Sent:* February 14, 2021 12:02 PM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>>
> *Subject:* Re: TwinCAT ADS - Write value to PLC
>
>
>
> 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* <https://www.noovelia.com/>
>
> ----------------------------------------------------------------------
> --
>
> *From:* Christofer Dutz
> <ch...@c-ware.de>>>
> *Sent:* Sunday, February 14, 2021, 10:58 AM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>>
> *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
> <pb...@noovelia.com>>>
> Gesendet: Sonntag, 14. Februar 2021 16:26
> An: dev@plc4x.apache.org<ma...@plc4x.apache.org>>
> 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:image001.png@01D702BB.1A317DF0]
> Patrick Boisclair​
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
> [cid:image185694.png@BDFA11CA.E2C7D002]
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> noovelia.com<https://www.noovelia.com/
<https://www.noovelia.com/%0b>> <https://www.noovelia.com/<https://www.noovelia.com/%20%3chttps:/www.n
<https://www.noovelia.com/%3chttps:/www.noovelia.com/%20%3chttps:/www.n%0b>> oovelia.com/>>>
>
>
>

RE: TwinCAT ADS - Write value to PLC

Posted by Patrick Boisclair <pb...@noovelia.com>.
Hi Chris, ty you very much for your time and the video you provided.

I did the same thing as you and I’m seeing the exact same behavior.
When I stop the PLC program, I can see the value changing.

Again, ty you very much for your time. It is greatly appreciated.


Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer
462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com
From: Patrick Boisclair <pb...@noovelia.com>
Sent: Monday, February 15, 2021 3:04 PM
To: Christofer Dutz <ch...@c-ware.de>; dev@plc4x.apache.org
Subject: Re: TwinCAT ADS - Write value to PLC

Ty you very much Chris.
I’ll double check tonite or tomorrow morning.
Really appreciated !

Get Outlook for Android<https://aka.ms/ghei36>
________________________________
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer
[cid:image928764.png@8059E7F9.192FCCE8]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>
From: Christofer Dutz <ch...@c-ware.de>>
Sent: Monday, February 15, 2021 2:07:55 PM
To: dev@plc4x.apache.org<ma...@plc4x.apache.org> <de...@plc4x.apache.org>>; Patrick Boisclair <pb...@noovelia.com>>
Subject: AW: TwinCAT ADS - Write value to PLC

And I just did another check ...

I simply commented out the line in my program, wehre I explicitly set the value oft he variable and I could change it from the driver even in run mode. I did also set a breakpoint in the initialization code I had and I had the PLC stop on every cycle.

So @Patrick Boisclair please double check you are not simply overwriting the values again like I was.


Chris



-----Ursprüngliche Nachricht-----
Von: Christofer Dutz <ch...@c-ware.de>>
Gesendet: Montag, 15. Februar 2021 19:51
An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
Betreff: AW: TwinCAT ADS - Write value to PLC

Ok ... that was a quick one ...

I think I solved the mystery :-) ...

The driver is actually doing what it should and seems to be doing it correctly.
I tried my test again, but having stopped the PLC programm. I did that cause I wanted to prevent the value being overwritten by any form of PLC program.

And as soon as I stopped the program execution, I could see the watch expressions I had setup change their value as expected.

In my case I setup a predefined set of variables to pre-defined values in order to run some manually executed tests against the device.
I think this initialization is run for every CPU cycle and hereby overwriting the changes the driver is sending.

Here a little video: https://drive.google.com/file/d/12e0Q4ewf8rIdPFcNYscH7xq5j_6RxAGY/view?usp=sharing

Hope this helps,
      Chris



-----Ursprüngliche Nachricht-----
Von: Christofer Dutz <ch...@c-ware.de>>
Gesendet: Montag, 15. Februar 2021 19:41
An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
Betreff: AW: TwinCAT ADS - Write value to PLC

Hi all,

so I just setup the example and my Beckhoff PLC.
I can confirm that the value doesn’t change in the PLC. I used wireshark to inspect the communication between the driver and the PLC and the response to my write request is:

Frame 41: 96 bytes on wire (768 bits), 96 bytes captured (768 bits) on interface \Device\NPF_{7F615F1B-E091-421F-850E-2BC9EEC3A622}, id 0 Ethernet II, Src: Beckhoff_13:6a:a0 (00:01:05:13:6a:a0), Dst: GopodGro_02:d2:c7 (48:65:ee:12:d2:c7) Internet Protocol Version 4, Src: 192.168.23.20, Dst: 192.168.23.200 Transmission Control Protocol, Src Port: 48898, Dst Port: 50301, Seq: 51, Ack: 121, Len: 42 AMS
    AMS Target Net Id: 192.168.23.200.1.1
    AMS Target port: 65534
    AMS Sender Net Id: 192.168.23.20.1.1
    AMS Sender port: 851
    CmdId: ADS Write (3)
    StateFlags: 0x0005
        .... .... .... ...1 = RESPONSE: Set
        .... .... .... ..0. = NO RETURN: Not set
        .... .... .... .1.. = ADS COMMAND: Set
        .... .... .... 0... = SYSTEM COMMAND: Not set
        .... .... ...0 .... = HIGH PRIORITY COMMAND: Not set
        .... .... ..0. .... = TIMESTAMP ADDED: Not set
        .... .... .0.. .... = UDP COMMAND: Not set
        .... .... 0... .... = INIT COMMAND: Not set
        0... .... .... .... = BROADCAST: Not set
    cbData: 4
    ErrorCode: NO ERROR (0x00000000)
    InvokeId: 0x00000002
    ADS Write Response
        Result: NO ERROR (0x00000000)

So from a protocol point of view it actually accepted the request and at least said that it processed it correctly.
I’ll check if my demo program might be setup wrong.

Chris



Von: Patrick Boisclair <pb...@noovelia.com>>
Gesendet: Montag, 15. Februar 2021 19:16
An: Łukasz Dywicki <lu...@code-house.org>>; dev@plc4x.apache.org<ma...@plc4x.apache.org>
Betreff: RE: TwinCAT ADS - Write value to PLC

Hi Lukasz,

I tried a single write, no luck ☹

Ty for your feedback
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer [cid:image199837.png@8952B63E.E11BC000]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA noovelia.com<https://www.noovelia.com/>
-----Original Message-----
From: Łukasz Dywicki <lu...@code-house.org>>>
Sent: Monday, February 15, 2021 5:06 AM
To: dev@plc4x.apache.org<ma...@plc4x.apache.org>>; Patrick Boisclair <pb...@noovelia.com>>>
Subject: Re: TwinCAT ADS - Write value to PLC

I have one report from openHAB community that it is possible to write BOOL value just once, second and every next write does not pass. It does not even show up any traffic in Wireshark. I haven't confirmed cause yet.

I have not completed setting wiring and program for tests with CX (TC2) I got. I already found there is a trouble with reading of symbol table
(SYM_UPLOADINFO2) due to new IEC decoder. It seems that it attempts to read more than is available in underlying response from PLC.

Best,
Łukasz

On 15.02.2021 01:11, Patrick Boisclair wrote:
> Hi Chris,
>
>
>
> I double checked and the value I’m trying to write is most definitely
> not being overridden.
>
> I have tried with TwinCAT (within Visual Studio) and changed the value
> and it worked while the PLC program was running.
>
>
>
> If you need more info or input, just let me know.
>
>
>
> Ty very much
>
>
>
> Patrick Boisclair​
>
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
>
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> *noovelia.com* <https://www.noovelia.com/>
>
> *From:*Patrick Boisclair
> <pb...@noovelia.com>>>
> *Sent:* February 14, 2021 12:02 PM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>>
> *Subject:* Re: TwinCAT ADS - Write value to PLC
>
>
>
> 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* <https://www.noovelia.com/>
>
> ----------------------------------------------------------------------
> --
>
> *From:* Christofer Dutz
> <ch...@c-ware.de>>>
> *Sent:* Sunday, February 14, 2021, 10:58 AM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>>
> *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
> <pb...@noovelia.com>>>
> Gesendet: Sonntag, 14. Februar 2021 16:26
> An: dev@plc4x.apache.org<ma...@plc4x.apache.org>>
> 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:image001.png@01D702BB.1A317DF0]
> Patrick Boisclair​
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
> [cid:image185694.png@BDFA11CA.E2C7D002]
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> noovelia.com<https://www.noovelia.com/
<https://www.noovelia.com/%0b>> <https://www.noovelia.com/<https://www.noovelia.com/%20%3chttps:/www.n
<https://www.noovelia.com/%3chttps:/www.noovelia.com/%20%3chttps:/www.n%0b>> oovelia.com/>>>
>
>
>

Re: TwinCAT ADS - Write value to PLC

Posted by Patrick Boisclair <pb...@noovelia.com>.
Ty you very much Chris.
I’ll double check tonite or tomorrow morning.
Really appreciated !

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 <ch...@c-ware.de>
Sent: Monday, February 15, 2021 2:07:55 PM
To: dev@plc4x.apache.org <de...@plc4x.apache.org>; Patrick Boisclair <pb...@noovelia.com>
Subject: AW: TwinCAT ADS - Write value to PLC

And I just did another check ...

I simply commented out the line in my program, wehre I explicitly set the value oft he variable and I could change it from the driver even in run mode. I did also set a breakpoint in the initialization code I had and I had the PLC stop on every cycle.

So @Patrick Boisclair please double check you are not simply overwriting the values again like I was.


Chris



-----Ursprüngliche Nachricht-----
Von: Christofer Dutz <ch...@c-ware.de>
Gesendet: Montag, 15. Februar 2021 19:51
An: dev@plc4x.apache.org
Betreff: AW: TwinCAT ADS - Write value to PLC

Ok ... that was a quick one ...

I think I solved the mystery :-) ...

The driver is actually doing what it should and seems to be doing it correctly.
I tried my test again, but having stopped the PLC programm. I did that cause I wanted to prevent the value being overwritten by any form of PLC program.

And as soon as I stopped the program execution, I could see the watch expressions I had setup change their value as expected.

In my case I setup a predefined set of variables to pre-defined values in order to run some manually executed tests against the device.
I think this initialization is run for every CPU cycle and hereby overwriting the changes the driver is sending.

Here a little video: https://drive.google.com/file/d/12e0Q4ewf8rIdPFcNYscH7xq5j_6RxAGY/view?usp=sharing

Hope this helps,
      Chris



-----Ursprüngliche Nachricht-----
Von: Christofer Dutz <ch...@c-ware.de>
Gesendet: Montag, 15. Februar 2021 19:41
An: dev@plc4x.apache.org
Betreff: AW: TwinCAT ADS - Write value to PLC

Hi all,

so I just setup the example and my Beckhoff PLC.
I can confirm that the value doesn’t change in the PLC. I used wireshark to inspect the communication between the driver and the PLC and the response to my write request is:

Frame 41: 96 bytes on wire (768 bits), 96 bytes captured (768 bits) on interface \Device\NPF_{7F615F1B-E091-421F-850E-2BC9EEC3A622}, id 0 Ethernet II, Src: Beckhoff_13:6a:a0 (00:01:05:13:6a:a0), Dst: GopodGro_02:d2:c7 (48:65:ee:12:d2:c7) Internet Protocol Version 4, Src: 192.168.23.20, Dst: 192.168.23.200 Transmission Control Protocol, Src Port: 48898, Dst Port: 50301, Seq: 51, Ack: 121, Len: 42 AMS
    AMS Target Net Id: 192.168.23.200.1.1
    AMS Target port: 65534
    AMS Sender Net Id: 192.168.23.20.1.1
    AMS Sender port: 851
    CmdId: ADS Write (3)
    StateFlags: 0x0005
        .... .... .... ...1 = RESPONSE: Set
        .... .... .... ..0. = NO RETURN: Not set
        .... .... .... .1.. = ADS COMMAND: Set
        .... .... .... 0... = SYSTEM COMMAND: Not set
        .... .... ...0 .... = HIGH PRIORITY COMMAND: Not set
        .... .... ..0. .... = TIMESTAMP ADDED: Not set
        .... .... .0.. .... = UDP COMMAND: Not set
        .... .... 0... .... = INIT COMMAND: Not set
        0... .... .... .... = BROADCAST: Not set
    cbData: 4
    ErrorCode: NO ERROR (0x00000000)
    InvokeId: 0x00000002
    ADS Write Response
        Result: NO ERROR (0x00000000)

So from a protocol point of view it actually accepted the request and at least said that it processed it correctly.
I’ll check if my demo program might be setup wrong.

Chris



Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Montag, 15. Februar 2021 19:16
An: Łukasz Dywicki <lu...@code-house.org>; dev@plc4x.apache.org
Betreff: RE: TwinCAT ADS - Write value to PLC

Hi Lukasz,

I tried a single write, no luck ☹

Ty for your feedback
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer [cid:image199837.png@8952B63E.E11BC000]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA noovelia.com<https://www.noovelia.com/>
-----Original Message-----
From: Łukasz Dywicki <lu...@code-house.org>>
Sent: Monday, February 15, 2021 5:06 AM
To: dev@plc4x.apache.org<ma...@plc4x.apache.org>; Patrick Boisclair <pb...@noovelia.com>>
Subject: Re: TwinCAT ADS - Write value to PLC

I have one report from openHAB community that it is possible to write BOOL value just once, second and every next write does not pass. It does not even show up any traffic in Wireshark. I haven't confirmed cause yet.

I have not completed setting wiring and program for tests with CX (TC2) I got. I already found there is a trouble with reading of symbol table
(SYM_UPLOADINFO2) due to new IEC decoder. It seems that it attempts to read more than is available in underlying response from PLC.

Best,
Łukasz

On 15.02.2021 01:11, Patrick Boisclair wrote:
> Hi Chris,
>
>
>
> I double checked and the value I’m trying to write is most definitely
> not being overridden.
>
> I have tried with TwinCAT (within Visual Studio) and changed the value
> and it worked while the PLC program was running.
>
>
>
> If you need more info or input, just let me know.
>
>
>
> Ty very much
>
>
>
> Patrick Boisclair​
>
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
>
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> *noovelia.com* <https://www.noovelia.com/>
>
> *From:*Patrick Boisclair
> <pb...@noovelia.com>>
> *Sent:* February 14, 2021 12:02 PM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>
> *Subject:* Re: TwinCAT ADS - Write value to PLC
>
>
>
> 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* <https://www.noovelia.com/>
>
> ----------------------------------------------------------------------
> --
>
> *From:* Christofer Dutz
> <ch...@c-ware.de>>
> *Sent:* Sunday, February 14, 2021, 10:58 AM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>
> *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
> <pb...@noovelia.com>>
> Gesendet: Sonntag, 14. Februar 2021 16:26
> An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
> 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:image001.png@01D702BB.1A317DF0]
> Patrick Boisclair​
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
> [cid:image185694.png@BDFA11CA.E2C7D002]
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> noovelia.com<https://www.noovelia.com/
> <https://www.noovelia.com/<https://www.noovelia.com/%20%3chttps:/www.n
> oovelia.com/>>>
>
>
>

AW: TwinCAT ADS - Write value to PLC

Posted by Christofer Dutz <ch...@c-ware.de>.
And I just did another check ...

I simply commented out the line in my program, wehre I explicitly set the value oft he variable and I could change it from the driver even in run mode. I did also set a breakpoint in the initialization code I had and I had the PLC stop on every cycle.

So @Patrick Boisclair please double check you are not simply overwriting the values again like I was.


Chris



-----Ursprüngliche Nachricht-----
Von: Christofer Dutz <ch...@c-ware.de> 
Gesendet: Montag, 15. Februar 2021 19:51
An: dev@plc4x.apache.org
Betreff: AW: TwinCAT ADS - Write value to PLC

Ok ... that was a quick one ...

I think I solved the mystery :-) ... 

The driver is actually doing what it should and seems to be doing it correctly.
I tried my test again, but having stopped the PLC programm. I did that cause I wanted to prevent the value being overwritten by any form of PLC program.

And as soon as I stopped the program execution, I could see the watch expressions I had setup change their value as expected.

In my case I setup a predefined set of variables to pre-defined values in order to run some manually executed tests against the device.
I think this initialization is run for every CPU cycle and hereby overwriting the changes the driver is sending.

Here a little video: https://drive.google.com/file/d/12e0Q4ewf8rIdPFcNYscH7xq5j_6RxAGY/view?usp=sharing

Hope this helps,
      Chris



-----Ursprüngliche Nachricht-----
Von: Christofer Dutz <ch...@c-ware.de>
Gesendet: Montag, 15. Februar 2021 19:41
An: dev@plc4x.apache.org
Betreff: AW: TwinCAT ADS - Write value to PLC

Hi all,

so I just setup the example and my Beckhoff PLC.
I can confirm that the value doesn’t change in the PLC. I used wireshark to inspect the communication between the driver and the PLC and the response to my write request is:

Frame 41: 96 bytes on wire (768 bits), 96 bytes captured (768 bits) on interface \Device\NPF_{7F615F1B-E091-421F-850E-2BC9EEC3A622}, id 0 Ethernet II, Src: Beckhoff_13:6a:a0 (00:01:05:13:6a:a0), Dst: GopodGro_02:d2:c7 (48:65:ee:12:d2:c7) Internet Protocol Version 4, Src: 192.168.23.20, Dst: 192.168.23.200 Transmission Control Protocol, Src Port: 48898, Dst Port: 50301, Seq: 51, Ack: 121, Len: 42 AMS
    AMS Target Net Id: 192.168.23.200.1.1
    AMS Target port: 65534
    AMS Sender Net Id: 192.168.23.20.1.1
    AMS Sender port: 851
    CmdId: ADS Write (3)
    StateFlags: 0x0005
        .... .... .... ...1 = RESPONSE: Set
        .... .... .... ..0. = NO RETURN: Not set
        .... .... .... .1.. = ADS COMMAND: Set
        .... .... .... 0... = SYSTEM COMMAND: Not set
        .... .... ...0 .... = HIGH PRIORITY COMMAND: Not set
        .... .... ..0. .... = TIMESTAMP ADDED: Not set
        .... .... .0.. .... = UDP COMMAND: Not set
        .... .... 0... .... = INIT COMMAND: Not set
        0... .... .... .... = BROADCAST: Not set
    cbData: 4
    ErrorCode: NO ERROR (0x00000000)
    InvokeId: 0x00000002
    ADS Write Response
        Result: NO ERROR (0x00000000)

So from a protocol point of view it actually accepted the request and at least said that it processed it correctly.
I’ll check if my demo program might be setup wrong.

Chris



Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Montag, 15. Februar 2021 19:16
An: Łukasz Dywicki <lu...@code-house.org>; dev@plc4x.apache.org
Betreff: RE: TwinCAT ADS - Write value to PLC

Hi Lukasz,

I tried a single write, no luck ☹

Ty for your feedback
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer [cid:image199837.png@8952B63E.E11BC000]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA noovelia.com<https://www.noovelia.com/>
-----Original Message-----
From: Łukasz Dywicki <lu...@code-house.org>>
Sent: Monday, February 15, 2021 5:06 AM
To: dev@plc4x.apache.org<ma...@plc4x.apache.org>; Patrick Boisclair <pb...@noovelia.com>>
Subject: Re: TwinCAT ADS - Write value to PLC

I have one report from openHAB community that it is possible to write BOOL value just once, second and every next write does not pass. It does not even show up any traffic in Wireshark. I haven't confirmed cause yet.

I have not completed setting wiring and program for tests with CX (TC2) I got. I already found there is a trouble with reading of symbol table
(SYM_UPLOADINFO2) due to new IEC decoder. It seems that it attempts to read more than is available in underlying response from PLC.

Best,
Łukasz

On 15.02.2021 01:11, Patrick Boisclair wrote:
> Hi Chris,
>
>
>
> I double checked and the value I’m trying to write is most definitely 
> not being overridden.
>
> I have tried with TwinCAT (within Visual Studio) and changed the value 
> and it worked while the PLC program was running.
>
>
>
> If you need more info or input, just let me know.
>
>
>
> Ty very much
>
>
>
> Patrick Boisclair​
>
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
>
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> *noovelia.com* <https://www.noovelia.com/>
>
> *From:*Patrick Boisclair
> <pb...@noovelia.com>>
> *Sent:* February 14, 2021 12:02 PM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>
> *Subject:* Re: TwinCAT ADS - Write value to PLC
>
>
>
> 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* <https://www.noovelia.com/>
>
> ----------------------------------------------------------------------
> --
>
> *From:* Christofer Dutz
> <ch...@c-ware.de>>
> *Sent:* Sunday, February 14, 2021, 10:58 AM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>
> *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
> <pb...@noovelia.com>>
> Gesendet: Sonntag, 14. Februar 2021 16:26
> An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
> 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:image001.png@01D702BB.1A317DF0]
> Patrick Boisclair​
> Analyste ‑ Programmeur senior / Senior Analyst Programmer 
> [cid:image185694.png@BDFA11CA.E2C7D002]
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA 
> noovelia.com<https://www.noovelia.com/
> <https://www.noovelia.com/<https://www.noovelia.com/%20%3chttps:/www.n
> oovelia.com/>>>
>
>
>

AW: TwinCAT ADS - Write value to PLC

Posted by Christofer Dutz <ch...@c-ware.de>.
Ok ... that was a quick one ...

I think I solved the mystery :-) ... 

The driver is actually doing what it should and seems to be doing it correctly.
I tried my test again, but having stopped the PLC programm. I did that cause I wanted to prevent the value being overwritten by any form of PLC program.

And as soon as I stopped the program execution, I could see the watch expressions I had setup change their value as expected.

In my case I setup a predefined set of variables to pre-defined values in order to run some manually executed tests against the device.
I think this initialization is run for every CPU cycle and hereby overwriting the changes the driver is sending.

Here a little video: https://drive.google.com/file/d/12e0Q4ewf8rIdPFcNYscH7xq5j_6RxAGY/view?usp=sharing

Hope this helps,
      Chris



-----Ursprüngliche Nachricht-----
Von: Christofer Dutz <ch...@c-ware.de> 
Gesendet: Montag, 15. Februar 2021 19:41
An: dev@plc4x.apache.org
Betreff: AW: TwinCAT ADS - Write value to PLC

Hi all,

so I just setup the example and my Beckhoff PLC.
I can confirm that the value doesn’t change in the PLC. I used wireshark to inspect the communication between the driver and the PLC and the response to my write request is:

Frame 41: 96 bytes on wire (768 bits), 96 bytes captured (768 bits) on interface \Device\NPF_{7F615F1B-E091-421F-850E-2BC9EEC3A622}, id 0 Ethernet II, Src: Beckhoff_13:6a:a0 (00:01:05:13:6a:a0), Dst: GopodGro_02:d2:c7 (48:65:ee:12:d2:c7) Internet Protocol Version 4, Src: 192.168.23.20, Dst: 192.168.23.200 Transmission Control Protocol, Src Port: 48898, Dst Port: 50301, Seq: 51, Ack: 121, Len: 42 AMS
    AMS Target Net Id: 192.168.23.200.1.1
    AMS Target port: 65534
    AMS Sender Net Id: 192.168.23.20.1.1
    AMS Sender port: 851
    CmdId: ADS Write (3)
    StateFlags: 0x0005
        .... .... .... ...1 = RESPONSE: Set
        .... .... .... ..0. = NO RETURN: Not set
        .... .... .... .1.. = ADS COMMAND: Set
        .... .... .... 0... = SYSTEM COMMAND: Not set
        .... .... ...0 .... = HIGH PRIORITY COMMAND: Not set
        .... .... ..0. .... = TIMESTAMP ADDED: Not set
        .... .... .0.. .... = UDP COMMAND: Not set
        .... .... 0... .... = INIT COMMAND: Not set
        0... .... .... .... = BROADCAST: Not set
    cbData: 4
    ErrorCode: NO ERROR (0x00000000)
    InvokeId: 0x00000002
    ADS Write Response
        Result: NO ERROR (0x00000000)

So from a protocol point of view it actually accepted the request and at least said that it processed it correctly.
I’ll check if my demo program might be setup wrong.

Chris



Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Montag, 15. Februar 2021 19:16
An: Łukasz Dywicki <lu...@code-house.org>; dev@plc4x.apache.org
Betreff: RE: TwinCAT ADS - Write value to PLC

Hi Lukasz,

I tried a single write, no luck ☹

Ty for your feedback
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer [cid:image199837.png@8952B63E.E11BC000]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA noovelia.com<https://www.noovelia.com/>
-----Original Message-----
From: Łukasz Dywicki <lu...@code-house.org>>
Sent: Monday, February 15, 2021 5:06 AM
To: dev@plc4x.apache.org<ma...@plc4x.apache.org>; Patrick Boisclair <pb...@noovelia.com>>
Subject: Re: TwinCAT ADS - Write value to PLC

I have one report from openHAB community that it is possible to write BOOL value just once, second and every next write does not pass. It does not even show up any traffic in Wireshark. I haven't confirmed cause yet.

I have not completed setting wiring and program for tests with CX (TC2) I got. I already found there is a trouble with reading of symbol table
(SYM_UPLOADINFO2) due to new IEC decoder. It seems that it attempts to read more than is available in underlying response from PLC.

Best,
Łukasz

On 15.02.2021 01:11, Patrick Boisclair wrote:
> Hi Chris,
>
>
>
> I double checked and the value I’m trying to write is most definitely 
> not being overridden.
>
> I have tried with TwinCAT (within Visual Studio) and changed the value 
> and it worked while the PLC program was running.
>
>
>
> If you need more info or input, just let me know.
>
>
>
> Ty very much
>
>
>
> Patrick Boisclair​
>
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
>
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> *noovelia.com* <https://www.noovelia.com/>
>
> *From:*Patrick Boisclair 
> <pb...@noovelia.com>>
> *Sent:* February 14, 2021 12:02 PM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>
> *Subject:* Re: TwinCAT ADS - Write value to PLC
>
>
>
> 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* <https://www.noovelia.com/>
>
> ----------------------------------------------------------------------
> --
>
> *From:* Christofer Dutz 
> <ch...@c-ware.de>>
> *Sent:* Sunday, February 14, 2021, 10:58 AM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>
> *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 
> <pb...@noovelia.com>>
> Gesendet: Sonntag, 14. Februar 2021 16:26
> An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
> 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:image001.png@01D702BB.1A317DF0]
> Patrick Boisclair​
> Analyste ‑ Programmeur senior / Senior Analyst Programmer 
> [cid:image185694.png@BDFA11CA.E2C7D002]
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA 
> noovelia.com<https://www.noovelia.com/ 
> <https://www.noovelia.com/<https://www.noovelia.com/%20%3chttps:/www.n
> oovelia.com/>>>
>
>
>

AW: TwinCAT ADS - Write value to PLC

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi all,

so I just setup the example and my Beckhoff PLC.
I can confirm that the value doesn’t change in the PLC. I used wireshark to inspect the communication between the driver and the PLC and the response to my write request is:

Frame 41: 96 bytes on wire (768 bits), 96 bytes captured (768 bits) on interface \Device\NPF_{7F615F1B-E091-421F-850E-2BC9EEC3A622}, id 0
Ethernet II, Src: Beckhoff_13:6a:a0 (00:01:05:13:6a:a0), Dst: GopodGro_02:d2:c7 (48:65:ee:12:d2:c7)
Internet Protocol Version 4, Src: 192.168.23.20, Dst: 192.168.23.200
Transmission Control Protocol, Src Port: 48898, Dst Port: 50301, Seq: 51, Ack: 121, Len: 42
AMS
    AMS Target Net Id: 192.168.23.200.1.1
    AMS Target port: 65534
    AMS Sender Net Id: 192.168.23.20.1.1
    AMS Sender port: 851
    CmdId: ADS Write (3)
    StateFlags: 0x0005
        .... .... .... ...1 = RESPONSE: Set
        .... .... .... ..0. = NO RETURN: Not set
        .... .... .... .1.. = ADS COMMAND: Set
        .... .... .... 0... = SYSTEM COMMAND: Not set
        .... .... ...0 .... = HIGH PRIORITY COMMAND: Not set
        .... .... ..0. .... = TIMESTAMP ADDED: Not set
        .... .... .0.. .... = UDP COMMAND: Not set
        .... .... 0... .... = INIT COMMAND: Not set
        0... .... .... .... = BROADCAST: Not set
    cbData: 4
    ErrorCode: NO ERROR (0x00000000)
    InvokeId: 0x00000002
    ADS Write Response
        Result: NO ERROR (0x00000000)

So from a protocol point of view it actually accepted the request and at least said that it processed it correctly.
I’ll check if my demo program might be setup wrong.

Chris



Von: Patrick Boisclair <pb...@noovelia.com>
Gesendet: Montag, 15. Februar 2021 19:16
An: Łukasz Dywicki <lu...@code-house.org>; dev@plc4x.apache.org
Betreff: RE: TwinCAT ADS - Write value to PLC

Hi Lukasz,

I tried a single write, no luck ☹

Ty for your feedback
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer
[cid:image199837.png@8952B63E.E11BC000]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>
-----Original Message-----
From: Łukasz Dywicki <lu...@code-house.org>>
Sent: Monday, February 15, 2021 5:06 AM
To: dev@plc4x.apache.org<ma...@plc4x.apache.org>; Patrick Boisclair <pb...@noovelia.com>>
Subject: Re: TwinCAT ADS - Write value to PLC

I have one report from openHAB community that it is possible to write BOOL value just once, second and every next write does not pass. It does not even show up any traffic in Wireshark. I haven't confirmed cause yet.

I have not completed setting wiring and program for tests with CX (TC2) I got. I already found there is a trouble with reading of symbol table
(SYM_UPLOADINFO2) due to new IEC decoder. It seems that it attempts to read more than is available in underlying response from PLC.

Best,
Łukasz

On 15.02.2021 01:11, Patrick Boisclair wrote:
> Hi Chris,
>
>
>
> I double checked and the value I’m trying to write is most definitely
> not being overridden.
>
> I have tried with TwinCAT (within Visual Studio) and changed the value
> and it worked while the PLC program was running.
>
>
>
> If you need more info or input, just let me know.
>
>
>
> Ty very much
>
>
>
> Patrick Boisclair​
>
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
>
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> *noovelia.com* <https://www.noovelia.com/>
>
> *From:*Patrick Boisclair <pb...@noovelia.com>>
> *Sent:* February 14, 2021 12:02 PM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>
> *Subject:* Re: TwinCAT ADS - Write value to PLC
>
>
>
> 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* <https://www.noovelia.com/>
>
> ----------------------------------------------------------------------
> --
>
> *From:* Christofer Dutz <ch...@c-ware.de>>
> *Sent:* Sunday, February 14, 2021, 10:58 AM
> *To:* dev@plc4x.apache.org<ma...@plc4x.apache.org>
> *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 <pb...@noovelia.com>>
> Gesendet: Sonntag, 14. Februar 2021 16:26
> An: dev@plc4x.apache.org<ma...@plc4x.apache.org>
> 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:image001.png@01D702BB.1A317DF0]
> Patrick Boisclair​
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
> [cid:image185694.png@BDFA11CA.E2C7D002]
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> noovelia.com<https://www.noovelia.com/ <https://www.noovelia.com/<https://www.noovelia.com/%20%3chttps:/www.noovelia.com/>>>
>
>
>

RE: TwinCAT ADS - Write value to PLC

Posted by Patrick Boisclair <pb...@noovelia.com>.
Hi Lukasz,

I tried a single write, no luck ☹

Ty for your feedback


Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer
462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com
-----Original Message-----
From: Łukasz Dywicki <lu...@code-house.org> 
Sent: Monday, February 15, 2021 5:06 AM
To: dev@plc4x.apache.org; Patrick Boisclair <pb...@noovelia.com>
Subject: Re: TwinCAT ADS - Write value to PLC

I have one report from openHAB community that it is possible to write BOOL value just once, second and every next write does not pass. It does not even show up any traffic in Wireshark. I haven't confirmed cause yet.

I have not completed setting wiring and program for tests with CX (TC2) I got. I already found there is a trouble with reading of symbol table
(SYM_UPLOADINFO2) due to new IEC decoder. It seems that it attempts to read more than is available in underlying response from PLC.

Best,
Łukasz

On 15.02.2021 01:11, Patrick Boisclair wrote:
> Hi Chris,
> 
>  
> 
> I double checked and the value I’m trying to write is most definitely 
> not being overridden.
> 
> I have tried with TwinCAT (within Visual Studio) and changed the value 
> and it worked while the PLC program was running.
> 
>  
> 
> If you need more info or input, just let me know.
> 
>  
> 
> Ty very much
> 
>  
> 
> Patrick Boisclair​
> 
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
> 
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> *noovelia.com* <https://www.noovelia.com/>
> 
> *From:*Patrick Boisclair <pb...@noovelia.com>
> *Sent:* February 14, 2021 12:02 PM
> *To:* dev@plc4x.apache.org
> *Subject:* Re: TwinCAT ADS - Write value to PLC
> 
>  
> 
> 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* <https://www.noovelia.com/>
> 
> ----------------------------------------------------------------------
> --
> 
> *From:* Christofer Dutz <ch...@c-ware.de>
> *Sent:* Sunday, February 14, 2021, 10:58 AM
> *To:* dev@plc4x.apache.org
> *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 <pb...@noovelia.com>
> Gesendet: Sonntag, 14. Februar 2021 16:26
> An: dev@plc4x.apache.org
> 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:image001.png@01D702BB.1A317DF0]
> Patrick Boisclair​
> Analyste ‑ Programmeur senior / Senior Analyst Programmer 
> [cid:image185694.png@BDFA11CA.E2C7D002]
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA 
> noovelia.com<https://www.noovelia.com/ <https://www.noovelia.com/>>
> 
>  
> 

Re: TwinCAT ADS - Write value to PLC

Posted by Łukasz Dywicki <lu...@code-house.org>.
I have one report from openHAB community that it is possible to write
BOOL value just once, second and every next write does not pass. It does
not even show up any traffic in Wireshark. I haven't confirmed cause yet.

I have not completed setting wiring and program for tests with CX (TC2)
I got. I already found there is a trouble with reading of symbol table
(SYM_UPLOADINFO2) due to new IEC decoder. It seems that it attempts to
read more than is available in underlying response from PLC.

Best,
Łukasz

On 15.02.2021 01:11, Patrick Boisclair wrote:
> Hi Chris,
> 
>  
> 
> I double checked and the value I’m trying to write is most definitely
> not being overridden.
> 
> I have tried with TwinCAT (within Visual Studio) and changed the value
> and it worked while the PLC program was running.
> 
>  
> 
> If you need more info or input, just let me know.
> 
>  
> 
> Ty very much
> 
>  
> 
> Patrick Boisclair​
> 
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
> 
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> *noovelia.com* <https://www.noovelia.com/>
> 
> *From:*Patrick Boisclair <pb...@noovelia.com>
> *Sent:* February 14, 2021 12:02 PM
> *To:* dev@plc4x.apache.org
> *Subject:* Re: TwinCAT ADS - Write value to PLC
> 
>  
> 
> 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* <https://www.noovelia.com/>
> 
> ------------------------------------------------------------------------
> 
> *From:* Christofer Dutz <ch...@c-ware.de>
> *Sent:* Sunday, February 14, 2021, 10:58 AM
> *To:* dev@plc4x.apache.org
> *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 <pb...@noovelia.com>
> Gesendet: Sonntag, 14. Februar 2021 16:26
> An: dev@plc4x.apache.org
> 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:image001.png@01D702BB.1A317DF0]
> Patrick Boisclair​
> Analyste ‑ Programmeur senior / Senior Analyst Programmer
> [cid:image185694.png@BDFA11CA.E2C7D002]
> 462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
> noovelia.com<https://www.noovelia.com/ <https://www.noovelia.com/>>
> 
>  
> 

RE: TwinCAT ADS - Write value to PLC

Posted by Patrick Boisclair <pb...@noovelia.com>.
Hi Chris,

I double checked and the value I’m trying to write is most definitely not being overridden.
I have tried with TwinCAT (within Visual Studio) and changed the value and it worked while the PLC program was running.

If you need more info or input, just let me know.

Ty very much


Patrick Boisclair
Analyste - Programmeur senior / Senior Analyst Programmer
462, rue des Forges, Trois-Rivières (Québec) G9A 2H5 CANADA
noovelia.com
From: Patrick Boisclair <pb...@noovelia.com>
Sent: February 14, 2021 12:02 PM
To: dev@plc4x.apache.org
Subject: Re: TwinCAT ADS - Write value to PLC

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
[cid:image691101.png@8CA666ED.333298CB]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>
________________________________
From: Christofer Dutz <ch...@c-ware.de>
Sent: Sunday, February 14, 2021, 10:58 AM
To: dev@plc4x.apache.org
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 <pb...@noovelia.com>
Gesendet: Sonntag, 14. Februar 2021 16:26
An: dev@plc4x.apache.org
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:image001.png@01D702BB.1A317DF0]
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer
[cid:image185694.png@BDFA11CA.E2C7D002]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>


Re: TwinCAT ADS - Write value to PLC

Posted by Patrick Boisclair <pb...@noovelia.com>.
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 <ch...@c-ware.de>
Sent: Sunday, February 14, 2021, 10:58 AM
To: dev@plc4x.apache.org
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 <pb...@noovelia.com>
Gesendet: Sonntag, 14. Februar 2021 16:26
An: dev@plc4x.apache.org
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:image001.png@01D702BB.1A317DF0]
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer
[cid:image185694.png@BDFA11CA.E2C7D002]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>



AW: TwinCAT ADS - Write value to PLC

Posted by Christofer Dutz <ch...@c-ware.de>.
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 <pb...@noovelia.com>
Gesendet: Sonntag, 14. Februar 2021 16:26
An: dev@plc4x.apache.org
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:image001.png@01D702BB.1A317DF0]
Patrick Boisclair​
Analyste ‑ Programmeur senior / Senior Analyst Programmer
[cid:image185694.png@BDFA11CA.E2C7D002]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>