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 Sun Nov 17, 2019 5:55 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
 Post subject: CTU
PostPosted: Wed Jan 09, 2013 12:26 pm 
Offline

Joined: Wed Oct 31, 2012 8:19 am
Posts: 8
Please can anybody tell me how to create counter up with math instructions??


Top
   
 Post subject: Re: CTU
PostPosted: Wed Jan 09, 2013 12:49 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Tue Jun 06, 2006 9:03 am
Posts: 410
Hi, do you mean structured text?
If yes, you can use it like this:

Code:
PROGRAM PLC_PRG
VAR
   fbCTU1: CTU;
   xCountUp1: BOOL;
   uiCounter1: UINT;
   xReset1: BOOL;
   xCountUp2: BOOL;
   uiCounter2: UINT;
   xReset2: BOOL;
END_VAR

Code:
// CTU Function-block
fbCTU1(
   CU:= xCountUp1,
   RESET:= xReset1,
   PV:= 100,
   Q=> ,
   CV=> uiCounter1);
   
// Or
IF xCountUp2 THEN
   uiCounter2 := uiCounter2 + 1;
   xCountUp2 := FALSE;
END_IF
IF xReset2 THEN
   uiCounter2 := 0;
END_IF


Top
   
 Post subject: Re: CTU
PostPosted: Wed Jan 09, 2013 12:57 pm 
Offline

Joined: Wed Oct 31, 2012 8:19 am
Posts: 8
Thank for that, but I must do CTU in ladder diagram only with math and compare instruction!


Top
   
 Post subject: Re: CTU
PostPosted: Wed Jan 09, 2013 1:06 pm 
Offline

Joined: Wed Oct 31, 2012 8:19 am
Posts: 8
Everytime when I put "1" on my firt input some memory registar must increase for 1.


Top
   
 Post subject: Re: CTU
PostPosted: Wed Jan 09, 2013 1:54 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Tue Jun 06, 2006 9:03 am
Posts: 410
See screenshot for an example


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  Reply to topic  [ 5 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 5 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