×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

HMI aplications using RSlogix &VBA

HMI aplications using RSlogix &VBA

HMI aplications using RSlogix &VBA

(OP)
Does anyone have some macro's that they can share with me, as I need help learning this language.

RE: HMI aplications using RSlogix &VBA

Macro’s for what?  Are you thinking about developing an HMI with a SLC5/00?  Do you have RSLINX?  Do you have a complicated process?  Is RSVIEW not an option?

RE: HMI aplications using RSlogix &VBA

When you say VBA, I assuming you are asking for an Excel Macro


Here is one I wrote:


Sub Start()

Dim lngRow As Long
Dim varCycle As Variant
Dim varLogging As Variant
Dim varResults As Variant
On Error GoTo Error
    
 
    'opens a COLD DDE link
    RSIchan = DDEInitiate("RSLinx", "M1138")
    
    'assign PLC bit values to VB variant varibles
    varLogging = DDERequest(RSIchan, "B3/163")
    varCycle = DDERequest(RSIchan, "B3/161")
    
    'close COLD DDE link
    DDETerminate (RSIchan)
    
    'check to see if the Cycle bit went to "1" if it did, excute read data
    If varCycle(1) = "1" And varLogging(1) = "1" Then

        'starts at row 3 of sheet
        lngRow = 3
        
        If Range("INDATA!A3").Value > 3 Then
            'look up last cell and change position
            lngRow = Range("INDATA!A3").Value
        End If
        
        'check until end of sheet
        For lngRow = lngRow To 65500
            'look for next empty cell
            If Cells(lngRow, 1) = "" Then Exit For
            
            'write current cell location to sheet INDATA
            'rather than writing a loop to search on
            'every cycle, by the time the log is at row 21,500
            'it could take a long time to search the rows...
            Range("INDATA!A3").Value = lngRow + 1
                        
        'add 1 to row "x" to check next row
        Next
          
        'opens a COLD DDE link
        RSIchan = DDEInitiate("RSLinx", "M1138")
        
        'there might be a better way to do this like
        'using this somehow ???????? but I don't know how
        'data = DDERequest(RSIchan, "f11:0,L7,C7")
        'Range("[M1138.xls]LOG!R[x]C1:R[x]C7").Value = data
                                                        
     
        'read word F8:10 and load into a VB variant variable
        f810data = DDERequest(RSIchan, "F8:10")
        'read word F8:11 and load into a VB variant variable
        f811data = DDERequest(RSIchan, "F8:11")
        'read word F8:12 and load into a VB variant variable
        f812data = DDERequest(RSIchan, "F8:12")
        'read word F8:16 and load into a VB variant variable
        f816data = DDERequest(RSIchan, "F8:16")
        'read word F8:18 and load into a VB variant variable
        f818data = DDERequest(RSIchan, "F8:18")
        'read word F8:17 and load into a VB variant variable
        f817data = DDERequest(RSIchan, "F8:17")
        'read word F8:20 force check #1 and load into a VB variant variable
        f820data = DDERequest(RSIchan, "F8:20")
        'read word F8:21 force check #2 and load into a VB variant variable
        f821data = DDERequest(RSIchan, "F8:21")
        'read word F8:22 force check #3 and load into a VB variant variable
        f822data = DDERequest(RSIchan, "F8:22")
        'read word F8:23 force check #4 and load into a VB variant variable
        f823data = DDERequest(RSIchan, "F8:23")
        'read word F8:24 max force and load into a VB variant variable
        f824data = DDERequest(RSIchan, "F8:24")
        'read word F8:25, get PASS or FAIL status from PLC and load into a VB variant variable
        varResults = DDERequest(RSIchan, "F8:25")
        
        'close COLD DDE link
        DDETerminate (RSIchan)
        
        'write all values to cells
        Cells(lngRow, 1).Value = f810data
        Cells(lngRow, 2).Value = f811data
        Cells(lngRow, 3).Value = f812data
        Cells(lngRow, 4).Value = f816data
        Cells(lngRow, 5).Value = f818data
        Cells(lngRow, 6).Value = f817data
        Cells(lngRow, 7).Value = f820data
        Cells(lngRow, 8).Value = f821data
        Cells(lngRow, 9).Value = f822data
        Cells(lngRow, 10).Value = f823data
        Cells(lngRow, 11).Value = f824data
        
            Range("INDATA!A4").Value = varResults
            
            If Range("INDATA!A4").Value = 0 Then
               Cells(lngRow, 12).Value = "PASS"
               
                'copies the conditional format to the next cell
                Rows(lngRow + 1).Select
                Selection.Copy
                Rows(lngRow + 2).Select
                ActiveSheet.Paste
                Application.CutCopyMode = False
                Range("L" & lngRow + 2).Select
                
            End If
            
            If Range("INDATA!A4").Value = 1 Then
                Cells(lngRow, 12).Value = "HEIGHT FAIL"
                
                'copies the conditional format to the next cell
                Rows(lngRow + 1).Select
                Selection.Copy
                Rows(lngRow + 2).Select
                ActiveSheet.Paste
                Application.CutCopyMode = False
                Range("L" & lngRow + 2).Select
                
            End If
            
            If Range("INDATA!A4").Value = 2 Then
                Cells(lngRow, 12).Value = "PARALLEL FAIL"
                
                'copies the conditional format to the next cell
                Rows(lngRow + 1).Select
                Selection.Copy
                Rows(lngRow + 2).Select
                ActiveSheet.Paste
                Application.CutCopyMode = False
                Range("L" & lngRow + 2).Select
              
            End If
            
            If Range("INDATA!A4").Value = 3 Then
               Cells(lngRow, 12).Value = "FORCE FAIL"
               
                'copies the conditional format to the next cell
                Rows(lngRow + 1).Select
                Selection.Copy
                Rows(lngRow + 2).Select
                ActiveSheet.Paste
                Application.CutCopyMode = False
                Range("L" & lngRow + 2).Select
                
            End If
            
            If Range("INDATA!A4").Value > 3 Then
                Cells(lngRow, 12).Value = "ERROR!"
            End If
        
        'capture time and date stamp into column 8
        Cells(lngRow, 13).Value = Now()
 
        'scrolls the screen down automatically
        'Range("A" & lngRow + 1).Select
      
    End If

