Frobozz
Member
Hello everyone. I'm still trying to wrap my head around PLC programming having come from a traditional computer programming background. I've been struggling to figure out how to do the following.
I want at some point in my program to take 1 reading from an analog input every second for 10 seconds, then take the average of those readings.
The part that's stumping me is the loop. I can use For and Next rung parts, set the loop for 10 cycles, but when I run the program, there's no delay, the loop takes 10 readings milliseconds apart. When I try to put in a 1-second timer, I need to split it between rungs and I can't wrap a For and Next between rungs. I tried to just manually "set" the NO condition that starts the cycle, and "reset" when 10 have passed figuring the program would naturally loop to the next one, but I can't seem to get it to continue after the first pass.
Is there some easier way to do this? I kinda figure it can't be that uncommon of a thing to take an average of several analog readings over time.
I want at some point in my program to take 1 reading from an analog input every second for 10 seconds, then take the average of those readings.
The part that's stumping me is the loop. I can use For and Next rung parts, set the loop for 10 cycles, but when I run the program, there's no delay, the loop takes 10 readings milliseconds apart. When I try to put in a 1-second timer, I need to split it between rungs and I can't wrap a For and Next between rungs. I tried to just manually "set" the NO condition that starts the cycle, and "reset" when 10 have passed figuring the program would naturally loop to the next one, but I can't seem to get it to continue after the first pass.
Is there some easier way to do this? I kinda figure it can't be that uncommon of a thing to take an average of several analog readings over time.