Step 7 ET200s - PID controller - dt problem

naturephoenix

Member
Join Date
Jan 2015
Location
Vienn
Posts
181
How can I get the curret "t" in SCL
dt=tnow-tprevious

I dont know how to get "tnow". I am not sure should it be in s(seconds) or miliseconds. I know that a cycle of my OB1 is somthing like 5ms.
So any help out there?
 
I would recommend running your PID code out of a cyclic OB, like OB35, instead of OB1. They have a much more defined interval than OB1.
 
I use this to calculate the time between PID calls:
Code:
[COLOR=SeaGreen]// Calculate the sample time[/COLOR]
[COLOR=SeaGreen]// Transfer previous time from last Current[/COLOR]
#Previous_Time:= #Current_Time;
[COLOR=SeaGreen]// Transfer Current time to previous time[/COLOR]
#"Cycle_Time_n-1":= #Cycle_Time;
[COLOR=SeaGreen]// Get the new Current Time[/COLOR]
#"RD-Sys_T_return":= RD_SYS_T(#Current_Time);
[COLOR=SeaGreen]// Subtract Current from Previous to get Time in ms[/COLOR]
#Cycle_Time:= T_DIFF(IN1:=#Current_Time, IN2:=#Previous_Time);
[COLOR=SeaGreen]// Convert to Real and divide by 1000 to get time in seconds[/COLOR]
#Time_in_Secs:= DINT_TO_REAL(TIME_TO_DINT(#Cycle_Time))/1000;
I am working with S7-1200 so I don't know if there is anything similar for the ET200s. I can't use a Cyclic Interrupt because the data isn't always available in a fixed period.
 

Similar Topics

I am having a step7 v5.4 program where the blocks are encrypted and locked. And the manufacturer is stopped the support. Is there any ways to...
Replies
2
Views
182
Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
253
HI! HOW COULD I OBTAIN THE NAMES OF THE STEPS OF A ROUTINE IN SFC LANGUAGE IN STUDIO5000? Or is there a system variable that gives me those...
Replies
0
Views
343
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
557
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
690
Back
Top Bottom