Excel VBA Write to Controllogix Program-scope tags

dcooper33

Lifetime Supporting Member + Moderator
Join Date
Jun 2011
Location
Rogers, AR
Posts
717
Hi all,
Trying to find an answer to what I can't believe hasn't already been asked and answered on this site or elsewhere on the interwebz. But if it has, I surely can't find it. :confused:
I've done a fair amount of VBA work vis-à-vis Excel and controllogix processors, but I've only ever worked with controller-scoped tags, until now. I've got to populate a string and real member of a UDT, within an array, within program-scoped tags.
Can anyone shed some light on the proper syntax for DDEPoke tag name strings when pointed to a program tag?

Normally, I would do something like:

Code:
Channel = DDEInitiate("RSLinx", My_Topic)
 
For i = 0 to My_Array_Size
     Row = i + 2 '(or whatever row the data starts on)
     Column = 1 '(or wherever)
     Dest = "My_UDT_Array[" & i & "].My_String"
     DDEPoke Channel, Dest, Cells(Row, Column)
Next i

So if "My_UDT_Array" is program-scoped, would I do something like the FTView way of looking at it, i.e. "Program:My_Program.My_UDT_Array[" & i & "].My_String"?

Thanks,
Dustin
 
That was the way my gut was telling me to go, but I'm writing this code without hardware to test on, and I knew someone could provide an easy answer. :nodi:
Thanks for the tip!
 
I don't think that you can get THERE from HERE ...

I'm prepared to be corrected - but I'm pretty sure (99.99%) that any external data which flows IN to - or OUT of - the processor MUST be set up as a Controller-scoped tag ...

I'd bet substantially more than pocket change on this one ... (but way less than the rent) ...

question to consider: if all that you needed to use was the Program name - and then the tagname - then how would you accommodate situations where the same Program name might be used in different Tasks? ... (for example: you can have a lot more than just one "MainProgram" structure) ...

DISCLAIMER: I haven't tried this lately with any higher-level versions of the RSLogix5000 software - but I seem to remember error messages which said: "Must be scoped at the Controller level" when trying to set up something like this in the past ...
 
Last edited:
I'm prepared to be corrected...

We'll there is a first time for everything, and I hope this is it! :ROFLMAO:
I'll find out tomorrow morning. The controller scope restriction makes a kind of sense, although I did not think you could have multiple programs with the same name in a project. If you could, what would protect against a conflict if someone unscheduled the same program from two different tasks? How would rslogix tell them apart? The same potential problem would exist with HMI's that use the program tag nomenclature mentioned above. They do not address a program via its task container, so to me this presupposes the impossibility of duplicate program names.

If it turns out that you are correct, then I will just have to create an array of controller tags to match my UDT, and just copy them over to the program scoped ones upon a successful completion of the VBA macro. Not exactly clean, or ideal, but not the end of the world either.
 
I think that I have just been corrected ... thank you ...

I know that you can have multiple ROUTINES with the same name within different PROGRAMS ... I just ran a quick experiment and it looks like you cannot have multiple PROGRAMS with the same names within different TASKS ...

all of my hardware is up at the lab - so I don't have anything here at home except the software ...

live and learn ...

.

read_write.jpg
 
Last edited:
I ran it on my hardware setup and it worked, never though to check the program with same name but you guys figured that one out anyway.

I am also running studio 5000 21 on a 1769-L33ER so I can vouch for older firmware
 
Last edited:
I really like that bit of code bmacattack33 :) So much simpler than my own take.

I could have saved some man hours correcting code last night.

But this gives me a great chance to ask a question: Is there a limitation on how many values you can move?

My question arises because my original code had to be cut at 120 values for one DDEpoke (running on WinXP). And yesterday I found that after changing to Win7 64-bit I had to stop at 115 values.

A copy of my original code was posted in this thread:
http://www.plctalk.net/qanda/showthread.php?t=54415

Private Sub Download_Click()
Svar = MsgBox("Ønsker du at Downloade værdier til PLC !", vbOKCancel, " Procestype 1")
If Svar = vbOK Then
RSIchan = DDEInitiate("RSLinx", "B1")
DDEPoke RSIchan, "Sekvens[1,0,0],L90,C2", Range("[B1Recepter.xls]ProcesType1!C246")
DDETerminate (RSIchan)
End If
End Sub

The quick reader will see that this bit of code is only transferring 90 values and it is a 3 dimensional tag. but having the same code try to send 120 and then right after 70 values in the next line - only the 70 values of the second line will get through.

Correcting the code to say 100 in the first line and then 90 in the second works.

Using bmacattack33's code would seem to be problem free in this regard? As the DDEPoke is called for each value, instead of transferring an array.

Or am I mistaken?
 
I really like that bit of code bmacattack33 :) So much simpler than my own take.

I could have saved some man hours correcting code last night.

But this gives me a great chance to ask a question: Is there a limitation on how many values you can move?

My question arises because my original code had to be cut at 120 values for one DDEpoke (running on WinXP). And yesterday I found that after changing to Win7 64-bit I had to stop at 115 values.

A copy of my original code was posted in this thread:
http://www.plctalk.net/qanda/showthread.php?t=54415



The quick reader will see that this bit of code is only transferring 90 values and it is a 3 dimensional tag. but having the same code try to send 120 and then right after 70 values in the next line - only the 70 values of the second line will get through.

Correcting the code to say 100 in the first line and then 90 in the second works.

Using bmacattack33's code would seem to be problem free in this regard? As the DDEPoke is called for each value, instead of transferring an array.

Or am I mistaken?

I have used variations of that code to push thousands of values in sequence without issue. I also usually have a "Cells(Row, Column).Select" statement in the code to help visualize the progress of the write sequence.
I've never tried to push an array like you're doing so I can't speak to the limitations. I'm sure it's much faster than individual pokes, but with my method, I'm usually running the macro from a remote server, so I can see the write process begin and then log off and let the process complete and check on it later, so speed is never really a concern
 

Similar Topics

Hi. I have a task of creating checklists for a plant that contain many standard items. My idea is to do this in Excel, whereby in one sheet I...
Replies
11
Views
3,308
Hello, I am looking for help writing to PLC tags from Excel. I am using Factory Talk Gateway as an OPC server and Excel VBA to write out to an...
Replies
5
Views
3,090
Hello. For a PLC data logging application at a candy factory, a customer requested me to setup an add-in for MS Excel called "MX Sheet" which is...
Replies
22
Views
7,967
Good evening, I'll start by explaining what i want to do and then what I've tried. We have an excel document at work that contains our material...
Replies
4
Views
2,278
I have not been able to crack this one out, even after much thinking and googling:banghead:. I would be so grateful if I can get some guidance...
Replies
11
Views
3,676
Back
Top Bottom