Easy E4 / Easysoft8 timer problems

Hi all,
I am developing a controller in Easy e4 using Structured Text, which reads a temperature, triggers an output then waits for a given number of seconds before resuming monitoring. It works exactly how I want it when it starts up, but when the delay is triggered a second time, the timer thinks its already at the end of the count, and so there is no delay.
The timer is within a case statement, and some other logic, it is enabled with a marker which is set to false between times, but that doesn't seem to be resetting it.

Can anyone please advise?

Thanks :)
 
Put the timer outside the structured text block (for example in ladder) or a least outside the case statement.

Also enabling is not the same as resetting a timer. You have to look closer at the timers in your PLC documentation to see how you control it. Different PLC brands and even models works differently when it comes to timers.

That will probably fix your problem.


That said, personally I very seldom use timers in structured text. I track elapsed time instead.
It's more flexible and you can have many "timers", index them, put them in UDT, and you don't need special date/time types (only integers or floats) etc.

Below some rough examples of that just to give you an idea.

Count elapsed time by counting milliseconds based on scan time
Code:
// increase a variable with the amount of millisecond for each scan
if counting_enabled then
   elapsed_time:=elapsed_time+last_scan_milliseconds;
end_if;

// check is 2.5 seconds has passed
if elapsed_time>2500 then
   // do something
   elapsed_time:=0;
end_if;

Or calculate elapsed time by using system time
Code:
// calculate elapsed time using system time (float)
// exact implementation and unit depends on the system
// in this case the unit is seconds
elapsed_time:=current_time-start_time;

// check if 1.3 seconds has passed
if elapsed_time>1.3 then
   // do something
   elapsed_time:=0;
end_if;


Or calculate elapsed time in seconds - for long periods where accuracy +/- 1 second is good enough
Code:
// one_second is set for one scan by a repetitive timer
// used by many elapsed timers in the system
// counting seconds
if counting_enabled and one_second then elapsed_seconds:=elapsed_seconds+1; end_if;

// check if 10 minutes has passed
if elapsed_seconds>600 then
   // do whatever is needed
   elapsed_second:=0;
end_if;

Another options is to count down instead of up.

Code:
// timer is floating point
// start the timer
if something_happened then timer:=10.0; end_if;

// count down as long as the timer is positive
if timer>0 then
   timer:=timer-last_scan_milliseconds/1000.0;
   if timer<=0.0 then
      // do something
     timer:=0.0;
   end_if;
end_if;
 
I agree with Pete.s, most delay on timers need to see the input enable to go false before a reset can occur, but it may depend on the timer type or specific platform, a timer in a case statement means that when the case statement is false the timer is not processed & therefore will not reset as it can not see a transition from true to false.
 
Thanks!! Fixed it :) I moved the case logic onto the enable input - it now works perfectly.

Coming to this from a programming background.... taking a bit of time to get my head around it.
 
Thanks!! Fixed it :) I moved the case logic onto the enable input - it now works perfectly.

Coming to this from a programming background.... taking a bit of time to get my head around it.

Yeah, ST is a kinda broken that way compared to Ladder i.e. "instructions" inside IF-ELSE-ENDIF clauses are not evaluated on every scan cycle, but it's not a big deal when you think about it.

To get your head around it, you have be as simple-minded as a PLC, which is surprisingly hard to do. I suggest you watch @Ron Beaufort's PLC bootcamp video series. Pay particular attention to discussion of the scan cycle. Ignore the advertising for the obsolete training (though it is available elsewhere if you are interested).
 

Similar Topics

Hi all, I am working on an Easy E4 project. Last week it was all working great - just a couple of tweaks to do day - but when I tried to connect...
1
Replies
151
Views
Hi all I am programming an Easy e4 which has the temperature extension module. I am trying to determine the behaviour for short and open circuit...
2
Replies
286
Views
Hi, can anyone help me with PLC: Novance EASY 301? The one I have is corrupted, and I no longer have the software. I need help, please. The...
0
Replies
506
Views
Hello all. I'm having an issue where I cant transfer the program from Easysoft V8.25 over onto the PLC. I have updated the PLC to V1.42, and...
1
Replies
512
Views
I havent used this for a while and now I can open projects or a new one but when I go to the Parameters screen it shuts down program Any Ideas...
1
Replies
413
Views
Top