Writing UserName to a PLC Tag

How do I write the System/User/Username to a Tag in a ControlLogix?

This is a Vision Client tag. It only exists in the Vision Client (or Designer), and each running Client or Designer has its own copy with a potentially different value.

That out of the way, you could write a script that reads the value and then writes it to an OPC tag from the PLC.

This question seems to be related to your (rather intriguingly named) Logging User Nane post. What is the real problem you are trying to solve?

I’m trying to get the Client Username into a PLC tag

What I really am trying to do is log who pressed a button.

I want to know the client and the User logged into that Client.

Ultimately, I want to write it to a PLC Tag and then read that PLC Tag as part of a Transaction Group.

Why? Just read the tag directly from the transaction group. No need for a middle man.

Never mind, I’m apparently asleep. I’m not sure you need to send it to the PLC, and there will definitely be a concern for conflicts from multiple clients, but I’m not sure exactly what that actually looks like.

1 Like

Why not enable auditing and query the audit log for that information?

2 Likes

A particular button or any button?

Are you going to have a different PLC tag for every possible client, as multiple client instances with the same button would only record the most recent instance.

Have you looked into using the audit logger for recording these types of events?

1 Like

Exactly what others have said. Use the already existing audit log. It will be more reliable and do exactly what you're asking for.

1 Like

What I really am trying to do is log who pressed a button. I want to know the client and the User logged into that Client.

Good. That's the real problem you're trying to solve.

Ultimately, I want to write it to a PLC Tag and then read that PLC Tag as part of a Transaction Group.

Not so good. That's how you think you should do it. This is blinding you.

There is no need to write to the PLC and, as others have pointed out, it will be a problem if there are multiple clients (including Designer).
One option would be to have the button code write directly to a gateway memory tag and include that in the transaction log. The chances of the button being pressed simultaneously on two clients should be extremely low.

The audit log would be best.

3 Likes