How to use Up/Down Counter in Step 7?

plcnoviceguy

Member
Join Date
Mar 2007
Location
Canada
Posts
2
I need to know how to use the Up/Down counter in Step 7 STL.

Just need the basics IE: How to call to it in STL and how to increment/decrement. Thanks!
 
Hello plcnoviceguy;

I found that the easiest way of understanding the STL functionnalities, for a beginner, is to write the code in LAD, study all the inputs and outputs of the block I want to understand (use the F1/help functionnalities or the program manual), and then translate the block from LAD to STL (View menu in the LAD/FBD/STL editor).
Something like this:

C_U_D.jpg



Hope this helps,
Daniel Chartier
 
plcnoviceguy said:
I need to know how to use the Up/Down counter in Step 7 STL.

Just need the basics IE: How to call to it in STL and how to increment/decrement. Thanks!

As a novice , I would call it in ladder first , you may find it easier to understand compared to STL .

This is yet another case where there is absolutely nothing to be gained by using STL .
 
Note that the Siemens in-built counter counts from 0 to 999

Also available is SFB2 which counts in the range -32768 to +32676
 
As L D[AR2,P#0.0] said, the siemens counters only count to 999, but it is very easy to create your own counters that will count to 2.147.483.647ish

And as said above, of you don't know it in STL, try it in LAD, convert it to STL and try to figure it out. And use the help files. There is alot of nice info hidden in there.
 
Maybe a little question...

10BaseT. said:
As a novice , I would call it in ladder first , you may find it easier to understand compared to STL .

This is yet another case where there is absolutely nothing to be gained by using STL .

I agree, but I do have a question.

Sometimes we want to avoid timers and counters by doing this:

For Counters:

A I 0.0
FP #mem1
JCN PRES
L #COUNT
L 1
+I
T #COUNT
PRES: A I 0.1
FP #mem2
JCN DECR
L 15
T #COUNT

DECR: A I 0.2
FP #mem3
JCN END
L #COUNT
L 1
-I
T #COUNT
END: L #COUNT
T MW 10

For Timers:

A I 0.0
A M 0.5 // pulse every second
FP #mem1
JCN OUT
L #TimeV
L 1
+I
T #TimeV
OUT: L #TimeV
L 10
>=I
= Q 0.0
RES: A I 0.1
JCN END
L 0
T #TimeV
END: NOP 0

// After 10s, Q0.0 is high
// M0.5 is a bit of the clock memorybyte in the CPU

Is this good or bad, and why ?
 
Just add or subtract 1 in conjunction with a one shot to a double integer. It is not elegant but it is simple and works.
 
Well I posted "my" solution a while back , I use the last cycle time generated by OB1 as the time base for a roll your own timer - you can also change the time on the fly , and lift the elapsed time as well if required - take a look , you should be able to find it . There is a slight flaw in the accuracy ( 1 cycle time over) - but within a few milliseconds is enough for most applications .
From the outside the block looks like an IEC timer .
 

Similar Topics

I am using LOGO Soft Comfort V8.1 I am trying to reset a UP/Down Counter when it reaches a certain value but I can not find the way to do it, does...
Replies
7
Views
5,100
I am new to PLCs just started doing this about a month ago. I want to write a ladder program using directsoft5 for DLO6 . The program should have...
Replies
10
Views
4,296
Hi to all, i am newbie on plc. I would like to make a down counter with preset value 3. Counter from 3 must goes to 2 after 2min, from 2 to 1...
Replies
4
Views
2,398
Here's the situation: operators print off labels for finished products, scan the barcode on the label, apply the label to the products and place...
Replies
8
Views
5,212
hi, I am working on mitsubishi PLC Fx1N. I have a table of rollers driven by a motor. Table length is 3 mtr and width is 2 mtr. this table is a...
Replies
2
Views
4,087
Back
Top Bottom