Switch to desktop version  

Ewon TechForum
Providing technical solutions to technical requests



Simple Math!
insyncs
Member
#1
Hi can you help please,
 
Trying to compute some simple math in the ewon but I’m not getting anywhere with it.  Have looked through reference manual,  but cannot find a math example.
 
“Running_Hours%” is a Dword,  “ComAp_Running_Hours_MSB%” is an INT “ComAp_Running_Hours_LSB%” is an INT
 
I cannot get any values from the calc into the “Running_Hours” tag, even if I use Running_Hours% =1
 
The % needs to be added at the end of the Tag as per the manual for an INT – doesn’t cover a DWord so % is probably wrong, have tries without also.

Code in basic IDE:


Code:
$Running_Hours% = (65536 * $F_Running_Hours_MSB%) + $F_Running_Hours_LSB%



All I want to do is put two 16bit values into a 32bit word.  

Cheers


Attached Files
  eWon.png (Size: 6,33 KB / Downloads: 12)
Reply

simon
eWON Support
#2
There is no need to put a $ char in front of the variables unless it is a local variable of a function (which is not your case).

See an example that works :



Code:
F_Running_Hours_MSB% = 195
F_Running_Hours_LSB% = 80

Running_Hours% = (65536 * F_Running_Hours_MSB%) + F_Running_Hours_LSB%
PRINT Running_Hours%
Reply

insyncs
Member
#3
Hi,

Thanks for the response. It doesnt work for me.

a bit more info for you. the two tags below are modbus tags:

F_Running_Hours_MSB%
F_Running_Hours_LSB%

I want to read the values from the modbus tags, then create a 32 bit value stored into Running_Hours%( Local memory variable?)

hope that's clear?

PS can you help me change my username so its not my email!

Cheers
Reply

insyncs
Member
#4
ok got there thanks.

i some how deleted the format of the script template so i guess it wasn't being called.

this is what i used in the end thanks.

// Calc For Historical Report
Running_Hours_MSB% = Running_Hours_MSB@
Running_Hours_LSB% = Running_Hours_LSB@

Running_Hours% = (65536 * Running_Hours_MSB%) + Running_Hours_LSB%
F_Running_Hours@ = Running_Hours%
PRINT Running_Hours%
// Calc End

If you could let me know about the username that would be grand.
Reply

simon
eWON Support
#5
Yes, I can.
Now I changed it to marcus_insyncs.
Tell me whether it is ok or not.
Reply

insyncs
Member
#6
(03-04-2017, 10:02 AM)Simon Wrote: Yes, I can.
Now I changed it to marcus_insyncs.
Tell me whether it is ok or not.

Hi,

Can you change it to just insyncs?

thanks!
Reply

simon
eWON Support
#7
Done
Reply

insyncs
Member
#8
(10-04-2017, 11:29 AM)Simon Wrote: Done

Thanks
Reply




Possibly Related Threads…
  Simple Math fonction .. Started by Aurelien
3 Replies - 4.129 Views
11-05-2023, 09:59 AM
Last Post: ziozetti
  Simple Alarm Escalation System Started by simon
4 Replies - 6.315 Views
15-06-2020, 11:54 AM
Last Post: simon



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy