Join us today!
Passing a structure between PLCs via ADS using symbolic addressing
Hey folks,
Looking to pass a data structure between two Beckhoff PLCs.
This is only intermittent data, as trays are passed between systems, so not occurring every scan.
Can see it's possible via either ADS or EAP.
EAP looks like a little more work, so preferring ADS.
Found examples here:
and here:
https://www.plccoder.com/communicating-between-beckhoff-controllers-part-2-ads/
But seems to rely on either a fixed offset in the PLC, or mapping to %MB areas and trying to avoid overlapping the addresses.
Is there a way to use symbolic comms, as is done from the ADS .Net library?
Thanks!
Duncan
@duncan this is possible. The two function blocks below use symbols instead of index/offset. 👍
FB_ReadAdsSymByName
FB_WriteAdsSymByName
Small example
PROGRAM MAIN VAR trigger : BOOL; adsWriteStatus : (IDLE, WRITE, BUSY, ERROR); adsWrite : FB_WriteAdsSymByName := ( sNetId := '192.168.0.2.1.1', nPort := 851, eComMode := E_AdsComMode.eAdsComModeSecureCom, tTimeout := DEFAULT_ADS_TIMEOUT ); sendTrayData : MyTrayStructure; END_VAR
CASE adsWriteStatus OF IDLE : IF trigger THEN trigger := FALSE; adsWriteStatus := WRITE; END_IF WRITE : adsWrite(bWrite := FALSE); adsWrite( sVarName := 'Main.receivedTrayData', nLen := SIZEOF(sendTrayData), nSrcAddr := ADR(sendTrayData), bWrite := TRUE ); adsWriteStatus := BUSY; BUSY : adsWrite(bWrite := FALSE); IF NOT adsWrite.bBusy THEN IF NOT adsWrite.bError THEN adsWriteStatus := IDLE; ELSE adsWriteStatus := ERROR; END_IF END_IF ERROR : // something went wrong... END_CASE
My blog: codingbytes
My code: https://github.com/benhar-dev
-
I cannot add a variable to the TwinCat scope project.
3 months ago
-
URGENT! Simulink with "To File" Block and "MAT-file logging" do not get activated into my Beckhoff runtime.
4 months ago
-
Twincat 3 HMI Server Graph display problem
11 months ago
-
Limitations on ADS Notifications
1 year ago
-
Detecting low voltage on PLC bus
2 years ago
- 17 Forums
- 267 Topics
- 942 Posts
- 0 Online
- 722 Members