Zuviel Werbung? - > Hier kostenlos beim SPS-Forum registrieren

Seite 1 von 2 12 LetzteLetzte
Ergebnis 1 bis 10 von 14

Thema: Excel Siemens libnodave

  1. #1
    Registriert seit
    26.02.2016
    Beiträge
    3
    Danke
    0
    Erhielt 0 Danke für 0 Beiträge

    Standard


    Zuviel Werbung?
    -> Hier kostenlos registrieren
    Hello,

    I attached my Excel program currently i working on it.

    I reading DB1.DBW0 from SIEMENS:

    ElseIf InStr(TagType_array(1), "DBW") > 0 Then
    addrOffset = Replace(TagType_array(1), "DBW", "")
    res2 = daveReadBytes(dc, daveDB, dbnum, addrOffset, 2, 0)

    This is clear for me.

    Then if this data is equal to 1:

    If daveGetU16(dc) = 1 Then

    a = davePut16(buffer(0), Cells(10, 1))
    a = davePut16(buffer(2), Cells(10, 2))
    a = davePut16(buffer(4), Cells(10, 3))
    a = davePut16(buffer(6), Cells(10, 4))
    a = davePut16(buffer(8), Cells(10, 5))
    a = davePut16(buffer(10), Cells(10, 6))
    a = davePut16(buffer(12), Cells(10, 7))
    a = davePut16(buffer(14), Cells(10, 8))
    a = davePut16(buffer(16), Cells(10, 9))
    a = davePut16(buffer(18), Cells(10, 10))
    a = davePut16(buffer(20), Cells(10, 11))
    a = davePut16(buffer(22), Cells(10, 12))
    a = davePut16(buffer(24), Cells(10, 13))
    a = davePut16(buffer(26), Cells(10, 14))
    a = davePut16(buffer(28), Cells(10, 15))
    a = davePut16(buffer(30), Cells(10, 16))
    a = davePut16(buffer(32), Cells(10, 17))
    a = davePut16(buffer(34), Cells(10, 18))
    a = davePut16(buffer(36), Cells(10, 19))
    a = davePut16(buffer(38), Cells(10, 20))
    a = davePut16(buffer(40), Cells(10, 21))
    a = davePut16(buffer(42), Cells(10, 22))

    res2 = daveWriteBytes(dc, daveDB, dbnum, 2, 2,
    buffer(0))

    res2 = daveWriteBytes(dc, daveDB, dbnum, 4, 2,
    buffer(2))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 6, 2,
    buffer(4))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 8, 2,
    buffer(6))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 10, 2,
    buffer(8))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 12, 2,
    buffer(10))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 14, 2,
    buffer(12))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 16, 2,
    buffer(14))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 18, 2,
    buffer(16))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 20, 2,
    buffer(18))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 22, 2,
    buffer(20))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 24, 2,
    buffer(22))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 26, 2,
    buffer(24))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 28, 2,
    buffer(26))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 30, 2,
    buffer(28))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 32, 2,
    buffer(30))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 34, 2,
    buffer(32))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 36, 2,
    buffer(34))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 38, 2,
    buffer(36))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 40, 2,
    buffer(38))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 42, 2,
    buffer(40))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 44, 2,
    buffer(42))

    I Writing Excel cells information to SIEMENS:

    Excel cell (1, 10) -> to DB1.DBW2
    Excel cell (2, 10) -> to DB1.DBW4
    Excel cell (3, 10) -> to DB1.DBW6
    Excel cell (4, 10) -> to DB1.DBW8
    Excel cell (5, 10) -> to DB1.DBW10
    Excel cell (6, 10) -> to DB1.DBW11
    Excel cell (7, 10) -> to DB1.DBW12
    Excel cell (8, 10) -> to DB1.DBW14
    Excel cell (9, 10) -> to DB1.DBW16
    Excel cell (10, 10) -> to DB1.DBW18

    And etc.. All Row.

    The problem for me is I dont have Live Reading and Writing from/to SIEMENS.

    I should push the button all the time.

    Question: How to make this excel working Live reading/writing.
    geras.rargeras.rar

    I attached my working Excel file.

    Thank you.
    Geändert von zmnck (26.02.2016 um 14:37 Uhr)
    Zitieren Zitieren Excel Siemens libnodave  

  2. #2
    Registriert seit
    22.06.2009
    Ort
    Sassnitz
    Beiträge
    11.186
    Danke
    923
    Erhielt 3.291 Danke für 2.660 Beiträge

    Standard

    Zitat Zitat von zmnck Beitrag anzeigen
    Question: How to make this excel working Live reading/writing.
    http://www.cpearson.com/excel/OnTime.aspx

    Harald
    Es ist immer wieder überraschend, wie etwas plötzlich funktioniert, sobald man alles richtig macht.

    FAQ: Linkliste SIMATIC-Kommunikation über Ethernet

  3. #3
    zmnck ist offline Neuer Benutzer
    Themenstarter
    Registriert seit
    26.02.2016
    Beiträge
    3
    Danke
    0
    Erhielt 0 Danke für 0 Beiträge

    Standard

    Thanks for you answer.

    I know this method, I doing like this:

    Sub Auto_Open()
    Call EventMacro
    End Sub

    Public Sub EventMacro()
    Call readFromPLC
    alertTime = Now + TimeValue("00:00:001")
    Application.OnTime alertTime, "EventMacro"
    End Sub

    I searching another way how to do this live connection with libnodave.

  4. #4
    Registriert seit
    29.11.2017
    Beiträge
    10
    Danke
    1
    Erhielt 0 Danke für 0 Beiträge

    Standard

    I tried o implement your code in VBA. Unfortunately it doesnt accept buffer the way you have defined it. I get a compile error. I could only write

    For example :

    a = davePut32(buffer, Cells(10, 1))
    res2 = daveWriteBytes(dc, daveDB, dbnum, 2, 4,
    buffer).
    . I would be grateful if you could show me the way of copying the cells in excel sheet to a db library




  5. #5
    Registriert seit
    22.03.2007
    Ort
    Detmold (im Lipperland)
    Beiträge
    11.718
    Danke
    398
    Erhielt 2.400 Danke für 2.000 Beiträge

    Standard

    I suppose you have 2 problems :
    - Cells(10,1) is a Variant - so you should write first into a VBA-Variable and the assign it to a Cell
    - buffer is not only one value - it is an array. So ... how do you think that you could assign an array to a single Variable ? You must assign one element from the buffer to your Variable ...

    Cheers
    Larry

  6. #6
    Registriert seit
    29.11.2017
    Beiträge
    10
    Danke
    1
    Erhielt 0 Danke für 0 Beiträge

    Standard

    Thanks for your reply. My code is working for writing Double Int from an Excel cell. I face problem writing strings of variable byte size from Excel Cell to LibnodaveDb. As the davePut8/ davePut16 / davePut32 will be hard to use along with daveWriteManyBytes

  7. #7
    Registriert seit
    22.03.2007
    Ort
    Detmold (im Lipperland)
    Beiträge
    11.718
    Danke
    398
    Erhielt 2.400 Danke für 2.000 Beiträge

    Standard

    Create an array of Byte from your String (because a String isn't anything else) and transfer it to your PLC ...

    Cheers
    Larry

  8. #8
    Registriert seit
    29.11.2017
    Beiträge
    10
    Danke
    1
    Erhielt 0 Danke für 0 Beiträge

    Standard

    Thanks for your reply again. I tried reading the string of 20 bytes long from excel sheet Cell( 12, 5) to Cell(12,9). As you suggested also defined array of Byte to read a string

    Private Sub CommandButton4_Click()
    Dim s As Integer
    Dim a As String
    Dim h() As Byte
    Dim b() As Byte


    For j = 5 To 9
    h() = ActiveSheet.Cells(12, j)


    For i = 0 To 19

    a = davePut8(b(i), h(i))
    Next i
    s = daveWriteBytes(dc, daveDB, DBNR, Count, 20, b())
    Count = Count + 20
    Next j



    I get the error in daveWriteBytes stage as it says *b()* is incompatible with the compiler. Isn't a buffer an array. I am not able to figure out my mistake.

    Any corrections or suggestion from your end will be appreciated
    Geändert von siddharthdc (04.12.2017 um 15:38 Uhr)

  9. #9
    Registriert seit
    22.03.2007
    Ort
    Detmold (im Lipperland)
    Beiträge
    11.718
    Danke
    398
    Erhielt 2.400 Danke für 2.000 Beiträge

    Standard

    Perhaps because b is a Null-dimensioned Array - try it with a dimensionized Array :
    Code:
    Dim b(19) As Byte
    But basicly I would make the coding like this :
    Code:
    Dim i,j,s As Integer
    Dim a As byte
    Dim h As string
    Dim b(19) As Byte
    
    
    For j = 5 To 9
            h = ActiveSheet.Cells(12, j)
    
            For i = 0 To 19
           b(i) = asc(mid$(h,i,1))
            Next i
            s = daveWriteBytes(dc, daveDB, DBNR, Count, 20, b())
            Count = Count + 20
    Next j
    Cheers
    Larry

  10. Folgender Benutzer sagt Danke zu Larry Laffer für den nützlichen Beitrag:

    siddharthdc (04.12.2017)

  11. #10
    Registriert seit
    29.11.2017
    Beiträge
    10
    Danke
    1
    Erhielt 0 Danke für 0 Beiträge

    Standard


    Zuviel Werbung?
    -> Hier kostenlos registrieren
    Thanks for your reply and spending out the time to write an example. May I ask why did you use Mid$. I know its used to iterate a string. But the reason is you are converting a string to ascii is a bigger step as you write a string into DB in ascii format. Neverthless I thank you again for your inputs.

    I had small corrections

    s = daveWriteBytes(dc, daveDB, DBNR, Count, 20, b()) ' that has to be corrected as having *b()* causes an error again. Maybe you use within a loop.


    s = daveWriteBytes(dc, daveDB, DBNR, Count, 20, b(i))

Ähnliche Themen

  1. LibNoDave - Excel CP343-1 Lean
    Von denhondt im Forum Hochsprachen - OPC
    Antworten: 2
    Letzter Beitrag: 20.04.2013, 08:36
  2. LibNoDave-NetToPLCSim-Excel
    Von Earny im Forum Hochsprachen - OPC
    Antworten: 1
    Letzter Beitrag: 13.10.2009, 18:52
  3. Libnodave und Excel
    Von Joe im Forum Hochsprachen - OPC
    Antworten: 7
    Letzter Beitrag: 23.01.2007, 11:19
  4. libnodave und Excel
    Von tomatensaft im Forum Programmierstrategien
    Antworten: 2
    Letzter Beitrag: 03.01.2007, 01:56
  5. S7 Libnodave und Excel
    Von uz71 im Forum Simatic
    Antworten: 27
    Letzter Beitrag: 15.11.2006, 13:51

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •