Rslogix 500 PRO API / VBA

PLC Gremlin

Member
Join Date
Aug 2004
Location
TN
Posts
80
Been a while since I've been around...

I own Rslogix 500 Pro and have messed around with the built in VBA.
I have searched on Google and here but it seems as if no one in the known universe has done much with the VBA in RSLogix. No Samples available... I do have the manual that ships with Pro about VBA.

My question is, does anyone use it (record macros or other) and what types of things have you done with it... If not, why not(Other than the obvious.. no spare time)

One other question.. Can apps written in Pro with VBA be used with someone else's standard license..
 
That is an interesting example in general but that
is VBA in excel. It doesn't really have much in to do with the use of the RsLogix API or VBA in RsLogix. Appreciate the response and like I said, pretty neat app..
Anybody else using VBA in RsLogix or ever messed with it.
 
Yes, I should have been more specific, but when I said in my original post
I do have the manual that ships with Pro about VBA.
, that was the manual I was talking about.

I guess I was right about no one realy using it much. No biggie, I was just curious to see if anyone had done anything cool with it.
Thanks for the responses..
 
The problem is you have not clarified.

Technically the Excel example is a record

THe rest depends on what you need/want to do.

Ahh nevermind.
 
I used VBA in RSLogix 5 Pro to display a form upon opening the RSP file.

RSLogixProVBA.gif


Maintenance technicians would most likely be opening the file for troubleshooting reasons, click the "Go Online ..." button and VBA takes you ONLINE and looks at the "Control System Error Code" number. N7:0 contains the Error number 880 in this example. VBA then searches for the logic generating code 880 which is OTL B16/[N7:0].
 
I wrote a small utility using the RSLogix model that automates search & replace operations using a csv file.

A client had a number of machines that consisted of essentially identical hardware wired to completely different I/O addresses. (The machines were updated/added to over the years and sensors etc. were simply slapped in wherever they seemed to fit best on that particular day).

Anyway, part of the project was to propagate some standard coding conventions across the machines without having to rewire anything. I wasn't terribly excited about manually converting the code from one addressing scheme to the next, so threw together this script to do it for me.

It's also come in handy on several other occasions - for example, a storage magazine of conveyors (say 8 conveyors long by 8 conveyors high). All the conveyors used the same code but had different I/O, indirects, etc.


To use the utility, create a .csv file with two columns: Column 1 represents the address to Search for, Column 2 represents the address to Replace with. After you create your CSV file, press 'ALT-F10' to access the VBA menu, choose the 'CSVSearchReplace' macro and follow the instructions on the popups.

You can select whether to search & replace within a single ladder file or to perform a global replace throughout the entire project. Global search & replaces can take a while if you have a large number of ladder files, so there's also a status window to indicate which file is currently being processed and how many remain.


The VBA code itself is pretty rough - I threw it together mostly for my own use so it's not exactly the cleanest source out there. There isn't any error handling to speak of, and I didn't really do any special character escaping so you'll need to verify that everything replaces the way you expect. Any limitations of the stock vba 'Replace' function will be present as well. I haven't used it in a while, but I seem to remember that there are a few objects that need to be released if you want to support multiple runs.

That being said, it's worked fine for me on a number of occasions and has certainly saved a lot of time.

The version I am attaching will work with RSLogix500. You can easily convert this to work with RSLogix5 as well. I've always used the Pro version, however, I think you can run premade macros in the Standard versions as well.

ABSearchReplace.png
ABSearchReplaceWorking.png




-Trevor
 
Last edited:
I wrote a small utility using the RSLogix model that automates search & replace operations using a csv file.

A client had a number of machines that consisted of essentially identical hardware wired to completely different I/O addresses. (The machines were updated/added to over the years and sensors etc. were simply slapped in wherever they seemed to fit best on that particular day).

Anyway, part of the project was to propagate some standard coding conventions across the machines without having to rewire anything. I wasn't terribly excited about manually converting the code from one addressing scheme to the next, so threw together this script to do it for me.

It's also come in handy on several other occasions - for example, a storage magazine of conveyors (say 8 conveyors long by 8 conveyors high). All the conveyors used the same code but had different I/O, indirects, etc.


