Sign in to follow this  
Followers 0
MarisK

Time measurement with S7-315

12 posts in this topic

Hello! Please help! I need to measure movement time. I have S7-CPU315-2DP with digital input module SM321. For detection of movement I have two photo sensors. So the problem is that I didn't know what STL instruction I must use for determine the movement time from first to second photo sensors. It seems that the traditional S5 timer instruction is not usable in this case. The problem is simple, but I dont now how to resolve them. Is anyone can help me? Maybe with some program example? Thanks in advance! Maris

Share this post


Link to post
Share on other sites
Just brainstorming a bit here. What if you set up an S5 timer with a preset much longer than any elapsed time you would expect to see? You could then start the timer when the part passes the first prox and grab the current remaining time when the part passes the second prox. Then do some math with the remaining time and the preset to determine the elapsed time.

Share this post


Link to post
Share on other sites
Yes, I have seen an app where the timer was set to the max value. Input 1 turned on the timer. When input two was triggered, the accumulated value of the timer was captured using a mov instruction. The timer was reset by Input #1, so actually on the trailing edge of input 1 the timer would begin to count. The timer would just run till max if no parts tripped the sensor, but every time a part went by, leading edge and true would reset the timer, and trailing edge it would start and run till next trip or complete. It seemed fairly simple. If neccesary, with a little manipulation you could start the timer on leading edge using a one shot rising for the timer reset.

Share this post


Link to post
Share on other sites
How long can it take at maximum?

Share this post


Link to post
Share on other sites
What is the possible range that needs to be measured and to what resolution are you trying to measure? Is it 5-10 seconds to the nearest 0.1 second? Or is it more like 20-30 milliseconds to the nearest 5ms? The methods you can use vary by the requirements...

Share this post


Link to post
Share on other sites
Measuring range is about 1-5 seconds. Resolution is 10 ms (for S7-300). I found that: https://support.automation.siemens.com/WW/llisapi.dll?func=cslib.csinfo&objId=29598009&load=treecontent?=en&siteid=cseus&aktprim=0&objaction=csview&extranet=standard&viewreg=WW But the program example is for Step7 v5.5m. I use Step7 v5.4 so I can't open this file.

Share this post


Link to post
Share on other sites
It will be very helpful, if You write down your idea in STL format. It is first time when I working with timers. The parts will not trip regulary. This will be an experimental device for testing wear (sliding time) of random parts. Thanks in advance, Maris

Share this post


Link to post
Share on other sites
As I understand, then the program will be like this (see attach.): Where: I4.1 - first sensor I4.2 - second sensor I4.3 - reset button And I need to just calculate triping time? prog.bmp

Share this post


Link to post
Share on other sites
Do you need the time to be from positive edge of first sensor to negative edge of second sensor or in some other fashion?

Share this post


Link to post
Share on other sites
I need the time from positive edge of first sensor to positive edge of second sensor (time from point A to point B).

Share this post


Link to post
Share on other sites
Example, accuracy is ~time of one cycle.

Share this post


Link to post
Share on other sites
Forget the S5 timers. Use the IEC timers in stead. It uses the time in TIME format, which increments in milliseconds. In order to for example add or subtract TIME values, you will hit a small problem because the mathematical functions expect the type to be DINTs so the typechecking will fail. The simple solution is to use STL, since there is no typechecking in STL. Just a small sample : L "my_IEC_timer".ET // load the expired time as TIME value. T "some_DINT_address" // transfer to a Merker or Datablock doubleword with DINT type.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0