What is the rising edge code in GX Works 2 in structured text

Tjkeets90

Member
Join Date
Mar 2018
Location
England
Posts
39
Hi all,

Does any body know what the rising edge code is for GX Works in structured text.
I have several manuals but can't find anything relating to 'rising edge'.

My code is pretty simple:

IF M1049 THEN
D181 := D181 +1;
IF D181 > 9998 THEN
D181 := 0;
END_IF;
END_IF;

I only want to increment D181 when M1049 is first set. So if the input stays set D181 doesn't increment with every scan.

Thanks,

Tom
 
There might be a pulse instruction or function, but the following modification might do what you want; the bold blue is new.


Code:
[COLOR=Blue][B](* Count each change of measurement 1049 to a non-zero value ... *)[/B][/COLOR]

IF  M1049 [COLOR=Blue][B]AND M1049 != M1049_save[/B][/COLOR] THEN

[COLOR=blue][B]  (* Increment counter *)[/B][/COLOR]

  D181 := D181 +1;

[COLOR=blue][B]  (* Reset counter at 9999th increment *)[/B][/COLOR]

  IF D181 > 9998 THEN
    D181 := 0;
  END_IF;

END_IF;

[COLOR=blue][B](* Ensure only changes in measurement are detected on future scans *)
M1049_save := M1049;[/B][/COLOR]
Perhapa "AND" should be &&? I am not an ST guru.
 
ENO := PLS(EN,D);


PLS(My_Trigger,My_Pulse); // Note here M0 is the trigger, M1 is the pulse so without symbols it's
PLS(M0,M1);

My_Trigger is the pulse enable & My_Pulse is the actual pulse
so when the trigger goes true the pulse is on for one scan.
 
Thanks Parky!

Did you find that in the manual or do you just know that?
I am just starting to use ST so would like to know the easiest way to find the ST equivalent to a ladder block.
 
I know it, however, if you create a program in FBD (just a dummy) in your ST project, click (highlight) the function you want i.e. PLS (from the right hand side) then press F1 if you have the help files loaded it will show you the FBD code & if it can be used in ST will show you that as well

Help.png
 
OR

IF M1049 and NOT M1049_LS THEN
D181 := D181 +1;
IF D181 > 9998 THEN
D181 := 0;
END_IF;
END_IF;

M1049_LS := M1049;

//Create a new bool of M1049_LS
 
You don't need to do the increment longhand there is a function called INC.
for example INC(Trigger, word);
or INCP(Trigger, Word); many instructions have a pulse function designated by "P" so any function that supports the "P" directive will when the trigger (called enable) goes true will only run once, so the function only runs on a positive transition of the enable and will only run again after a false & back to true.

Here is the code:

PLS(M1048, M1049);
INC(M1049,D181);
IF D181 > 9998 THEN
D181 := 0;
END_IF;

Alternatively, you could use

INCP(M1049,D181);
IF D181 > 9998 THEN
D181 := 0;
END_IF;
 
Last edited:

Similar Topics

I have a FX3U clone that I am failing to get a simple Structured Text example working on and would really appreciate some help. I created a...
Replies
30
Views
983
Hi everyone first of all. This is first question in the forum. I am using HSC application. I'm reading A and B pulse count. 1 round of the motor...
Replies
12
Views
4,384
Hi All, Does anyone of you know what is the function of rising and falling edges? I essentially want to trigger a timer once the state of a coil...
Replies
8
Views
4,765
i need to capture the time between the rising edge of 1 pulse and the rising edge of the next pulse after it. i have a flow meter that gives a...
Replies
16
Views
5,126
Hi! Anyone can share example of GE Proficy Rising Edge Structured Text? I have found text as below InstanceOfR_TRIG( CLK := inBool, Q =>...
Replies
6
Views
2,966
Back
Top Bottom