CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Thu Nov 23, 2017 10:31 am

All times are UTC+01:00




Post new topic  This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Fieldbus
PostPosted: Fri Feb 28, 2014 9:34 am 
Offline

Joined: Mon Jan 14, 2013 3:47 pm
Posts: 73
Fieldbus related:

EtherCat recovering from disconnection
EtherCat, How to reset the Master in IEC?
EtherCat, Error detection in IEC
EtherCat project contains additional Modbus TCP Master: update of Ethercat frames seems to be influenced by modbus update - how could this be avoided?
Modbus, Trigger variable


Top
   
 
PostPosted: Fri Feb 28, 2014 9:35 am 
Offline

Joined: Mon Jan 14, 2013 3:47 pm
Posts: 73
EtherCat revocering from disconnection

Question:
Which steps are needed to recover from disconnected slaves

Answer:
There are two use cases:
1. IEC application should care on restart / error handling
xRestart on Master is needed
2. restart of slaves is done automatically:
The EtherCAT Master provides an option to restart the fieldbus:
Master Configuration, Master: Checkbox: Auto restart slaves
3. Optional Slaves are possible (this is a tag 'Optional') in the slave config


You do not have the required permissions to view the files attached to this post.


Top
   
 
PostPosted: Fri Feb 28, 2014 9:37 am 
Offline

Joined: Mon Jan 14, 2013 3:47 pm
Posts: 73
Question:
EtherCAT Error detection in IEC
Answer:
Master:
Diagnostics Message can be read within the Master configuration tab.
Same in EtherCAT_Master.m_sLastMesage

Slave:
Slave State can be read within the Slave configuration tab. Diagnostics Current State
Same with SlaveName.wState (call of the slave instance is required)
Example:
Code:
EK1100(); // Name of the slave = "EK1100"
      EL1004();
      EL2008();
      IF NOT EK1100.wState = ETC_SLAVE_STATE.ETC_SLAVE_OPERATIONAL THEN
      // do something
      END_IF


Snippet:Snippet:


A very good example is the ethercat example in the CODESYS store: http://store.codesys.com/ethercat-example.html#Support
Code:
(* Get some information of the slaves and master. It is possible to go through all masters and slaves
   and get information about them. *)


(* EtherCAT_Master is an instance of the IoDrvEtherCAT function block.*)

(* The number of active slaves *)
uiActiveSlaves := EtherCAT_Master.NumberActiveSlaves;

(* Get the ETCMaster *)
pEtcMasterFB := EtherCAT_Master.Master;

(* The number of SDO's *)
iSDOCnt := pEtcMasterFB^.GetNumberOfSDO;

(* Go through all Slaves *)   
pSlave := Ethercat_Master.FirstSlave;



WHILE pSlave <> 0 DO

   (* get the address of the current slave. This can also be found under the  device in the "Slave" tab. *)
   uiSlaveAddr := pSlave^.SlaveAddr;
   
   pSlave^();
   (* Get the state of the slave *)
   (* With pSlave^.SetOpMode(ETC_SLAVE_STATE), the state can be set.*)
   IF pSlave^.wState = ETC_SLAVE_STATE.ETC_SLAVE_OPERATIONAL THEN
      ;
   END_IF
   
   pSlave := pSlave^.NextInstance;

END_WHILE


Back to FAQ overview


Top
   
 
 Post subject: Modbus, Trigger variable
PostPosted: Fri Feb 28, 2014 9:40 am 
Offline

Joined: Mon Jan 14, 2013 3:47 pm
Posts: 73
But we can’t locate the actual Boolean Trigger variable?

You can find the trigger var, if you change the Trigger to “Rising edge” :
Attachment:
1.png

you can define any bool var and map the var like any other in/output within the IOMapping for this channel.
Attachment:
2.jpg


What is the scope of the trigger boolean?
Yes
Will it cause just one channel to be written?
Yes

Back to FAQ overview


You do not have the required permissions to view the files attached to this post.


Top
   
 
PostPosted: Fri Feb 28, 2014 9:41 am 
Offline

Joined: Mon Jan 14, 2013 3:47 pm
Posts: 73
Question:
How to reset the Master in IEC:

Answer:
Do not use auto restart option and IEC code at the same time.
Use a rising trigger to reset the Master with xReset.
Code:
      Ethercat_Master.xRestart := xReset;
      Ethercat_Master();


Back to FAQ overview


Top
   
 
PostPosted: Mon Mar 10, 2014 9:43 pm 
Offline

Joined: Mon Jan 14, 2013 3:47 pm
Posts: 73
In a mixed application with Ethercat and Modbus masters, you see an influence on Modbus update to Ethercat task / sending frames- How could this be avoided?

You need a proper seperation of the use of the modbus io's and ethercat io's according to the task which does the buscycle update:

1. Set Ethercat master in 'PLC Settings' as' Buscycle Task' - and Ethercat io's are only used in ethercat task context (in that case in PLC_PRG)
2. specify on Modbus master the update task for Modbus - and Modbus io's are only used in Modbus task context ( in that case in ModbusPRG)
3. Check if these rules are ok with 'task deployment' tap - Rule: Ethercat io's are only updated in the Ethercat task - Modbus io's are only updated on the Modbus task context - this you see with the red cross on each used io.
check online help for 'bus cycle'


Back to FAQ overview


You do not have the required permissions to view the files attached to this post.


Top
   
 
Display posts from previous:  Sort by  
Post new topic  This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited