Variable on/off timer S7 300

Simmo

Member
Join Date
Oct 2008
Location
Liverpool
Posts
3
Hi guys, I am having a brain freeze on how to produce a timer with the on and off times changeable via the HMI. For example i have a solenoid on a ghlue nozzle, currently the glue is fired as one continuous line onto the product, i need to produce a variable pattern eg on for 500ms then off for 1 second and so on until i loose the glue output. these on and off times need to br varible via the HMI. Can anybody help me please as i just cant think at the minute!!!

Thanks

Simmo
 
I don't have Step7 to hand at the moment so I can't give a detailed answer, but if you use the IEC Timers (maybe SFB3/4 etc.???) the time is defined in ms instead of the daft BCD code which S5Time uses. It should then be pretty easy to do what you want.
 
Here is one way to do it:

ONOFF.jpg




Exchange mw10 and mw12 with locals to clean it up.
change the timebase so it suits you demands. In the sample the time equals integer = 1 = 1 sec.

Be sure that the on- and off-times never equals 0 because then it will lock itself!!
 
Thanks Guys

Sorry about the delay was called out of country, thanks for your rapid responses, i will try this thanks!!:geek:
 
I agree with the IEC timer comment, and you can then set the HMI units directly in m/sec, without having to convert to S5Time.
You will need to display the HMI in x.xxx secs but you can do this on most HMI's quite easily

That is what I usually do.
 
Hi there I am also currently using timers here
setting a timer up is pretty simple.

use madmans tabel for the time base
For example if you want to load a timer with a 1 second interval and a preset value of 30 seconds.
First L W#16#2030
T MW 10

Then just put mw 10 at the PV input of youre prefered timer.
Easy huh.(y)
 
nEVER USED AN Iec TIMER BEFORE COULD YOU SHOW ME HOW TO SET THIS UP PLEASE,:cry:

You find them in the standard library, SFB4 for example is Delay On.

The only problem with them is the fact they need IDB's, for this reason I only use them in FB's where I create them as STAT's.
 
Thanks to Bob Harris, I use functions (FC's) to convert HMI integer setpoints to S5time. The code inside the function looks like what WJhsson posted above. One function for hundredths, one for tenths, one for seconds, and one for minutes. The input is declared as an IN-OUT and if the input is greater than the time the S5timer will support, the function clamps it.

One thing that is not good about S5 timers or IEC timers is once the timer starts timing it no longer looks at the preset. So if you set a timer to 5 minutes and it starts timing, changing the preset to 10 seconds has no effect. Obviously this is not a good thing, not the way AB or GE works.

To combat this, as well as making the time conversion to S5 time format unnecessary, simply make your own timer function. For an integer timer, declare Timer.ACC, Timer.PRE, Timer.1shot, and Timer.DN in a data block (structures work well).

Inside your timer function declare local variables as needed. When enable input is on, use an ADD_I instruction to add a one to the Timer.ACC if the ACC not GEQ the PRE. Next rung compares the ACC to the PRE and sets the Done output.

When you call your FC it will be a timer and work the way normal timers from AB or GE work. Plus you don't have to worry about running out of S5 timers (we had 128 when I started with S7-300 ten years ago) or using lots of instance data blocks like the IEC timers.

I call the timer all the time. I use boolean permissives in series with the enable input along with a 1-second pulse generated from an S5 timer. Alternatively you could call the timer FC in OB35. In the hardware configuration if you set OB35 to be called every 100ms then your timer FC would have a 100ms time base.

I will be glad to post a library of examples if requested. This was one of the big "gotchas" back when I started and people helped me get through them.
 
Here is a library with code examples of what I use for timer presets from an HMI.

Included:

Four functions to convert Integer setpoints to S5 time (hundredths, tenths, seconds, minutes)

Two custom timers (int and dint) that do not use S5 timers

Ladder-logic examples
 

Similar Topics

Background Upgraded from an older TwinCAT 3 build (in the VS2010 shell) to the current one (in the VS2013 shell). Opened project created in...
Replies
1
Views
3,434
Can the Beckhoff experts (I know there are a few of you out there) provide some suggestions on the best way to organize links to physical I/O...
Replies
20
Views
12,023
Is there a way to make a variable non-volatile in a BC9000 when a digital input is cycled on / off? Change a variable to a constant? make the...
Replies
0
Views
1,631
I have a beckhoff bc9000 that i am attempting to program using the twincat IDE. How can I make the value of a variable equal to the value of an...
Replies
10
Views
6,963
Hi guys! Does anyone know how to share variables between two BECKHOFF controllers e.g.: BC to BC, BC to CX, BX to Twincat,... ???? I have a...
Replies
5
Views
3,663
Back
Top Bottom