Switch to desktop version  
efficiency calculation in the BASIC IDE - Printable Version

+- Ewon Technical Forum (https://techforum.ewon.biz)
+-- Forum: Development (https://techforum.ewon.biz/forum-50.html)
+--- Forum: BASIC Script (https://techforum.ewon.biz/forum-52.html)
+--- Thread: efficiency calculation in the BASIC IDE (/thread-899.html)



efficiency calculation in the BASIC IDE - dnwangu - 11-04-2019

Hi 


i am still fairly new to using the flexy 205, i need to calculate efficiency using the formula, i have created the Pump_efficiency Tag as MEM and the other parameters is data received from a PLC

Pump_efficiency@ = flow@ * pressure@ / power_used@

please can you kindly assist me


RE: efficiency calculation in the BASIC IDE - ziozetti - 11-04-2019

I made a test on Flexy 201 with latest firmware using my tags.
This syntax works:

%test = flow@ * pressure@ / power_used@

Now I have problems with connection so I can't make other test, I'm sorry...

EDIT: it works also with mem tag.


RE: efficiency calculation in the BASIC IDE - ziozetti - 11-04-2019

Uhm... let's considering you are totally new to eWON BASIC:
Create a section called calculation

In Init section write:
Code:
ONCHANGE "flow","GOTO calculate"
ONCHANGE "pressure","GOTO calculate"
ONCHANGE "power_used","GOTO calculate"

Then in calculation section write:


Code:
calculate:
Pump_efficiency@ = flow@ * pressure@ / power_used@
END



RE: efficiency calculation in the BASIC IDE - dnwangu - 12-04-2019

Hi Ziozetti


thanks alot, the solution works.


RE: efficiency calculation in the BASIC IDE - dblake - 22-04-2019

May I suggest that while Ziozetti's solution works, it needlessly burdens the processor.  The three monitored variables are analog and will likely change every code cycle.  That means that you will be calculating the efficiency 3x every cycle.  Why not calculate the efficiency on a fixed time period, say once every second.

Code:
// Replace the three ONCHANGE instructions with these TSET and ONTIMER instructions.
TSET 1, 1
ONTIMER 1, "GOTO calculate"

As an improvement to the calculate routine, you can smooth out the result by calculating a running average over a one-minute period (60 readings).