GoTo Done:
Error:
    frmError.Hide
    frmError.Show
 
    'trying a timed form box, so disabled the old MESSAGE BOX here for now
    'MsgBox ("Communications to PLC have been lost! Or Log Sheet is FULL! Can not log data anymore. Check PLC connection and wiring.")
    Application.Run Macro:="ChkTime"

Done:

'check for date change, if so then save as new sheet
Application.Run Macro:="ChkTime"
End Sub


You can download the whole program here:

http://www.mrplc.com/dl/index.php?action=view&view=entry&entryid=74



Or if you want a sample VB 6.0 AB to DDE program you can donwload a sample program I never did finish, but the DDE works in the program.


http://www.mrplc.com/dl/index.php?action=view&view=entry&entryid=58


The code for the above program looks a little bit different than VBA code, so make sure you get the right sample.


Good Luck!

Chris Elston
Automation & Controls Engineer
http://www.mrplc.com
Download Sample PLC Ladder Logic Code
at MrPLC.com

RE: HMI aplications using RSlogix &VBA

(OP)
Thanks for your replies,

I need to give some more detail on my requirements: Firstly I have just purchased RSLogix 500 pro with a view to creating a pc interface with the micrologix & slc range of plc's.  This interface will vary from machine to machine & process to process.  I wish to use control buttons to turn various devices on & off eg: motors, valves, etc, as well as alarms for use in fault finding diagnostics.  The main plant that I will be using to develop my HMI is a plastic bottle plant that I have built.  This has a small network of micrologix 1500,1000, slc5/03 processors & pv300micro terminals running on a DH485 protocol.  

