This site has helped me many a time so I wanted to give back with something I worked on recently.
I needed to set up a PV HMI in FTME that was more universal, and we didn't want to have to change the plc code that we had standardized any more than necessary. This is the way I came up with to allow a digital tag to switch between Metric and Standard units, both displaying and entering in the relevant units whilst still giving the plc Standard units
1) create a digital tag for your unit toggle button (We linked it to plc tag as well for some other options in the plc we added later) (you could use the CurrentLanguage() = "en-US" but I wanted more flexibility) MACHINE_TYPE\METRIC
2) create your conversion tags (just makes it cleaner and easier if you want to adjust the scales later) ie. MATH_BARS_PSI where PSI = BARS * 14.503778 (we set a scale of 0.1 for a degree of accuracy, of course, you could go further)
3) Using a Numeric input cursor point object set desired tags and calculations
(the key here is that FTME uses the ? to identify whatever value was just entered into the keypad popup, and optional expression will apply its statement before parsing the value to the value tag)
a) Value: desired tag to hold value, INJECT_PRESSURE
b) Optional expression:
If MACHINE_TYPE\METRIC ==0
then ?
ELSE (?)*MATH_BARS_PSI
c) Indicator: is the numeric display for the Standard or metric data (remember the math needs to be reversed for displaying vs inputting)
If MACHINE_TYPE\METRIC ==0
then INJECT_PRESSURE
else INJECT_PRESSURE / MATH_BARS_PSI
(this is also what I put into any non-entry numeric displays)
Now when we enter a number through the keypad it will always send it down to plc in Standard and then convert it to whichever state is required for displaying.
The last thing is temperatures, which we all know is goofy from Fahrenheit to Celsius but here is that statement as well, in case you need it. (F to C = F -32 *0.555)
Value: MOTOR_TEMP
Optional expression:
If MACHINE_TYPE\METRIC ==0
then ?
else (?/CEL_TO_FAR)+32
Indicator:
If MACHINE_TYPE\METRIC ==0
then MOTOR_TEMP
else (MOTOR_TEMP -32)*CEL_TO_FAR
Hope this comes in useful for some other unsuspecting PLC guy who gets a metric job dumped on their lap.
I needed to set up a PV HMI in FTME that was more universal, and we didn't want to have to change the plc code that we had standardized any more than necessary. This is the way I came up with to allow a digital tag to switch between Metric and Standard units, both displaying and entering in the relevant units whilst still giving the plc Standard units
1) create a digital tag for your unit toggle button (We linked it to plc tag as well for some other options in the plc we added later) (you could use the CurrentLanguage() = "en-US" but I wanted more flexibility) MACHINE_TYPE\METRIC
2) create your conversion tags (just makes it cleaner and easier if you want to adjust the scales later) ie. MATH_BARS_PSI where PSI = BARS * 14.503778 (we set a scale of 0.1 for a degree of accuracy, of course, you could go further)
3) Using a Numeric input cursor point object set desired tags and calculations
(the key here is that FTME uses the ? to identify whatever value was just entered into the keypad popup, and optional expression will apply its statement before parsing the value to the value tag)
a) Value: desired tag to hold value, INJECT_PRESSURE
b) Optional expression:
If MACHINE_TYPE\METRIC ==0
then ?
ELSE (?)*MATH_BARS_PSI
c) Indicator: is the numeric display for the Standard or metric data (remember the math needs to be reversed for displaying vs inputting)
If MACHINE_TYPE\METRIC ==0
then INJECT_PRESSURE
else INJECT_PRESSURE / MATH_BARS_PSI
(this is also what I put into any non-entry numeric displays)
Now when we enter a number through the keypad it will always send it down to plc in Standard and then convert it to whichever state is required for displaying.
The last thing is temperatures, which we all know is goofy from Fahrenheit to Celsius but here is that statement as well, in case you need it. (F to C = F -32 *0.555)
Value: MOTOR_TEMP
Optional expression:
If MACHINE_TYPE\METRIC ==0
then ?
else (?/CEL_TO_FAR)+32
Indicator:
If MACHINE_TYPE\METRIC ==0
then MOTOR_TEMP
else (MOTOR_TEMP -32)*CEL_TO_FAR
Hope this comes in useful for some other unsuspecting PLC guy who gets a metric job dumped on their lap.