CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sat Dec 15, 2018 3:49 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Nov 28, 2018 2:01 pm 
Offline

Joined: Tue Jan 30, 2018 11:11 am
Posts: 5
Hello

I have a generic service running reading a parameter. It can read the parameter once, then it won't go again because the 'IF xDone then' runs which makes it finish the sub routine. I need to do a cold reset to get it to work again.

I found a reset() function which seams to do nothing. The documentation says:
Quote:
This function block is used for calling the reset service of a specific instance of a CIP object. The exact effect of this service depends on the CIP object (refer to the CIP specifications (Vol. 1 and 2). This instance call resets the DEVICE_123_ETHERNET device as soon as xExecute yields TRUE:


Thanks

Sub routine:
Code:
IF Execute THEN
   Done                  :=FALSE;
   Read_Parameter_TxData[17]   :=DriveAddress;
   Read_Parameter_TxData[10]   :=WORD_TO_BYTE(ParameterNumber);
   Read_Parameter_TxData[11]   :=WORD_TO_BYTE(SHR(ParameterNumber,8));
   Read_Parameter(
      itfEtherNetIPDevice      :=EthernetAdapter,
      eClass               :=Read_Parameter_Class,
      dwInstance            :=Read_Parameter_Instance,
      wAttribute            :=Read_Parameter_Attribute,
      eService            :=Read_Parameter_Serv,
      pWriteData            :=ADR(Read_Parameter_TxData[0]),
      udiWriteDataSize      :=SIZEOF(Read_Parameter_TxData),
      pReadData            :=ADR(Read_Parameter_RxData[0]),
      udiReadDataSize         :=SIZEOF(Read_Parameter_RxData),
      xExecute            :=TRUE,
   );
   counter:=1;
END_IF

IF Read_Parameter.xDone THEN
   returnValue      :=   SHL(BYTE_TO_WORD(Read_Parameter_RxData[1]),8) + Read_Parameter_RxData[0];
   Execute         :=    FALSE;
   Done         :=   TRUE;
   counter         :=   0;
   Read_Parameter.xExecute := FALSE;
END_IF

IF counter = 2 THEN
   Execute:=TRUE;
   counter:=0;
END_IF

IF Read_Parameter.xError AND counter = 1 THEN
   ErrorEnum := Read_Parameter.eError;
   Execute   :=    FALSE;
   counter := 2;
   Read_Parameter.xExecute := FALSE;
END_IF

Error:=Read_Parameter.xError;


Main:
Code:
IF IDL_ReadBool THEN
         IF RParmEIP.Error THEN
            RParmEIP();
         ELSE
         RParmEIP(
            EthernetAdapter     :=OPC_2_ETHIG_IN,
            ParameterNumber  :=IDL_ReadP-1,
            Execute          :=TRUE,
         );
         END_IF
      END_IF

      IF RParmEIP.Done THEN
         IDL_ReadBool   :=FALSE;
         IDL_ReadVal      :=RParmEIP.returnValue;
         RParmEIP();
      END_IF


Top
   
PostPosted: Wed Nov 28, 2018 2:39 pm 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 67
If you don't call your FB "Read_Parameter", how should xDone (FB output) come to false ?
Your FB should be called at every cycle.

exemple, slightly edited to auto cycle com requests
Code:
Read_Parameter_TxData[17]   :=DriveAddress;
Read_Parameter_TxData[10]   :=WORD_TO_BYTE(ParameterNumber);
Read_Parameter_TxData[11]   :=WORD_TO_BYTE(SHR(ParameterNumber,8));

Read_Parameter(
  itfEtherNetIPDevice      :=EthernetAdapter,
  eClass               :=Read_Parameter_Class,
  dwInstance            :=Read_Parameter_Instance,
  wAttribute            :=Read_Parameter_Attribute,
  eService            :=Read_Parameter_Serv,
  pWriteData            :=ADR(Read_Parameter_TxData[0]),
  udiWriteDataSize      :=SIZEOF(Read_Parameter_TxData),
  pReadData            :=ADR(Read_Parameter_RxData[0]),
  udiReadDataSize         :=SIZEOF(Read_Parameter_RxData),
  xExecute            :=NOT (Read_Parameter.xError OR Read_Parameter.xDone),
);

IF Read_Parameter.xDone THEN
   returnValue      :=   SHL(BYTE_TO_WORD(Read_Parameter_RxData[1]),8) + Read_Parameter_RxData[0];
END_IF

IF Read_Parameter.xError THEN
   ErrorEnum := Read_Parameter.eError;
END_IF


Regards,
dFx


Top
   
PostPosted: Wed Nov 28, 2018 2:51 pm 
Offline

Joined: Tue Jan 30, 2018 11:11 am
Posts: 5
Ah thanks, so glad it was that simple!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 4 guests


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