Hello Guest it is April 20, 2024, 12:04:27 AM

Author Topic: variable  (Read 2610 times)

0 Members and 1 Guest are viewing this topic.

Re: variable
« Reply #10 on: July 25, 2018, 02:13:53 AM »
ok thank you

mach 4

can you or sb write code
1-it must work all the time, from the moment the program is started until the program is turned off
2-must read the register
3- multiply by 5, divide by 6
4- save the result to the registry gRegs0/newreg45


In this case

I have an analogue value at the entrance
I want to show this result in a form other than 0-10v


otherwise I will have to interpolate the axes
so I would ask for a script



Re: variable
« Reply #11 on: July 25, 2018, 02:56:18 AM »
Hi,
yes, that can be done no sweat! The code needs to go it the PLC script.

You can strip some of the extra stuff of the code:
Code: [Select]
local inst=mc.mcGetInstance()
local hreg=mc.mcRegGetHandle(inst,'ESS/Encoder_0')
local regvalue=mc.mcRegGetValueString(hreg)
regvalue=tonumber(regvalue)
regvalue=(regvalue*5)/1.141
regvalue=tostring(regvalue)
hreg=mc.mcRegGetHandle(inst,'gRegs0/newreg45')
mc.mcRegSetValueString(hreg,regvalue)
The PLC script is part of the GUI root viewed and edited in Edit Screen Mode.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: variable
« Reply #12 on: July 25, 2018, 05:07:25 AM »
thank you my friend