Hi guys,
I need to count how much time spindle was turned on and he much time spindle was not used . I tried to it as in attachments . but looks like it's impossible to start timers via bg logic. Any ideas?
Timers in bg
-
Acapulka -
March 16, 2017 at 1:54 PM -
Thread is marked as Resolved.
-
-
See the timer comments on page 2 of the BGLogic post at the top of the forum. Basically, you will have to use the 8ms cycle time along with an accumulating register to "time" your process. 125 cycles = 1 second... R[1] = R[1]+1, so when R[1] = 125, one second has passed.
It's presented a little more clearly in the BGLogic thread, but in short, no, you cannot use a conventional timer in BGLogic.
-
See the timer comments on page 2 of the BGLogic post at the top of the forum. Basically, you will have to use the 8ms cycle time along with an accumulating register to "time" your process. 125 cycles = 1 second... R[1] = R[1]+1, so when R[1] = 125, one second has passed.It's presented a little more clearly in the BGLogic thread, but in short, no, you cannot use a conventional timer in BGLogic.
So why IF (DI[1), R[1]=R[1]+1 Is not working in bg?
-
I asked for a timer sample code for background logic and got this, I wanted a beeper to beep for 1 second when one of the 6 machines alarmed out. the guy is a premium programmer and the company he works for does not use plcs, they use bg logic and the I pendant hmi. hope this helps, they use this code all the time for other stuf and this is the watered down version. I cant tell you anything about it but that it works.
2: !Record Scan Time ;
3: R[13:BG Logic Scan]=($MIX_LOGIC.$NUM_SCAN*$SCR.$ITP_TIME) ;
1: !Reset tick if the Alarm is OFF. !Alarm = (Alarm = OFF) ;
1: IF (!DI[100:Alarm 1]),R[100:Alarm 1]=(0) ;
1: IF (!DI[101:Alarm 2]),R[101:Alarm 2]=(0) ;
1: IF (!DI[102:Alarm 3]),R[102:Alarm 3]=(0) ;
1 !Count up if an Alarm is active ;
1: IF (DI[100:Alarm 1]),R[100:Alarm 1]=(R[100:Alarm 1]+1);
1: IF (DI[101:Alarm 2]),R[101:Alarm 2]=(R[101:Alarm 2]+1);
1: IF (DI[102:Alarm 3]),R[102:Alarm 3]=(R[102:Alarm 3]+1);
1: !This converts 2000ms into ticks. ;
1: R[99:Time CNV]=(2000/R[13:BG Logic Scan]) ;
1: !If any tick count in in-between 1 and 2000ms alarm out is active. ;
1: IF ((R[100]>0 AND R[100]<R[99]) OR (R[101]>0 AND R[101]<R[99]) OR (R[102]>0 AND R[102]<R[99])),DO[100:Alarm]=(ON) ;
1: IF ((R[100]=0 OR R[100]>R[99]) AND (R[101]=0 OR R[101]>R[99]) AND (R[102]=0 OR R[102]>R[99])),DO[100:Alarm]=(OFF) ;