To use the utility, create a .csv file with two columns: Column 1 represents the address to Search for, Column 2 represents the address to Replace with. After you create your CSV file, press 'ALT-F10' to access the VBA menu, choose the 'CSVSearchReplace' macro and follow the instructions on the popups.

You can select whether to search & replace within a single ladder file or to perform a global replace throughout the entire project. Global search & replaces can take a while if you have a large number of ladder files, so there's also a status window to indicate which file is currently being processed and how many remain.


The VBA code itself is pretty rough - I threw it together mostly for my own use so it's not exactly the cleanest source out there. There isn't any error handling to speak of, and I didn't really do any special character escaping so you'll need to verify that everything replaces the way you expect. Any limitations of the stock vba 'Replace' function will be present as well. I haven't used it in a while, but I seem to remember that there are a few objects that need to be released if you want to support multiple runs.

That being said, it's worked fine for me on a number of occasions and has certainly saved a lot of time.

The version I am attaching will work with RSLogix500. You can easily convert this to work with RSLogix5 as well. I've always used the Pro version, however, I think you can run premade macros in the Standard versions as well.

ABSearchReplace.png
ABSearchReplaceWorking.png




-Trevor
Greetings,
I downloaded and ran your example and then tried to build my own vba application using RSlogix Pro but so far no luck. Could you post or forward a very short example of a one button appliation that opens another instance of RSLogix.

The code of the form could be........

Dim gApplication As RSLogix500.Application
Dim gProject As RSLogix500.LogixProject
Dim gDataFiles As RSLogix500.DataFiles
Dim gDataFile As RSLogix500.DataFile

Private Sub Command1_Click()
Set gApplication = CreateObject("RSLogix500.Application")
gApplication.Visible = True
gApplication.AutoSaveInterval = 3
gApplication.WindowState = lgxWindowStateMaximized

It's the code location and the Module and the build and save that cause the problem when I then run it in RSLogix Standard.

All work OK in RSLogix Pro.

Help would be appreciated and returned if possible.

Thank you
 
Hello Inisglas,

I'm afraid I haven't had access to RSLogix for about a year now - lately most of my work has been with Siemens, C, and C#. Perhaps someone else might be able to offer further assistance.

You mentioned that your test project works as expected in RSLogix Pro. What happens when you attempt to run it in RSLogix Standard? Are you able to select your script from the macro selection window? (Alt-F10, if I remember correctly).


-Trevor
 
Thank you kindly for your prompt reply.
Yes I accessing the proper method, Under Tools, Visual Basic, Run Macro .......the vba starts but when I press the Command Button of the applciation it gives a : "vba script error each object must have it's own key"
Thank you and good luck in your non-RsLogix life.........!
 
I believe some system integrators and OEMs use Logix VBA code to auto generate PLC code according to their own standards. You would have a Excel sheet with all the specifics on it, then let VBA generate the code for you.
 
I haven't found it all that useful.

It's so easy to autogenerate code outside of RSLogix and simply load the result, that learning the Rockwell model isn't worth the effort.
 
I haven't found it all that useful.

It's so easy to autogenerate code outside of RSLogix and simply load the result, that learning the Rockwell model isn't worth the effort.


What are the other methods mellis? I know about using MS Word and MS Excel to do it but thats about the lenght of my knowledge.

Are there some additional methods?
 

Similar Topics

Hi, I’m looking at the difference between standard and pro versions of RSLogix 500. I know the pro version lets you edit the database in excel...
Replies
11
Views
2,749
So once again i am trying to create a program in unity pro from an Ab program. i have an FFL and FFU in rslogix 500 and need to use something like...
Replies
2
Views
2,215
Hello All... I am programming a Micrologix 1400 series C and cannot "Save" online edits. I can perform online edits, but when I try and save...
Replies
1
Views
2,257
1.the black switch is master start/stop switch 2. When red pushbutton is pressed once, both motor 1 and 2 should run continuously 3.if you close...
Replies
3
Views
1,752
Is there a "BOLD" font that can be used in the ladder logic of RSLogix 500 pro? The regular font drives me nuts.:banghead: TIA LW-c
Replies
2
Views
1,898
Back
Top Bottom