For my CNC program, who is communicating with an arduino,
I want to read the temperature of the cooling water.
This is messured via a sensor connected on the analog input A0 on the arduino board.
This input haves a resolution of 10 bits => ReadAnalogValue = 0...1023
I want to give the enduser the freedom to enter a formule to convert this value to a temperature
EXAMPLE:
-20.0...110.0 C
My used variables:
Code: Select all
Global ReadAnalogValue.w = Arduino analog input A0 => 0...1023
Global TempMin.f = -20.0
Global TempMax.f = 110.0
Global DeltaTemp.f = TempMax - TempMin = 120.0
Global Resolution.w = 10 bits = 1024
Global MyTemperature.f
Global UserString.s
Code: Select all
UserString = "(ReadAnalogValue * (120.0 / 1024)) - 10.0"
OR the user can enter "-10 + (ReadAnalogValue * (120.0 / 1024))"
Question:
How can I convert this string UserString to a usable formule inside my program ?
WIN10 x64 - PB 5.72x64 LST
Thanks,
marc