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 <[email protected]>
Gesendet: Montag, 15. Februar 2021 19:16
An: Łukasz Dywicki <[email protected]>; [email protected]
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:[email protected]]
462, rue des Forges, Trois‑Rivières (Québec) G9A 2H5 CANADA
noovelia.com<https://www.noovelia.com/>
-----Original Message-----
From: Łukasz Dywicki <[email protected]<mailto:[email protected]>>
Sent: Monday, February 15, 2021 5:06 AM
To: [email protected]<mailto:[email protected]>; Patrick Boisclair
<[email protected]<mailto:[email protected]>>
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
> <[email protected]<mailto:[email protected]>>
> *Sent:* February 14, 2021 12:02 PM
> *To:* [email protected]<mailto:[email protected]>
> *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
> <[email protected]<mailto:[email protected]>>
> *Sent:* Sunday, February 14, 2021, 10:58 AM
> *To:* [email protected]<mailto:[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]<mailto:[email protected]>>
> Gesendet: Sonntag, 14. Februar 2021 16:26
> An: [email protected]<mailto:[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/
> <https://www.noovelia.com/<https://www.noovelia.com/%20%3chttps:/www.noovelia.com/>>>
>
>
>