1/8/2021 9:34 PM  
Joined: 12/3/2018 Last visit: 10/18/2023 Posts: 75 Rating: (0) 
Hi, i would like to know the accumulated average value of temperature, which is monitored via analogue input. First thing that I did was to check out the incorporated average block, but it wont be OK because as a parameter you have to set an exact period of monitoring time in advance, which I don`t know... I would like to monitor average value of "vorlauf" temperature of heating system but only in the working cycles (when heating system operates, not during pauses). This period time changes and cant be predicted. Sometimes the working period is 20 minutes, sometimes 50 or much more... and the pause between them is also different every time. The average value should be for all periods (until reseted), not for just one period. So I would need a program which is somehow based on some clock and it should calculate average every minute or so.... I think something like this is an possible approach, but I dont know how to program it in LOGO: Any help would be appreciated. 
Last edited by: Frayer at: 01/08/2021 21:36:20 

1/9/2021 3:44 AM  
Joined: 12/18/2014 Last visit: 12/1/2023 Posts: 31530 Rating: (3916)

You can't simply convert all functions of an S7 FB into LOGO! programming. And I don't understand why the average value shouldn't be formed continuously. I can't see the LOGIC in it.

1/9/2021 4:17 AM  
Joined: 12/18/2014 Last visit: 12/1/2023 Posts: 31530 Rating: (3916)

Maybe this is what you want.
AttachmentAverage_0BA8.Standard.zip (200 Downloads) 
1/9/2021 10:42 AM  
Joined: 12/3/2018 Last visit: 10/18/2023 Posts: 75 Rating: (0) 
It should be formed continuously... but the sample time is unknown in advance. That`s why I choosed 1 minute, but the average should be cumulative, not only for the last minute but for the whole f.i. 20min, 45min or any other period lenghts. And for more periods, not only for one (until reset). About your program: I have hard time to understand it in order to test it, that`s why I don`t know if it fits altogether. I change it a little to more match my situation and for easier following (please, see ver2). Please, can you explain just a little bit:  where can I read out an average output? Is it B005 Aq?  sampling time is every minute? Where can I change that, if needed?  can I reset the calculated average value somewhere and force it to begin calculation again? I tried to test it like this but it gives me strange results:  for the first minute I set A1 at fixed 10°C  after one minute B005Aq displays  10° which is OK (if this should be output)  for the second minute I quickly set A1 to +10°C  after second minute past, the output should show average for BOTH minutes 0 (10 + 10 = 0) but it shows me 10° So I think, it only calculates the average of last minute and does not include old values. Basically it works like normal average block without anything around (that why I put the B007 next, for comparision). About the I1 (working period simulation): if I set it to zero  that would mean pause in heating  in that offtime the average temperature should be freezed to last calculated state, until a new heating period is started. I think now is not working this way? It just puts a new value to output, which is not good. But as I said, maybe I just don`t know how to use your program. AttachmentAverage_0BA8.Standard_v2.zip (146 Downloads) 
1/9/2021 10:44 AM  
Joined: 12/3/2018 Last visit: 10/18/2023 Posts: 75 Rating: (0) 
Maybe this picture of vorlauf temperature of various lenghts will help: I would like to know the average for the all ON periods, not just for last minute: 
1/9/2021 1:50 PM  
Joined: 12/18/2014 Last visit: 12/1/2023 Posts: 31530 Rating: (3916)

I'm sorry, but I got you completely wrong. You have to find another PLC for what you want. Your link with the reference to an S7 and an FB works in the LOGO! not because the LOGO! does not have the memory by means of data blocks. That's why I save myself the explanation. In my opinion, some users expect too much from the LOGO !. The LOGO! is not a PLC such as an S7. Even Siemens describes the LOGO! as a programmable relay.

1/9/2021 5:49 PM  
Joined: 2/22/2008 Last visit: 11/30/2023 Posts: 2698 Rating: (203) 
Frayer, that's not difficult to calculate an average for a limited amount of values. Also the S7 FB average cannot calculate endless values, because for arithmetic average you need to sum all values X1, X2, X3 ... Xn and devide it by n. For this you need n blocks to store the values. Depend on your application and free resources it may be possible to use e.g. 50 values. For this you need 50 Min/Max blocks to store the values and several arithmetic blocks to calculate the average. See attachment for an example with 9 blocks and additional arithmetic. The calculation is splitted, a group of 3 blocks needs 1 arithmetic block. The 3 arithmetic blocks needs a final arithmetic block. If you need more values for average, the program will grow up more and more with higher amounts. The example has a pulse generator TH=0,5s and TL=0,5s for simulation with 1s. Change it to TH=30s and TL=30s for 1m. Then you can calculate the average for 9 minutes for active mode (I1=On). Expand the Min/Max chain for your desired amount of values depend on your free resources. Regards, Scorp AttachmentAverage1.zip (153 Downloads) 
This contribution was helpful to1 thankful Users 
1/9/2021 9:59 PM  
Joined: 12/3/2018 Last visit: 10/18/2023 Posts: 75 Rating: (0) 
Thanks, I really didn`t expect this to be so complicate or source consuming... OK, I would like to know an average for at least of one (last) ON cycle, but even this this could last anywhere from 20 to 180 minutes or so. It is possible only if I change average reading to 20 minutes instead of 1 minute in your program. I asked my friend (a S7 programmer) what he would do (even before I asked here). He gave me a proposal with S7 blocks... but I didn`t know how to translate this to Logo so I asked here for a opinion. Please, take a look on this  is it basically correct concept and could this be made with Logo? (I thought that network I/O works similar as data blocks in S7) p.s. he propose triggering reading based on difference in values, not on clock. I dont know which is better or easier on processor 
Last edited by: Frayer at: 01/09/2021 22:02:59 

1/9/2021 11:11 PM  
Joined: 2/22/2008 Last visit: 11/30/2023 Posts: 2698 Rating: (203) 
There are 2 different methodes to calculate the arithmetic average. The first one is the described methode to store all values and then build the sum and device by amount of values. Sure there is a second methode, which can be used with S7. All values are added directly and a counter is used for the amount of values. Then you have X1+X2+X3....+Xn and n. But this methode you can not use in the Logo, because you only have 16 bit integer values from 32768 up to +32767. May be with some tricks it's possible to create higher values (e.g. 32 bit) to reduce the amount of blocks from my first example. But this is also very complicated and i only can try to find a solution. For this i need the information, which values you have, 100 to +100, 1000 to +1000, 10000 to +10000 ? If you are not fixed on a Logo, it would be better to use another logic controller with 32 bit integer. You can add e.g. 10000 for >400000 times, before there is an overflow. In Logo you only can add 3 times. You see the difference ? Generally you also have to check, if arithmetic average is the right value for your function. Have a look at Wikipedia for different averages, arithmetic, geometric, harmonic ... Regards, Scorp 
1/9/2021 11:31 PM  
Joined: 12/3/2018 Last visit: 10/18/2023 Posts: 75 Rating: (0) 
yes, I see the difference.. About the values: maximum values after 010V conversion are 20°C to 60°C but in reality the Vorlauf temperature of heatpump is somewhere between 20°C and 55°C. (COP of heatpump is greatly dependent of outputVorlauf temperature, thats why I am interested in monitoring and analysing it) I will check out that explanation of averaging too. ____________________________________ A correction: 20.0 to 55.0 is only a display on message text with one decimal point. The real calculated values behind are 200 to 550 
Last edited by: Frayer at: 01/09/2021 23:36:40Last edited by: Frayer at: 01/10/2021 08:32:02 

Follow us on