Step7. Calculating of quantity of bottles (trays)

Valera

Member
Join Date
Jan 2004
Location
Saransk town Russia
Posts
147
There is task for me. It was put me by my boss. I must write program (add to exist program) for calculation quantity of bottles and trays and palletts. I think, my way is: install fotosensor for count bottles (Omron E3S-R1B4) then connect signals from fotosensor to digital input of modules SM323. Next I read this input to DB doublewords (type must be DINT). Next task is put this value to OP-17.
My question is: how I can count for fixed interval of time (08.00-20.00 then 20.00-08.00 for shift). What function must I use for it?
 
I don't know Siemens (this IS Siemens, right?), but I would think you'd want to take advantage of the real-time-clock in the PLC (or read it from the HMI). Use comparison instructions to trigger a one-shot (positive differential) at the start of each shift. Use this one-shot to transfer the current counter value to a separate register for display. Also use this one-shot (AFTER the value transfer) to reset your counter to zero.

In ladder, something like this:

| HOURS = 08 MINUTES = 00
|------] [-------+-------] [---------(PD)
| |
| HOURS = 20 |
|------] [-------+
|
| PD
|-----] [--------+----> MOVE COUNTER VALUE TO REGISTER
| |
| |
| +----> RESET COUNTER


The one-shot will allow you to update the shift's count and reset the counter ONLY at the START of each shift. Of course, the PLC must be in RUN mode at the shift transitions, or the one-shot will never fire.

This is not the ONLY way to do this, it's just a quick idea to get you going.

If you don't have a real-time-clock available, you could add a cheap external weekly timer (like THIS for example) to turn a relay on and off at each shift change. The relay contacts would connect to an input to trigger the counter update.

Remember that you may have to debounce (add short on and off-delay timers to) your photoeye input to get accurate counts!... (n)

beerchug

-Eric
 
If you need to execute tasks at certain times, one way to do it is to use SFC 1 ("Read Clock"). You can find this in the Siemens Library. You would have to make sure the PLC clock is accurate, and then you would call SFC 1 every few seconds and check the time. When it switches over to the next shift, you can do all kinds of "housekeeping", such as copying the "Current Shift" total to a "Previous Shift" total area, or whatever else may be shift-specific. By the way, since the PLC system clock tends to drift over time, there are some methods of keeping it accurate if you aren't there to adjust it every few weeks or so.

Here's a quick example of how you could evaluate the date and time (in this case, I am executing a function every Sunday at 2PM so I can reset some weekly production totals; and, the ReadCurrentTime is passed into local variables LB0-LB7):


CALL "READ_CLK"
RET_VAL:=#Return
CDT :=#ReadCurrentTime
L LB 0
T "Weekly Reset DB".Reset.Year
L LB 1
T "Weekly Reset DB".Reset.Month
L LB 2
T "Weekly Reset DB".Reset.Day
L LB 3
T "Weekly Reset DB".Reset.Hour
L LB 4
T "Weekly Reset DB".Reset.Minute
L LB 5
T "Weekly Reset DB".Reset.Second
L LB 6
T "Weekly Reset DB".Reset.MillisecMSB
L LB 7
SLW 12
SRW 12
T "Weekly Reset DB".Reset.DayOfWeek

A(
L "Weekly Reset DB".Reset.DayOfWeek
L 1
>I
)
R "Weekly Reset DB".Reset.ResetComplete

A(
L "Weekly Reset DB".Reset.Hour
BTI
L 14
>=I
)
A(
L "Weekly Reset DB".Reset.DayOfWeek
L 1
==I
)
AN "Weekly Reset DB".Reset.ResetComplete
JC rst
BEU

rst: L 0
T "Production”.TotalWeekly
T "Production”.Machine[1].Production.Weekly
T "Production”.Machine[2].Production.Weekly
T "Production”.Machine[3].Production.Weekly
T "Production”.Machine[4].Production.Weekly
SET
= "Weekly Reset DB".Reset.ResetComplete
 
Hi S7GUY pretty need programming, but I'm afraid I only understand partial what you do with the program.
Would it be mutch to ask for some comments in between the program?
Just a small explanation with what you do with the code.

Thank you in advance
 
No problem JvdV, always glad to help. I've added some comments. Keep in mind that "Weekly Reset DB" is an actual Data Block, so if you want to try this out, just substitute your own absolute addresses:

CALL "READ_CLK" //Call SFC 1, "Read System Clock"
RET_VAL:=#Return
CDT :=#ReadCurrentTime

//***************************
//Load each byte of #ReadCurrentTime and transfer
//them to data bytes. This wouldn't be
//absolutely necessary, but it's nice to go online
//with the block and see what the current time is.
//Use the Siemens Help to see the "Date and Time"
//format to see why I have to SLW12 and SRW12 on LB7.
//***************************
L LB 0
T "Weekly Reset DB".Reset.Year
L LB 1
T "Weekly Reset DB".Reset.Month
L LB 2
T "Weekly Reset DB".Reset.Day
L LB 3
T "Weekly Reset DB".Reset.Hour
L LB 4
T "Weekly Reset DB".Reset.Minute
L LB 5
T "Weekly Reset DB".Reset.Second
L LB 6
T "Weekly Reset DB".Reset.MillisecMSB
L LB 7
SLW 12
SRW 12
T "Weekly Reset DB".Reset.DayOfWeek

//***************************
//After I have executed the weekly event that
//occurs each Sunday (Sunday=1, Monday=2, etc),
//the next day I reset the "Reset Complete" bit
//in my data block. By comparing the current day
//against "1", you can see that it will be reset
//every Monday.
//***************************
A(
L "Weekly Reset DB".Reset.DayOfWeek
L 1
>I
)
R "Weekly Reset DB".Reset.ResetComplete

//***************************
//Siemens uses the BCD format in the Date And Time,
//so I have to use the BTI instruction to convert
//it to an integer. In this section, I check to see
//if it is 1400 hours (2PM) and if it is Sunday (day
//of week = 1). If it is not, then I don't jump
//to label "rst", and I end the block.
//***************************

A(
L "Weekly Reset DB".Reset.Hour
BTI
L 14
>=I
)
A(
L "Weekly Reset DB".Reset.DayOfWeek
L 1
==I
)
AN "Weekly Reset DB".Reset.ResetComplete
JC rst
BEU

//***************************
//If it has reached 2PM on Sunday, I jump to
//"rst" and transfer a zero to all of my weekly
//production counts for each machine as well as the
//total production. I also set the "ResetComplete" bit
//as a way to create a one-shot (see the comparison
//above) so this is only executed once.
//***************************

rst: L 0
T "Production”.TotalWeekly
T "Production”.Machine[1].Production.Weekly
T "Production”.Machine[2].Production.Weekly
T "Production”.Machine[3].Production.Weekly
T "Production”.Machine[4].Production.Weekly
SET
= "Weekly Reset DB".Reset.ResetComplete
 
Generally there are clearly.
One question: If I want to have history for data of shift's quantity like: 01.02.2004 20.00-02.02.2004 08.00 100.000 bottles
02.02.2004 08.00-02.02.2004 20.00 110.000 bottles
02.02.2004 20.00-03.02.2004 08.00 100.000 bottles
then I can use DB words for save and FIFO or I can use features of OP-17 (operator panel Siemens)? I don't familiar with OP-17.
 
If all you want to do is display production totals for each day for the last year, then you could definitely set up a FIFO. Then, the OP (or any other HMI) can just read the tag values straight from the PLC. Basically, the amount of your archived data would only be limited by the CPU memory. To shift the FIFO, use the SFC Block Move.
 
bottles??

In my field we count bottles also. I was wondering if these are plastic clear or colored bottles? Also the speed at which the bottles move are going to be another factor. I would highly recomend going with some type of smart photoeye sensor that can be calibrated if you are moving clear(transparent) bottles at a high rate of speed. These "smart photoeyes" normally come with an RS-232 hookup and software to fine tune the sensor for your process. Good luck

Dallas Smith :D
 
to "eastkodakguy"
Must be counted empty transparent glass bottles, full bottles, trays.
Can you send me blocks of Step7 that is used for counting? So I will build my block on the foundation of these ones. I read language of STL very well, but when you must write from scratch this another case. I think so.
 
How is used SFC1? Step7 read time

Just I try to use SFC1 in real. I get fault. I can't manage with parametrs of SFC1. Can anybogy advise me for exatly way to write code of calling SFC1. I try call SFC1 in OB1 trough CallCondion but maybe it is impossible.
Please help (what type of parametrs etc) I have read Step7 help but nothing.
 
Valera, when you say you get a fault, do you mean an internal fault on the PLC? Or do you mean you have a fault while entering the parameters while programming the function?

You can call it in OB1, so that isn't the problem. If you look at my example above, you'll see that the two parameters are local variables. The return value is just an INT, but the other one is type DateTime. Add these two variables to your local data stack in the block you are calling SFC1 from, and it will work. Also, make sure you copy SFC1 from the system blocks library to your project folder.
 

Similar Topics

Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
74
Hi all, I am trying to convert RSLogix 5000 program to Step7. I need to bit shift left my array of double integers for tracking the product on...
Replies
2
Views
504
I have a word in some DB which I want to load to AR1 and use as a pointer. In order to do this I need to write L DBxy.DBW xy SLD 3 LAR1 I...
Replies
3
Views
506
Hi, is there any way to export all contents of Block folder (OBs, FBs, DBs, etc) to a text file? I know it is possible to export symbol table, but...
Replies
5
Views
1,198
Hello, When trying to enable the Operator Control & Monitoring features in Data blocks of the Step 7 5.7 project it gives the Error of Operator...
Replies
0
Views
894
Back
Top Bottom