HMI tags to Database

Hello!

How can i insert HMI tags (data) to database using name queries?

I have a sample here:

I want to insert all this tags data into my database when the record_trigger turns to “True” (boolean) without using transaction group.

Thank you.
Thank you.

That's exactly what transaction groups were made for. Why not use them?

If you want, you can always script it yourself though: you can run a script on tag change that reads all the values and stores it in a database.

Yeah, i already used transaction groups. I want to verify and validate if all the transactions are captured by using other methods. Based on our checking there is a transaction that skip in the transaction group.

Here is my set up in transaction group:


When the record_trigger turns true data on the tags will stored into the databased.
Is there something wrong with my set up?

Thank you.

It’s probably a timing issue. OPC UA has timing in scan classes (or groups in Ignition 8). But that timing isn’t deterministic. So if the value goes high and low within the timer, Ignition will never see that value.

It’s better to either let Ignition reset the trigger after execution, or not reset that bit and act on any change.

Thanks for the info.
Okay sir, i based on my set up. I set the timer into 1 millisecond which means this reason will possible never see the value?
Regarding the trigger it is a button in the HMI where in if you click it the trigger it will becomes “True”, which means the trigger is already resetting correct me if im wrong.

Thank you

You mean an Ignition button? Or a different HMI?

If it's an Ignition button, I would just add a script to the button, and not use any tags as trigger.
Just use a regular button, and add an "actionPerformed" script.
Inside that script, get all the tags into variables:

parameters = {
    "batch_number": system.tag.read("Before Cutting Area/batch_number").value,
    ...
}

Then call a named query

system.db.runNamedQuery("queryName", parameters)

And create the named query like this:

INSERT INTO Table_Name
    ( batch_number, ...) VALUES
    (:batch_number, ...)

This approach will make sure you actually see the errors in the client when the button is pressed. And there's less to go wrong in general.

Yeah, its a button from the HMI
see reference of HMI:


The save button is my Trigger in the tags before_cutting_area_record_trigger that i used in the Transaction Group.

Regarding script into the button, thanks for the info i get it. but i will try to script it into the textbox that binds to a record_trigger (Tags), if the value of the textbox is true then call the name query.
Is that possible?

Thank you.

Ah, it’s a Siemens HMI, ignore my previous post then.

When you click that button, the PLC sets the warm_carcass_whole_record_trigger to 1.
But the question is, what code is setting that bit back to 0.

You should try to find that code, and disable it. But in Ignition enable the “Reset trigger after execution” checkbox. Then Ignition will set that bit back to 0.

Yes, it turns 1 when the HMI button clicked then it reset automatically to 0 after clicked.
But the problem when i try it into the Transaction Group, sometimes data skipped or doubled. I don’t think if my set up in the transaction group is the problem my execution timer is 1 millisecond.

I don’t think you need the “only evaluate when values have changed” checkbox checked. When your transaction group timer executes that should evaluate or read the current value of your trigger.

Also, you mentioned the transaction group timer being 1 ms but what is the scan class / tag group of the actual warm_carcass_whole_record_trigger tag? If that isn’t as frequent as your transaction group timer you might not be evaluating the most recent value.

Transaction groups can certainly get confusing. The documentation in the user’s manual is pretty good at breaking down their order of operations.

https://docs.inductiveautomation.com/display/DOC80/Understanding+Transaction+Groups

1 Like