John Croson

MrPLC Member
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About John Croson

  • Rank
    Newbie

Contact Methods

  • ICQ 0
  1. HELP!

    THANKS! I'm trying it myself, now.
  2. HELP!

    This is what I'll end up using. This should set the bit to 1, wait a second, and then set it back to 0. Could I have also just have used something like this? DDEPoke RSIChan, "B3/100", 1 Pause 1 DDEPoke RSIChan, "B3/100", 0 Should I have those number in quotes? Sub DDE_Write() Dim intSet As Integer RSIChan = DDEInitiate("RSLINX", "ENDRES") 'write data thru channel 'set the bit to 1 DDEPoke RSIChan, "B3/100", Range("OUTDATA!A11").Value Pause 1 'and set it back to 0 DDEPoke RSIChan, "B3/100", Range("OUTDATA!A10").Value 'close dde channel DDETerminate (RSIChan) End Sub Public Sub Pause(ByVal pSng_Secs As Single) 'Wait for the number of seconds given by pSng_Secs Dim lSng_Start As Single Dim lSng_End As Single On Error GoTo Err_Pause    lSng_Start = Timer    lSng_End = Timer + pSng_Secs    Do While Timer < lSng_End    '' Correction if the timer moves over to a new day (midnight)    '' 86400-num of secs in a day        If Timer < lSng_Start Then lSng_End = lSng_End - 86400    Loop Err_Pause:    Exit Sub     End Sub Thanks.
  3. HELP!

    Sorry for my incomplete post! This cell contains a "1" DDEPoke RSIChan, "B3:100", Range("OUTDATA!A11").Value This cell contains a "0" DDEPoke RSIChan, "B3:100", Range("OUTDATA!A10").Value I was told that if I set the bit in this b3/100 to 1 and then back to 0, it would reset my n24 integer bits. Thanks again! You guys are great!
  4. HELP!

    Thanks! Yes, I did hack up your original example, and AB's. I'm more of a vb guy, never having grabbed data from a PLC before, so it threw me off, not declaring variables, and then passing the var's into int's, etc. The only issue I'm having now is DDEPoke into B3/100 to reset the array. It doesn't seem to work. My code: Sub DDE_Write() RSIChan = DDEInitiate("RSLINX", "ENDRES") 'write data thru channel DDEPoke RSIChan, "B3:100", Range("OUTDATA!A11").Value DDEPoke RSIChan, "B3:100", Range("OUTDATA!A10").Value 'close dde channel DDETerminate (RSIChan) End Sub Thanks!
  5. HELP!

    COOL! Thanks for the pointer. Bad form using Variants, but so be it... The Example: Sub Word_Read()      Dim mytype As String      Dim test As Integer      Dim junk As Tag      Set junk = gTagDb.GetTag("analog")      'open DDE link: testsol=DDE Topic      RSIchan = DDEInitiate("RSLinx", "testsol")      'get data and store in data variable      data = DDERequest(RSIchan, "N7:0")      'shows the variable type for data      'use the TypeName function and the Locals Window to determine      'the data type for the variable 'data' to determine it is an array.      'the line is not necessary for the script to run.      mytype = TypeName(data)      'store the value from data into variable and tag      test = data(1)      junk.Value = data(1)      'close dde link      DDETerminate (RSIchan)      'release memory for tag      Set junk = Nothing End Sub The thing I can't understand is why I'm setting the junk variable. Is this simply used for a test? I am using the example this way: Sub Start() Dim lngRow As Long Dim varResults As Variant Dim strTestType As String Dim intDump As Integer Dim junk As Tag Dim intVar As Integer, intCount As Integer, _    intData As Integer, strData As String On Error GoTo Error     Set junk = gTagDb.GetTag("test")    'opens a COLD DDE link    RSIChan = DDEInitiate("RSLINX", "ENDRES")        'assign PLC bit values to VB variant varibles    dumpqty = DDERequest(RSIChan, "C5:2.ACC")         'shows the variable type for data 'use the TypeName function and the Locals Window to determine 'the data type for the variable 'data' to determine it is an array. 'the line is not necessary for the script to run.    strTestType = TypeName(dumpqty)        ' Convert our variable into something usable    intDump = dumpqty(1)    junk.Value = dumpqty(1)        'close COLD DDE link    DDETerminate (RSIChan)        'check to see if anything has been dumped    If intDump > 0 Then For intCount = 0 To intDump        '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", "ENDRES")                '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("[ENDRES.xls]LOG!R[x]C1:R[x]C7").Value = data                                                             For intCount = 0 To intDump         ' Fill in the TYPE Column        intData = DDERequest(RSIChan, "N24:" & intVar)            Select Case intData            Case Is = 1                strData = "BREAD"            Case Is = 2                strData = "PRETZEL"        End Select        Cells(lngRow, 1).Value = strData        'increment our var        intVar = intVar + 1        'zero our data        intData = 0            ' Fill in the Room Column        intData = DDERequest(RSIChan, "N24:" & intVar)            Select Case intData                Case Is = 1            strData = "Mixing Room"                Case Is = 2            strData = "Package Room"                Case Is = 3            strData = "Oven Room"        End Select        Cells(lngRow, 2).Value = strData        'increment our var        intVar = intVar + 1        'zero our data        intData = 0                    ' Fill in the Line        intData = DDERequest(RSIChan, "N24:" & intVar)            Select Case intData            Case Is = 5                strData = "Other"            Case Else                strData = intData        End Select        Cells(lngRow, 3).Value = strData        'increment our var        intVar = intVar + 1        'zero our data        intData = 0                    ' Fill in the Result Of Column        intData = DDERequest(RSIChan, "N24:" & intVar)            Select Case intData            Case Is = 1                strData = "From Startup"            Case Is = 2                strData = "From Shutdown"            Case Is = 3                strData = "Normal Production"            Case Is = 4                strData = "From R&D"            Case Is = 5                strData = "From Change Over"            Case Is = 6                strData = "Other"        End Select        Cells(lngRow, 4).Value = strData        'increment our var        intVar = intVar + 1        'zero our data        intData = 0                 Next intCount                      'close COLD DDE link        DDETerminate (RSIChan) The installer of the panel supplied these instructions: Word 1 ( N24:0 ) = TOTE WEIGHT Word 2 ( N24:1 ) = PRODUCT TYPE, 1=bread / 2=pretzel Word 3 ( N24:2 ) = ROOM, 1=mixing / 2=packaging / 3=oven Word 4 ( N24:3 ) = LINE, 1,2,3,4,5 Word 5 ( N24:4 ) = RESULT OF, 1=startup / 2=shutdown / 3=normal 4=r&d / 5=change over / 6=other Then it starts over, counting Word 1 from N24:5, the weight. The rest of the code has been snipped, but I just want to check for an accumulated value in C5:2.ACC, and if it is more than 0, grab all the data in the "array" and push it into my spreadsheet. It seems that I have to do a var check for all of the PLC types of data? Thanks for looking!
  6. HELP!

    Thanks, but I do have a topic set up.
  7. HELP!

    Thanks for the reply. Here is the top of the sub: Dim lngRow As Long Dim varDump As Variant Dim sngWeight As Single Dim varResults As Variant Dim intVar As Integer, intCount As Integer, _ intData As Integer, strData As String On Error GoTo Error 'opens a COLD DDE link RSIChan = DDEInitiate("RSLINX", "ENDRES") 'assign PLC bit values to VB variant varibles varDump = DDERequest(RSIChan, "C5:2.ACC") 'close COLD DDE link DDETerminate (RSIChan) 'check to see if anything has been dumped If varDump > 0 Then Thanks again!
  8. HELP!

    I am not a PLC person, but I am a VBA person. I can create a hot link in Excel to an SLC503+ and see my data. But if I try to use the following code, I get a Type Mismatch error. This usually tells me that I'm using an invalid variable type to hold the data, but I'm using a Variant type!! 'assign PLC bit values to VB variant varibles varDump = DDERequest(RSIChan, "C5:2.ACC") This space is supposed to hold a number from 0 to 25. If I do a Copy DDE link from RSLinx (Single Node), I get this: [ENDRES]C5:2.ACC,L1,C1 Can anyone tell me why I get this error? Thanks!