PLC programming question

arocon

Member
Join Date
Oct 2006
Location
Dubai
Posts
171
I need to do continuously comparing of a analog value between current and 2 seconds earlier value. Could any one tell me how to program it ? In general PLC or Siemens simatic S7 PLC.

Thank you.
 
Let's talk a bit of reality here. Since the PLC has a scan with a finite scan time the comparisons cannot be CONTINUOUS. So the question is - how often will fast enough to be considered continuous? Some analog don't change extremely rapidly. If they did we'd be talking about a separate signal processor chip or an analog circuit with a two second analog delay line. Let's say, for argument that every 1/10th of a second is fine. Make a 20 place long FIFO register. Each 1/10th of a second get the current reading, compare to the oldest reading on the FIFO stack, take whatever action is appropriate, then push this newest reading on the stack and wait another 1/10th of a second.

Adjust the FIFO length and delay as needed. Watch out for that pesky scan time.
 
Last edited:
not every 2 second. it needs to compare current value with earlier 2 secs value in every plc scan time.
 
I think my interpretation in post #2 especially given arocon's reply in post #5 that he intends a continuous (as possible) comparison of the latest analog input with the one from 2 seconds before. This would have to be as fast as the scan and the analog input's conversion rate would allow. Not one comparison every 2 seconds. Doing it every scan would be problematic because how many scans back is 2 seconds ago? Scan times can vary. And comparing more often that the analog input conversion rate adds no new information.
 
yes, but with interrupt he can have same time between samples. if scan time is less than 150ms he can set interrupt for 200ms so he will have 10 samples. create array of 10 or 11 samples and calculate diff between last 10 samples re-writing the the data block, something like in pseudocode:

diff=curr-db1.dbd
db1.dbd=curr
i++
if i>10 then i=0
 
...he intends a continuous (as possible) comparison of the latest analog input with the one from 2 seconds before.
Another interpretation is that he must have saved a reading every two seconds, otherwise he will not have one from "2 seconds before". That automatically sets the sample time, as shown by JRB's example.
 

Similar Topics

Hello. Was just curious, if it is possible to load an image from an SD card on to a Compactlogix PLC that came straight out of the box brand new...
Replies
4
Views
545
How do you code it to when you push a button attached to X001, it turns on Y001. Then, the next time you push the button attached to X001 it...
Replies
4
Views
1,611
I have a function block (FB1) which uses internal tags and has made a data block (DB1). I have a created a PLC data type with around 15 tags and...
Replies
2
Views
1,688
Hi, I have a question about plc programming as a second job and whether anyone currently does this. I work full time for a company (not plc...
Replies
20
Views
4,676
Hello, We are a mechanical engineering senior deign team from the University of Houston building an automated beer brewing system known as HERMS...
Replies
12
Views
4,616
Back
Top Bottom