How to capture value from variable in ST

Akgaurihar

Member
Join Date
Apr 2020
Location
xxx
Posts
9
Hi,

I want to capture a value from variable A (e.g Temperature) when certain conditions are met and write this value to another variable B. Variable B should only contain captured value until the next time conditions are met and value is written.

Variable B indicates that when a certain condition occurred the temp was xx.

I am using OpenPCS and programming in ST.

Thanks in advance.

Regards,
 
If you want to capture the variable as long as condition is true:

Code:
IF condition THEN
  variable_B := variable_A ;
END_IF ;
or if you want to capture the variable only the moment condition turns TRUE:
Code:
IF condition AND NOT condition_mem THEN
  variable_B := variable_A ;
 END_IF ;
condition_mem := condition ;
 
Another way to capture only when the condition becomes true would be to use a rising trigger function block (R_TRIG). The .Q value of this block is true for one scan only after the condition becomes true:

Code:
VAR
Capture_Value: R_TRIG;
Condition:     BOOL; 

(* other variable definitions *)
END_VAR

Capture_Value(CLK:=Condition);   // Call the Rising Trigger Function Block
If Capture_Value.Q THEN
   variable_B := variable_A;
END_IF
 

Similar Topics

Hi all, Let's say we have a nice real (analog) value that has already been scaled with an SCP in Studio5000. Is there a slick method to...
Replies
6
Views
1,578
Good day all, PLC: RSLogix/Studio 5000 using Ladder Logic I've been toying around with the idea of capturing the previous value of a tag inside...
Replies
6
Views
4,366
I'm trying to figure out how I can capture an encoder value using (1) prox switch reading the pedestal on a filler. I want to capture the value...
Replies
7
Views
3,544
Hi All I have a very simple logic with some light sensors and RFID reader, which are providing start and stop events for capturing some short...
Replies
10
Views
2,732
Working on a project using MQTT and an Automation Direct Click Plus. Have the bidirectional communication pretty much figured out. One of the...
Replies
1
Views
1,453
Back
Top Bottom