Convert Mqtt created string tags to number

Hi
I use Matt engine and get some tag from my plc. All tags which is created in mqttengine folder are string.
I want to know what are best way to convert them to float easily so I can define history and alarm on them.
Unfortunately my plc doesn’t support Matt sparkplug.

Caveat: I’m not familiar with your data source and there may be a better way to accomplish this. That said, would expression tags like this do the trick?
image
If your string tags have multiple values packed into them or other characters that need to be stripped out, that can be done in expression tags too. If you need a lot of these tags, you can create a script to go through the string tags and create the necessary expression tags for them.

1 Like

Hi
Thanks. If I have UDT structure for my Mqtt tag list, is there any way to create the tags manually and link them to related topic like creating opc tag that need indicate the opc address?

Can you share an example of your UDT structure?

Yes.
For example valve udt:
Opened Boolean
Closed Boolean
Open command Boolean
Close command Boolean
Traveling Boolean
Fault Boolean
Position float

I want to use udt instead of automatically created mqttt tag in Matt engine.
I can manually link them to my udt but this cause system use a lot resource( ones for Matt tag and one for udt tag)

I’m sorry, I think I misunderstood your last question. You could definitely create a UDT with the boolean tags as derived tags and an expression tag that would convert the position string to a position float, but you probably already knew that. I’m not sure if you can replace the MQTT engine tags with UDTs and don’t have an MQTT device to play with. Someone else may weigh in with more knowledge.

Assuming you can’t replace the MQTT engine tags with UDTs and you also can’t get the MQTT engine to give you the position as a float (ideal solution), I’d guess making your UDTs with derived and/or expression tags shouldn’t be too hard on resources. If you have a lot of these to make, system.tag.configure (Ignition 8) or system.tag.addTag (Ignition 7.9) is the way to go.

Thanks again.
For derived tag how I can reference them to write back to mqtt tag? For setpoint tag. There is one direction by expression.
At the moment I don’t know why write value on mqtt engine tag get back access denied error.

If position is a read/write value (rather than read-only), a derived tag would do the job like this:


I’m guessing there’s a setting somewhere that determines whether you can write to the MQTT tags and you’re getting the error because they are read-only. They’d need to be setup to allowing publishing to them, rather than just subscribing.

1 Like