4/2/2020 9:43 AM  
Joined: 12/18/2014 Last visit: 11/26/2020 Posts: 20466 Rating: (2232)

Rounding example: The main problem remains the same: That's why I asked you to explain exactly what you want to do. But I don't get that explanation. If you e.g. want to weigh something and the weight is around 335 g, if it were 0.335 kg. 
4/2/2020 2:29 PM  
Joined: 12/3/2018 Last visit: 11/23/2020 Posts: 65 Rating: (0) 
ixo65, I didnt quite understand your weighting example. Here is what I am trying to do: I am calculating the heat energy from momental and average power. I have 2 sensors for temperature (Vorlauf, Rucklauf) and liquid (heating water) flow sensor. I have calculated momental power and then average it over some period (one hour for the test). The power results are in 5th row of LOGO display (first momental and then average power). Then I calculate the gained heat energy in that hour. That is displayed in the 6th row. I would need to store this value and then add it to new value which comes next hour. This is the part which I don`t know how to program. AttachmentTest program.zip (15 Downloads) 
4/2/2020 2:54 PM  
Joined: 12/3/2018 Last visit: 11/23/2020 Posts: 65 Rating: (0) 
Because one hour is very long time for testing, I change a bit the program to be more "test friendly". The averaging time is one minute (you have to wait one minute to see the average value) and energy calculation can be done sooner with a press on C1 button, just to see it working. Some examples: Power 1000W (= 1kW) .... that means 1kWh energy in one hour. Power 1350W (= 1.35kW) ...... again 1kWh (because of rounding to lower number) Power 2730W (= 2.73kW) ....... gives a result 3kWh energy in one hour (because of rounding to higher number) If I want to calculate the energy in two hours, I need to store this value and add it to next one for the second hour. And so on... 32767 is big enough at this point. AttachmentTest program (shorter times).zip (12 Downloads) 
Last edited by: Frayer at: 04/02/2020 14:56:10 

4/2/2020 3:43 PM  
Joined: 12/18/2014 Last visit: 11/26/2020 Posts: 20466 Rating: (2232)

Hello Frayer, take a look at attachment. It's a possible solution. This solution counted your kW/h up to 999.999 kWh. With a litte trick and two counters more you can count up to 999.999.999.999. AttachmentTest program (shorter times)_V2.zip (21 Downloads) 
4/2/2020 4:56 PM  
Joined: 12/3/2018 Last visit: 11/23/2020 Posts: 65 Rating: (0) 
You solve not one problem, but two of them in one package Great. I don`t understand excactly how it works just yet, but I will try to... (can you explain just a little bit?) There is really no need for MW since 999999kWh should be enough for more than 5 lifespans of the measured machine (heatpump with expected annually energy produce of around 20.000kWh) Now I just have to change readings (calculations) from one hour back to one day, because rounding (cutting) of decimals bring less error on one day then on one hour because the day number is bigger. No biggie, it basically means that you will have to wait one day for a bigger number, but as I said, I plane to read it out once/month. Or maybe you have a solution even for that as well? 
4/2/2020 5:18 PM  
Joined: 12/18/2014 Last visit: 11/26/2020 Posts: 20466 Rating: (2232)

Hahahaha .... I guessed it. As soon as the solution to the problem is delivered, a second one is called up immediately. 
4/2/2020 9:36 PM  
Joined: 12/18/2014 Last visit: 11/26/2020 Posts: 20466 Rating: (2232)

Attached is a proposal on how you can save and add up the exact energy value in W/h every hour. If you inserted in your program then must you the follows: You have to reference your calculated energy value per hour to B011 (parameter V1). The value of 32,767 is also only for the simulation. In your program must you set to 0. AttachmentCounter.zip (23 Downloads) 
4/3/2020 1:26 PM  
Joined: 12/3/2018 Last visit: 11/23/2020 Posts: 65 Rating: (0) 
Hi, I put it together and now testing it. So, if I want to avoid rounding error, I have to calculate in Wh not kWh. That means the result will be in bigger numbers. This is a little bit unclear, because we are used to kWh. Maybe I will rather stick to your first solution with kWh and daily reading, I haven`t decided yet. I will test both versions and then decide. Can you tell me what is the purpose of "Protection active" setting of some bloc (I mean in general)? P.S.: Don`t be mad at me, I have to correct you since I am an electrician: the correct unit for energy is Wh (or kWh, MWh, Ws....) not W/h This is because you calculate the energy from power with equation " Energy (Wh) = Power (W) x time (h) " See "Misuse of watts per hour" in Wikipedia:https://en.wikipedia.org/wiki/Kilowatthour 
4/3/2020 1:33 PM  
Joined: 12/18/2014 Last visit: 11/26/2020 Posts: 20466 Rating: (2232)

The Wh value can be a max. of 32, 767 Wh. But you are not forced to take my solution either. 
4/3/2020 2:14 PM  
Joined: 12/3/2018 Last visit: 11/23/2020 Posts: 65 Rating: (0) 
Maybe we don`t understand each other... It is hard to communicate over keyboard in foreign language and the topic isn`t exactly light ;) If I stay at kWh (which I would prefer) I still get a rounding error in my B003: (dividing with 1000 is there because of translating from Wh to kWh) 
Last edited by: Frayer at: 04/03/2020 14:17:17Last edited by: Frayer at: 04/03/2020 14:19:54 

Follow us on