Step7 Data collection, sort of

dahnuguy

Member
Join Date
Mar 2007
Location
SC
Posts
720
I need to monitor the very slow drop of an oil level as the oil is consumed by a process. It will ocnsume the oil, it is supposed to.

I have a block now that samples the oil level every X time period and puts this value in a memory location.

As it moves the data to a new location, it compares the two last readings and gives the difference as the oil drop in that time period.

It then would compare each new oil drop to the first oil drop to see if we are using more or less now than when we started. Like a very rough trend.

I am using sample00 as the standard reference and then take 2 more samples 01 and 02 and then just overwrite the previous one and redo the compare .repeat forever.

I am getting to the point where I would like to do an average of more than just the last 2 or 3 readings.

Maybe take a reading every minute and then average them for the hour and day and week. And then I could display this rough trend on the HMI.

I think the best way to do something like this would be a table like in SQL.

Just keep adding new readings to the top and let the old numbers shift down and then out.

The average would always be updated.

I see how this would work in my head , but not translated into S7.

Does this sound reasonable?

Any ideas on how to do this S7?

I am going to look for a FC that might help, I thought I saw a database like table function somewhere.




I have read through several posts in an effort to find something like this.
 
CharlesM said:
What HMI are you using? Is it a panel or a PC?
178 COLOR TOUCHSCREEN.

I will be using these numbers in the PLC for other calculations and I want the machine to run if the HMI fails.

So the question should have been prefaced with "How do I do this with a 313C PLC.........."

Just forget I said HMI.
 
dahnuguy said:
I think the best way to do something like this would be a table like in SQL.

Just keep adding new readings to the top and let the old numbers shift down and then out.

Do a search on "UDT" and "SFC 20". If you aren't using UDTs in your program, you're doing it wrong. It makes life a lot easier.
 
I used sfc20 in another part of the project.

The place I used it, allows a selection bit to do a move that takes a set of variables from a list in the DB. I used a UDT to make a list of variables. So there are 5 sets of 4 for example and I only need 4 variables at a time, but they are different for each occasion.

I know that doesn't read well.

SO in that case I would have an input bit that would enable a blkmov from DVXX into DBYY. Where DBXX has a\all the varables and DBYY has just the ones being used right now from the main list.

That works great and is nice.

This situation needs to have an empty DB into which I would add one varable of set size and type.

Each time I move a new piece of data into the DB the previous piece would move down the list and eventually off the end.

All the data would be numerical and would indicate a changing level.

These would then be averaged and or referenced elsewhere.

In this case there would be one piece of information added periodicaly to the top of the list.

I think I read something in S7 about this very thing, but I don't recall were or what the magic name was.

I'll find it again eventually. I remember thinking, that's exactly how SQL does it. Lots of PC like functions in S7.
 
Do a search on SFC 20 Block Copy, and there will be numerous examples of shifting data as you describe. You may or may not need a scratch data block, depending on the direction you are copying. Personally, I like to have my newest data in the lowest bytes so that when I open up the block, it's right there.

But in a nutshell, you would copy the entire block to another data block, and then copy it back, starting at the byte offset that you want to shift to.
 
S7Guy said:
Do a search on SFC 20 Block Copy, and there will be numerous examples of shifting data as you describe. You may or may not need a scratch data block, depending on the direction you are copying. Personally, I like to have my newest data in the lowest bytes so that when I open up the block, it's right there.

But in a nutshell, you would copy the entire block to another data block, and then copy it back, starting at the byte offset that you want to shift to.


I saw something like "add to table" that would just put the new one in and move the others down.

I am stuck doing other stuff today, so I haven't been able to look it up yet.
 
FC90........WSR word shift register

Description


Th WSR function shifts data into a shift register from the indicated source. Each value is moved into the next location. LENGTH specifies the number of locations to be shifted. The data contained in the last location of the shift register is lost after the shift. New data is read from the source (S_DATA) each time the instruction is executed; this data is shifted into the shift register starting location (START) when the RESET input is set to 0. If the RESET input is set to 1, the register location is set to zeros when the instruction is executed. The output Q is turned on when the shift register is empty or cleared (that is, after a reset or after all zeros are shifted in).

I think I will try this, the one I was thinking of was ATT FC84 but this one should do it all by itself.

Add data shift down repeat.
 
Here is what I came up with.

Put everything in one DB....DB96 , the first entry is how many entries to look at for the STD DEV block that comes next and then the 10 pieces of data which are the slowly desending oil level and then the last entry is where the STD DEV is placed.

I may not use the deviation but I thought I would play with it.

FC90_OIL_LVL_01.jpg



FC90_OIL_LVL_02.jpg
 

Similar Topics

Product: STEP7 Professional V13 Reference: FB Declaration Static: Data type TON is not allowed here Description...
Replies
2
Views
2,672
Hi all. I use kepware opc to read data from Matlab, it works fine. Now i want to move these data to step 7, how can i read data from OPC to step 7...
Replies
2
Views
3,224
Hi, Just wanna pick some brains here. Problem: PLC1: S7-315 with CP343 PLC2: S7-414 with CP443 PLC1 contains 12 DB's that needs to be tranferred...
Replies
3
Views
1,996
I am working on an application where I am controlling the ramp of a web and I want to increase the web speed by .1 feet per minute every x...
Replies
14
Views
5,147
This is probably one for Jesper or Daniel. I want to use FB126 to replace the FC125 that I used in an old project which is being used as the basis...
Replies
8
Views
10,736
Back
Top Bottom