[?]: Count Number of motor starts in the last hour

примеры программ
peterg70
Posts: 121
Joined: Tue Apr 12, 2011 1:44 pm

[?]: Count Number of motor starts in the last hour

Post by peterg70 »

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: Select all

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.
peterg70
Posts: 121
Joined: Tue Apr 12, 2011 1:44 pm

Re: [?]: Count Number of motor starts in the last hour

Post by peterg70 »

anyone able to help out?
dsekulic
Posts: 186
Joined: Sun Feb 12, 2006 5:47 pm
Location: Europe

Re: [?]: Count Number of motor starts in the last hour

Post by dsekulic »

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
peterg70
Posts: 121
Joined: Tue Apr 12, 2011 1:44 pm

Re: [?]: Count Number of motor starts in the last hour

Post by peterg70 »

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: Select all

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
dsekulic
Posts: 186
Joined: Sun Feb 12, 2006 5:47 pm
Location: Europe

Re: [?]: Count Number of motor starts in the last hour

Post by dsekulic »

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
almaz78
Posts: 108
Joined: Tue Dec 16, 2008 7:36 pm

Re: [?]: Count Number of motor starts in the last hour

Post by almaz78 »

try this:
https://rapidshare.com/files/3284892899 ... InHour.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 :)