Celsius <=> Fahrenheit

I just saw this in one of SCADA systems on the market:
There is a global setting in the project: Display temperature in Celsius/Fahrenheit, and it can also be changed/used in Runtime.
So, in the Runtime, you have a screen with temperatures (in labels/input fields/trends…). And there are two radio buttons with Celsius and Fahrenheit. When you choose Celsius, all temperatures are shown in Celsius, and when you choose Fahrenheit, all temperatures on the screen are shown in Fahrenheit.

Is it possible to do that somehow in Ignition?

I know, how to convert from Celsius to Fahrenheit and vice versa in Ignition (tag scaling, scripting). But you have to do it for every tag/label/input field.
Or I’m missing something?

you can do this easily with a script and call the script from the button/label/whatever

I think Z is wondering if a feature could be added to define say a tag as F,and on using it for a screen bind it as C(or set an override ‘unit’) and have Ignition do the conversion for it.

I’d imagine there would need to be a prebuilt conversion table for simple ones(F to C, C to F, inches to cm, etc) and possibly a user defined table for more esoteric conversions.

[quote="Dravik"]I think Z is wondering if a feature could be added to define say a tag as F,and on using it for a screen bind it as C(or set an override 'unit') and have Ignition do the conversion for it.

I'd imagine there would need to be a prebuilt conversion table for simple ones(F to C, C to F, inches to cm, etc) and possibly a user defined table for more esoteric conversions.[/quote]
I've been playing with this:
Yes, you can do it with script (in fact, there is no other option for now), but you must do it for every TAG (or label or input field).
I found that the 'easiest' way to do it is to set scaling of tag to 0 (OFF) or 1 (linear scaling).
Somewhere on the screen I put two radio buttons (one for Celsius and one for Fahrenheit). Then in property change event of this two radio buttons I change the 'ScaleMode' of the tag:

# For Fahrenheit
system.tag.writeToTag('Vipa/MW20.ScaleMode', 1)
# For Celsius
system.tag.writeToTag('Vipa/MW20.ScaleMode', 0)

The 'problem' is, you have to do it for all tags. For example I have 20 temperatures and I have to write 20 writeToTag commands (or writeAll, with the predefined tags paths and values).
The second problem I have is, that I want to change the EngUnit also:

# For Fahrenheit
system.tag.writeToTag('Vipa/MW20.ScaleMode', 1)
system.tag.writeToTag('Vipa/MW20.EngUnit', "F")
# For Celsius
system.tag.writeToTag('Vipa/MW20.ScaleMode', 0)
system.tag.writeToTag('Vipa/MW20.EngUnit', "C")

The change to EngUnit works only for first write (for examle 'F'). The second write ('C') writes the 'C' in the EngUnit, but something overwrites it back to 'F'. I was unable to find what is doing this.
The third 'problem' I see with this (changing the 'ScaleMode') is, that every time I change ScaleMode, the tag quality changes for a second (becomes bad and then good again). I understand why (the tag must be unsubscribed and subscribe again to use new setting), but maybe, if this was on some 'system' or project level, we can avoid that.

I think also, that making the 'Scale Mode' property in the Tag editor bindable to another tag or property or expression will help a lot.

Create two tags for each process value, one would be the process value the other would be an expression to convert the process value to the other temperature range. Use a client string tag to hold the values C or F, and then use indirect binding to display the temperature units the user wants.

The problem with changing the scaling with scripting as shown in your example is that you’ll mess up your tag history. Using two tags for each temperature process value allows you to store the history in both C and F which will allow you to easily display history data in the units the user wants. The other problem is that your forcing every user to view the temperature values in the units the last user selected.

The simplest way would to be to create a Temperature UDT -Temp/C Temp/FThen create a Client Tag “userTempUnits” and would use indirect binding to display the user’s desired temperature units -Temp/{userTempUnits}

[quote=“Pat”]Create two tags for each process value, one would be the process value the other would be an expression to convert the process value to the other temperature range. Use a client string tag to hold the values C or F, and then use indirect binding to display the temperature units the user wants.

The problem with changing the scaling with scripting as shown in your example is that you’ll mess up your tag history. Using two tags for each temperature process value allows you to store the history in both C and F which will allow you to easily display history data in the units the user wants. The other problem is that your forcing every user to view the temperature values in the units the last user selected.

The simplest way would to be to create a Temperature UDT -Temp/C Temp/FThen create a Client Tag “userTempUnits” and would use indirect binding to display the user’s desired temperature units -Temp/{userTempUnits}[/quote]
Thank you, Pat, for your explanation and suggestion, but I think you lost me here… :frowning:
I don’t quite understand, what you mean (about UDT and client tag???)… example, maybe… or some pictures… :blush:

A client tag is a tag that is unique to each client instance, so each client can have a different value for that tag - http://www.inductiveautomation.com/support/usermanuals/ignition/index.html?types_of_sqltags.htm

I’ll assume that your temperature units are coming in in Fahrenheit.

  1. Create a string client tag called TempUnits that holds the value C or F.
  2. Create an OPC tag called FurnasTemp_F.
  3. Create an Expression tag called FurnasTemp_C it’s expression will be -code*5/9[/code]
  4. Add a numeric display to a window, bind the value to the expression -tag("FurnasTemp_" + {[Client]TempUnits})

Changing the TempUnits value to C or F will display the proper value in your numeric display.

@Pat
Thank you. Now I understand. :smiley: