I'm trying to build a program which scan an alarm table and if an alarm occurs, it send a sms but I've a trouble with my Rtrig, so this is the piece of programm which give me problems:
For i:=0 to 200 by 1 DO
Rtrig(alarme[i].state)
If(Rtrig(alarme[i].state) THEN
buffer[j].mesage:=alarme[i].message;
J:=J+1;
END_IF
END_FOR
So the problem is when a RTrig occurs, my programme continue stay in the IF, so it continues to store the same message in my buffer and it continues to increase the J variable
So I made a small test, after the for, I put a Test:=Test+1; and my variable Test increase continually until I release my variable Alarme[i].State
After that, I made a trial, I write a function in ladder language, with a R trig contact and a coil, and here it's working
Any help?
Thank in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, but your solution is too convoluted (difficult).
Usualy simpler is better, so try this;
Fori:=0to200by1DO
  Rtrig(CLK :=alarme[i].state); Run trigger function call
  If RTrig.QTHEN   // .Qistheoutputofthetrigger
    buffer[j].mesage:=alarme[i].message;
    J:=J+1;
  END_IFEND_FOR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hermsen,
The problem with this is that you are using the same R_TRIG for 201 values. So like teichhei says you would need an array of R_TRIG. For example if you had the following:
alarm[0]:=FALSE;Rtrig(CLK:=alarm[0]);Â Â Â Â //Rtrig.Qwould=false;alarm[1]:=TRUE;Rtrig(CLK:=alarm[1]);Â Â Â Â //Rtrig.QwouldALWAYSgettriggeredtoTRUEbecauseyouarecallingthesamefunctionblockasinline2;
So every cycle would trip the rising trigger.
You would need to do something like
//SUDOuntestedVAR
  alarm:ARRAY[0..200] OFBOOL;
  alarmTrig:ARRAY[0..200] OFR_TRIG;
  i:INT;END_VARFORi:=0to200by1DO
  alarmTrig[i](CLK:=alarm[i]);
  IFalarmTrig[i].QTHEN
   //doworkhereifalarmtriggered
  END_IFEND_FOR
Hermsen hat geschrieben:
Teichhei,
Sorry, but your solution is too convoluted (difficult).
Usualy simpler is better, so try this;
Fori:=0to200by1DO
  Rtrig(CLK :=alarme[i].state); Run trigger function call
  If RTrig.QTHEN   // .Qistheoutputofthetrigger
    buffer[j].mesage:=alarme[i].message;
    J:=J+1;
  END_IFEND_FOR
Don't think that would work because in every loop run you call the same instance of rtrig again, 200 times in a cycle, causing it to look at the previous condition in the previous call. But you need to trigger on the previous cycle state foe the same [i]. You are looking at a different value from one i to the next.
Sent from my SM-G935F using Tapatalk
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well after reading the feedback on my posting I see why my solution will not work.
However, the anwser Joseph proposes seems very sound.
Good luck and sorry for the misdirection =) never too old to learn.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone,
I'm trying to build a program which scan an alarm table and if an alarm occurs, it send a sms but I've a trouble with my Rtrig, so this is the piece of programm which give me problems:
For i:=0 to 200 by 1 DO
Rtrig(alarme[i].state)
If(Rtrig(alarme[i].state) THEN
buffer[j].mesage:=alarme[i].message;
J:=J+1;
END_IF
END_FOR
So the problem is when a RTrig occurs, my programme continue stay in the IF, so it continues to store the same message in my buffer and it continues to increase the J variable
So I made a small test, after the for, I put a Test:=Test+1; and my variable Test increase continually until I release my variable Alarme[i].State
After that, I made a trial, I write a function in ladder language, with a R trig contact and a coil, and here it's working
Any help?
Thank in advance
If alarme(i-1) is false and alarme(i) is true rtrig returns true.
You would need an rtrig by every i
And you are calling the block twice, should be If rtrig[i].q then ... So use an array of r_trig one for each alarm
Sent from my SM-G935F using Tapatalk
Teichhei,
Sorry, but your solution is too convoluted (difficult).
Usualy simpler is better, so try this;
Hermsen,
The problem with this is that you are using the same R_TRIG for 201 values. So like teichhei says you would need an array of R_TRIG. For example if you had the following:
So every cycle would trip the rising trigger.
You would need to do something like
Related
Talk.ru: 1
Good feedback!
Hi.
But the oop solution is create an fb alarm with three attributes.
Private bool alarm, edge.
Amd two methods
SetAlarm(bool value)
If(value<>alarmOld)then
Edge=true
Else
Edge=false
Endif
Alarm=value
And two gets, one for alarm, and one for value
That would work to.
Don't think that would work because in every loop run you call the same instance of rtrig again, 200 times in a cycle, causing it to look at the previous condition in the previous call. But you need to trigger on the previous cycle state foe the same [i]. You are looking at a different value from one i to the next.
Sent from my SM-G935F using Tapatalk
I like the OOP version too...
Sent from my SM-G935F using Tapatalk
Well after reading the feedback on my posting I see why my solution will not work.
However, the anwser Joseph proposes seems very sound.
Good luck and sorry for the misdirection =) never too old to learn.