So if anyone has any ideas or suggestions or pointers it would be greatly appreciated

Thanks

Russell Gee

RE: HMI aplications using RSlogix &VBA


Russell,


Sounds like you better just stick with RS View 32. It's simple and easy to use. It's sold be the "TAG". You can get 300 tags pretty cheap. Buying RS View 32 far out weighs the cost of any time spent on a VB application.

Check it out at: rockwellsoftware.com

Chris Elston
Automation & Controls Engineer
http://www.mrplc.com
Download Sample PLC Ladder Logic Code
at MrPLC.com

RE: HMI aplications using RSlogix &VBA

(OP)
Chris,

I agree that for this application RS View would be an easier option, however in Australia a 300 tag version retails for about $2900 for a single licence & this makes it prohibitive for distribution on a wider scale for smaller machines.

Russell Gee

RE: HMI aplications using RSlogix &VBA

What I do is pay for the development license ($1200). Then I purchase a RUNTIME (300 tags) for $800.00. So each time I put a computer and a HMI on a new machine, it only cost me $800 for the RUNTIME 300 tags. MY runtime I purchase comes with a new copy of RS Linx Pro. So I am getting a 300 tag runtime, and RS Linx Pro for $800.00 for each new machine. Don't quote me on that price, but I am pretty sure that was the price I last paid.

See if your AB rep can work you a deal like that.

Chris Elston
Automation & Controls Engineer
http://www.mrplc.com
Download Sample PLC Ladder Logic Code
at MrPLC.com

RE: HMI aplications using RSlogix &VBA

(OP)
Chris,

Is that US dollars? Because I havent heard of prices like that in Aus, However it does look like it is worth investigation.  I'd be interested in looking at some of your applications if you are able to share them.

Thanks
Russell Gee

RE: HMI aplications using RSlogix &VBA

(OP)
It appears that I have been asking the wrong questions.  What I am really trying to do is produce some simple user interface screens for data collection & program control that can be used in the programming & commisioning enviroment & possibly afterwards. This will include some simple push buttons possibly rate counters & areas to change timer values.  If it as all possable to write a protocol to comunicate with the plc network without the use of links this would be of a great advantage thus eliminating the need for expensive licences for links.

Russell Gee

RE: HMI aplications using RSlogix &VBA

Sounds Like you want to create your own HMI application and write your own DF1 driver. If this is the case VBA will not work as a stand alone code for you VBA is Visual Basic for Applications, this means Not that you use it for building application but use it inside of an existing application such as Excel.

You would require a real full version of VB or WinC+ or some thing like that. Once you have some thing like that I would suggest using additional active X controls to assemble your projects. Although this may have a lower upfront cost, the over all cost of programming out side your means will in the long run cost far more and the extra stress will put you on lisinopril. Although I do not know your limitations.

Another benefit of using a pre packaged SCADA system is history, alarm, & other tools as such. Not to mention it would be easier to find people to support it when you have other duties.

But if you must look at some of the stuff at
WWW.SOFTWARETOOLBOX.COM
http://www.instrumentationactivex.com/
http://www.symbolfactoryactivex.com

If you search for DF1 you will find info on using mscomm32.ocx to build a driver for such uses.

RE: HMI aplications using RSlogix &VBA

I started to write a book on this very subject but lost interest. I thought that it wasn't very useful since a lot of people prefer software packages like wonderware,cimplicity and etc... Are there many of you forum users out there that would purchase such a book devoted exclusively to Industrial Automation Applications? I havedesigned HMI applications using VB that interfaced to execel and access. I have developed applications that exhibit automation that is in synchronization with actual pick n place machine movements. All of the appplications were developed for the Allen-Bradley SLC 5XX series of programmable logic controllers. best regards, PLCSAVVY

RE: HMI aplications using RSlogix &VBA

Also try InGear I think that communication package for VB that is a one time price. No runtime costs.
Paul

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources