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 Wed Apr 24, 2019 2:56 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: TOF RST and ET
PostPosted: Tue May 01, 2018 10:35 am 
Offline

Joined: Thu Feb 23, 2017 5:07 pm
Posts: 89
hello, I need a TOF that has RST and ET

OSCAT has a TOF with RST but does not have ET
Standard TOF has ET but has no RST

How can I solve ?

Thanks, Alberto


Top
   
 Post subject: Re: TOF RST and ET
PostPosted: Tue May 01, 2018 5:39 pm 
Offline
Frequent User
Frequent User

Joined: Tue Dec 03, 2013 11:52 pm
Posts: 109
Just make your own: (Should work but needs to be tested)
Code:
FUNCTION_BLOCK TOF_Advanced
VAR_INPUT
    IN:BOOL;
    PT:TIME;
    RST:BOOL;
END_VAR
VAR_OUTPUT
    ET:TIME;
    Q:BOOL;
END_VAR
VAR
    tStartTime : TIME;
    tCurrentTime : TIME;
END_VAR

//Read system time
tCurrentTime := TIME();

//Set Q based off IN and PT
IF RST THEN
    Q := FALSE;
    ET := T#0MS; //You can reset ET here also if wanted
ELSIF IN THEN
    Q := TRUE;
    ET := T#0MS;
    tStartTime := tCurrentTime;
ELSIF tCurrentTime - tStartTime >= PT AND Q THEN
    ET := tCurrentTime - tStartTime;
    Q := FALSE;
    tCurrentTime := T#0MS;
ELSIF Q AND NOT IN THEN
    ET := tCurrentTime - tStartTime;
END_IF


Attachment:
TOF_Advanced.PNG


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


Top
   
 Post subject: Re: TOF RST and ET
PostPosted: Tue May 01, 2018 7:11 pm 
Offline

Joined: Thu Feb 23, 2017 5:07 pm
Posts: 89
WooooooW

Work very fine :shock:

Thanks


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 3 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