LibNoDave - Excel CP343-1 Lean

denhondt

Level-1
Beiträge
6
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Hi,

I'm trying to read some data from an S7 300 CPU with a CP343-1 Lean card to a excel file

What i did:

- Changed to ph = openSocket(102, peer$)
- Changed to di = daveNewInterface(ph, ph, "IF1", 0, daveProtoISOTCP, daveSpeed187k)

- Run InitTable
- Set IP adress of the CP343-1 Lean card
- Start PLC => This Works OK
- Stop PLC => This works OK
- Read Diagnostic => This works OK
- Read TypeNr => This works OK
- Read ProgBocks => I get something like "Contents of OB1: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" I think this is OK

- Read From PLC => This doesn't work, i did not change anything of the sample program of ReadFromPlc

Original code:
' read some values from FD0,FD4,FD8,FD12 (MD0,MD4,MD8,MD12 in german notation)
' to read from data block 12, you would need to write:
' daveReadBytes(dc, daveDB, 12, 0, 16, 0)
'
Sub readFromPLC()
Cells(1, 2) = "Testing PLC read"
Dim ph As Long, di As Long, dc As Long
res = initialize(ph, di, dc)
If res = 0 Then
res2 = daveReadBytes(dc, daveInputs, 0, 0, 16, 0)
Cells(5, 1) = "result from readBytes:"
Cells(5, 2) = res2
If res2 = 0 Or res2 = -128 Then
v1 = daveGetS32(dc)
Cells(7, 1) = "MD0(DINT):"
Cells(7, 2) = v1
v2 = daveGetS32(dc)
Cells(8, 1) = "MD4(DINT):"
Cells(8, 2) = v2
v3 = daveGetS32(dc)
Cells(9, 1) = "MD8(DINT):"
Cells(9, 2) = v3
v4 = daveGetFloat(dc)
Cells(10, 1) = "MD12(REAL):"
Cells(10, 2) = v4
v5 = daveGetFloatAt(dc, 12)
Else
e$ = daveStrError(res)
Cells(9, 4) = "error:"
Cells(9, 5) = e$
End If
End If
Call cleanUp(ph, di, dc)
End Sub

in sheet1 i get:
error: ok
result from readbytes: -128
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Hallo!

Ich habe libnodave mit Excel 2003 im Einsatz, funktioniert wunderbar. Ist jedoch die SPS nicht erreichbar, so dauert es 3 Minuten bis
ph = openSocket(102, peer$)
erfolglos abbricht.

Kann man diese Zeit verändern?
 
Zurück
Oben