(0410812024, 06:35 Averaging an analog input - Vision & Samba PLC + HMI Controllers & Vis Logie Software - Unitronies Support Forum: Progr
Vision & Samba PLC + HMI Controllers & VisiLogic Software
p+
W% unitRonics’p)
+HMI
ALL IN ONE
Home > Vision, Samba, Jazz and M90 PLC + HMIs & Software
Vision & Samba PLC + HMI Controllers & VisiLogic Software Unread Content. y" Marksiteread
Rate this topic
Averaging an analog input
Bymuckingfuddle
March 20, 2021 in Vision & Samba PLC + HMI Controllers & VisiLogic Software
ner!
6 Good Morning Guys / Gals
lam trying to find a solution for a piece of test equipment that i have built for aclient, iam
muckingfud ing a smaawith Analog inputs and outputs and when we built the equipment the client
dle
sosed March 20, Wanted apeak reading, he snow asking for an average reading.
2021
The test being carried out is about 15 seconds long and the first 2 seconds are ignored so in
essence i need to average a reading from a 0-10v input for 13 seconds and display it on the
screen at the end of the test, iam hitting a total blank of how to do this my thoughts were to
take a sample every 1/2 second and add together and divide the end result but the amount of
code seems huge, is there a simpler way to do it or even a block i am missing, or cani create a
block with all this code in,
Thanks
+ Quote
bitpssforum xnitronics.comtopici8044-averaging-an-analog-input) 16(0410812024, 06:35 Averaging an analog input - Vision & Samba PLC + HMI Controllers & Vis Lagie Software - Unitronies Support Forum: Progr
How to get HELP:
ick to learn more!
MVP
2028
/ You're right, averaging can get really complex in a hurry, but the specific task you
SD rave seems pretty easy. Try this:
Flex727 gp ggg ap
70, gg M8 op 1Bey | god
Posted March 20, gg | Satacesing (000050) jeedo0 so
2021 : OBethe "Oe he
gs -—/r+—_{ +>—
Sy Meo MIO M2
[satin], “mM t
=I vi Bar
|? 18} 1B} —
Sy) weo
| Saas
P|
8. |
pater
Moss Tinet
a ae NEW NER
a me
wr chown Le
are rae Sm samba
Mo
g sum 1
i MEO
Stata
e S
i Ei
a
‘ waa wa
‘Sum CP nal Average
m2
Eis Number ot |
+ Quote oO
eo Isthere nota filter FB that could be used for that?
Visilogic juste crashed after that screenshot, so ican not check. But i would try with this.
vincentBsef
Posted March 27,
2021
-npsuforum.untronies.comtopici8044-averaging-ar-analog-input!
218(0410812024, 06:35 Averaging an analog inou- Vision & Samba PLC + HMI Controllers & Vis Logie Sofware - Unitronies Support Forum: Progr
fms fe en fet ath neem isan Meh
OBE ABE po ee RR AMOS TT AG OM: te mete we
Senn 7 Comer _> Hon nt Soe + ter Sys wen ona nn
@ ct
i—
Ud mone +
Ilowee
lel rommame +
=| So aaa
oo
ime ems Slee
ae eS
fa rea te
«x SEO O°
re
Yes there is, but tis limited to the amount of numbers it can work with. In simpler
cases | often cascade things.
Ausman
cheers, Aus
Posted March 27,
2021
+ Quote oO
MvP
2023 )
e +1 on what Aus says on the Filter imitation
I've had jumpy analog inputs I've had to filter up to 100 values. I wrote a routine that
stuffed a small data table that added the incoming value to a total and then stuffed it
ito the top of a data table after pushing all the other ones down and incrementing a
pointer. The pointer was the divisor of the total until it reached the total number of
samples that | wanted, and then | used it to point to the row of the data table that
had the oldest value and subtract it from the total before dividing it.
Joe Tauser
Posted March 28,
2021
Overkill? Yes. But very precise overkill with the ability to change the number of
samples on the fly.
JoeT.
+ Quote oO
nipsuforum.untronies.comtopii8044-averaging-ar-analog-input!
316(0410812024, 06:35 Averaging an analog input - Vision & Samba PLC + HMI Controllers & Vis Lagie Software - Unitronies Support Forum: Progr
Mvp.
2028
wanted an actual average, not a moving average.
For a 100 point moving average you could use Mls and indirect addressing, For 1000
points, you probably need to use a Data Table, as Joe suggests above, but for 10,000
Flex727
Posted March 28,
2021
points or more you're probably out of luck.
At one time I came up with a routine for an approximation of a moving average for
any number of points that I've never used, because | don't trust it, but I'm interested
in finding out if it might be useful. Simply subtract the average from the sum and add
the most recent data point then divide by the number of points to obtain the new
average, and repeat. Only 4 registers needed - the most recent data point, the sum,
the number of points total, and the average. I've simulated it in an Excel spreadsheet
and it appears to follow an actual moving average very closely, but I'm worried that
there is a flaw that I'm not seeing that might crop up under unusual circumstances. |
think | need a mathematician.
+ Quote °o
HiAll,ihave tried the solution provided by @Flex727 and the solution works pretty well, i
6 did have to change the MI inputs to ML inputs as the number was overrunning and becoming
muckingfud "*22tive, not really sure if thats the correct way butit did seem to work, one issue seem to
dle get.is that sometimes my analog input seems to go negative and that really screws up my
Posted March 29, average, is there a way to stop my analog input going negative, ido have a calibration
2021 adjustment which i would like to stop at 0 but can potentially go negative.
nipsuiforumuntronies.comtopici8044-averaging-ar-analog-nput!
48(0410812024, 06:35 Averaging an analog inout - Vision & Samba PLC + HMI Controllers & Vis Lagie Software - Unitronies Support Forum: Progr
ce
rela | wut | easy
cee
a
eee
(03/29/2021 at 4:43 AM, muckingfuddle said:
Flex727 cone issue i seem to get is that sometimes my analog input seems to go negative
Posted March 29, :
pes ' and that really screws up my average, is there a way to stop my analog
input going negative
Yes, insert this just above ladder rung 36:
6[819] |
| ALonaTeD 0
NEN iRP
ARB
wise |,
CALIBRATED
jo
+ Quote °o
Mvp:
aos iO
ow"
I recommend STORE DIRECT "Value" to "Variable" with condition (value:
kratmel
use "Variable" for calculate AVERAGE.
Posted March 30,
2021
If "Value"<0 then RESET "Variable"
In this case
is possible to generate error
no signal on input.
'Value" is not correct ("Value”<<0) with
ntpsforum.unitronis.comitopii8044-averaging-an-analog-nput 56Your content will need to be approved by a moderator
‘D Reply to this topic...