plcforum.uz.ua

International PLC Forum
It is currently Sat May 27, 2017 10:59 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu May 26, 2011 3:37 pm 

Joined: Tue Apr 12, 2011 4:44 pm
Posts: 121
Need some ladder code example to count the number of motor starts in the last hour.

If more than 10 then raise an output.

I thought I had this done but I don't think I handle the expiration of the first motor start.

example
Code:
time 0 motor start (Count 1)
time 10 min motor start (Count 2)
time 15 min motor start (Count 3)
time 20 min motor start (Count 4)
time 25 min motor start (Count 5)
time 35 min motor start (Count 6)
time 45 min motor start (Count 7)
time 50 min motor start (Count 8)
time 55 min motor start (Count 9)
time 65 min motor start (Count 9) because Count 1 is expired (greater than 1 hour ago)
time 69 min motor start (Count 10) RAISE Alarm output


I don't want to create a timer for each one unless this is the only way.
I thought using a countdown timer which adds on each motor start but what would be high trigger if you had 10 hits within 10 minutes

i.e. first trigger add to count and store current time stamp in datablock and start countdown timer with 60 if countdown is zero.
second trigger add to count and store current time stamp in datablock and add to countdown timer (current time - previous time)
etc
if countdown time > ????? then alarm.

Thoughts or examples please.


Top
 Profile  
 
PostPosted: Sun May 29, 2011 5:23 pm 

Joined: Tue Apr 12, 2011 4:44 pm
Posts: 121
anyone able to help out?


Top
 Profile  
 
PostPosted: Sun May 29, 2011 9:15 pm 

Joined: Sun Feb 12, 2006 8:47 pm
Posts: 182
Location: Europe
Hi,
Did You look in www.oscat.de -> downloads (BASIC DOC 332 EN). There You have function CLICK_CNT. This is not exactly what You looking for but it is similar. You should also look rest of functions.
regards


Top
 Profile  
 
PostPosted: Mon May 30, 2011 3:07 pm 

Joined: Tue Apr 12, 2011 4:44 pm
Posts: 121
that click_cnt would do exactly what I need to do.

But it doesn't exist in rslogix. Well at least that I can find.

Okay found the code behind
Code:
FUNCTION_BLOCK CLICK_CNT
VAR_INPUT
   IN : BOOL;
   N : INT;
   TC : TIME;
END_VAR
VAR_OUTPUT
   Q : BOOL;
END_VAR
VAR
   tx : TP;
   edge: BOOL;
   cnt: INT := -1;
END_VAR

(*
version 1.0   16. jul. 2008
programmer    hugo
tested by   oscat

this Module decodes a specified number of clicks.
the output trig is high for one cycle if N clicks are present within a specified time TC.

*)

(* @END_DECLARATION := '0' *)
(* Q shall only be active for one cycle only *)
Q := FALSE;

IF in AND NOT edge AND NOT tx.q THEN
   (* a rising edge on in sets the counter to 0 *)
   cnt := 0;
ELSIF tx.Q AND NOT IN AND edge THEN
   (* count falling edges when tp.q is true *)
   cnt := cnt + 1;
ELSIF NOT tx.Q THEN
   Q := cnt = N;
   cnt := -1;
END_IF;

(* remember the status of IN *)
edge := IN;
tx(in := IN, pt := TC);


(* revision history

hm    16. jul. 2008   rev 1.0
   original version released


*)
END_FUNCTION_BLOCK


Now to convert it to ladder.
Anyone able to decipher how this works.

TC is only used in a function called tx(in,pt) where in = Input and pt = TC.
then the tx.q and tx.Q are used???
Anyone?

Thanks


Top
 Profile  
 
PostPosted: Mon May 30, 2011 7:42 pm 

Joined: Sun Feb 12, 2006 8:47 pm
Posts: 182
Location: Europe
Hi,
I think that You should think about statement list (or instruction list) instead of ladder logic because statement list is superset to ladder. That means that everything what You write in ladder You can convert to statement list. Opposite, it is not rule (You can not convert everything what is done in statement list to ladder).
regards


Top
 Profile  
 
PostPosted: Tue Jun 14, 2011 8:58 am 

Joined: Tue Dec 16, 2008 10:36 pm
Posts: 89
try this:
https://rapidshare.com/files/3284892899/TenTimesInHour.ACD
i hope, that i understand your problem right.
some improvements are required for this program (midnight time for example), but i think, it does what you need.

And i count only 5 times :)


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

All times are UTC + 3 hours


Who is online

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

Search for:
Jump to:  
Powered by International PLCforum® Forum Software © PLCforum
Mobile version