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

Seite 2 von 4 ErsteErste 1234 LetzteLetzte
Ergebnis 11 bis 20 von 32

Thema: Help with the libnodave library

  1. #11
    Registriert seit
    03.04.2008
    Beiträge
    6.200
    Danke
    237
    Erhielt 815 Danke für 689 Beiträge

    Standard


    Zuviel Werbung?
    -> Hier kostenlos registrieren
    Normaly you adress dw0 not the single Bytes dbb0 and dbb1.

    Zottel, the guy who programmed the Libnodave library wrote you this allready :

    Code:
    //daveWriteBytes(dc,daveDB,42,17,4,&a); would write it to data block 42, starting with DBB 17.
    // note the a is an int (32bit) and len (4) happens to be the byte size of a!
    Also in the documentation it is decribed who to adress the PLC.


    bike

  2. #12
    vanvanero ist offline Neuer Benutzer
    Themenstarter
    Registriert seit
    07.06.2011
    Beiträge
    24
    Danke
    0
    Erhielt 0 Danke für 0 Beiträge

    Standard

    In wanting to change the value of DB1: DW0 and DB1: DW1, I wrote this code:

    a=daveSwapIed_32(a+1);
    daveWriteBytes(dc,daveDB,1,0,4,&a);
    b=daveSwapIed_32(b+2);
    daveWriteBytes(dc,daveDB,1,1,4,&b);

    a=daveGetU32(dc);
    b=daveGetU32(dc);
    printf("DB1: DW0: %d\n",a);
    printf("DB1: DW1: %d\n\n",b);

    but my output does not change the values, it returns this:

    DB1: DW0: 0
    DB1: DW1: 0

  3. #13
    Registriert seit
    27.11.2005
    Ort
    im Osten
    Beiträge
    1.183
    Danke
    141
    Erhielt 271 Danke für 248 Beiträge

    Standard

    Zitat Zitat von vanvanero Beitrag anzeigen
    but my output does not change the values, it returns this:
    You can not write to DW0 and DW 1, you must write to DW0 and DW 2.

    this code should work:
    Zitat Zitat von vanvanero Beitrag anzeigen
    a=daveSwapIed_16(a+1);
    daveWriteBytes(dc,daveDB,1,0,2,&a);
    b=daveSwapIed_16(b+2);
    daveWriteBytes(dc,daveDB,1,2,2,&b);
    davereadBytes(dc,daveDB,1,0,4,NULL);
    a=daveGetU16(dc);
    b=daveGetU16(dc);
    printf("DB1: DW0: %d\n",a);
    printf("DB1: DW1: %d\n\n",b);
    Es ist nicht schwierig, mit noch nicht erreichten Zielen zu Leben; schwierig ist, ohne Ziele zu Leben !
    (Günther Kraftschik)

  4. #14
    Registriert seit
    19.06.2003
    Beiträge
    2.200
    Danke
    85
    Erhielt 259 Danke für 175 Beiträge

    Standard

    Zitat Zitat von MW Beitrag anzeigen
    You can not write to DW0 and DW 1, you must write to DW0 and DW 2.

    this code should work:
    You CAN write to DW0 and DW1, but when you write to DW1, you'll overwrite the 2nd half of DW0 and the 1st of DW2.
    This is neither a feature nor a bug of Libnodave. It's just the same if you set DW0's and DW1's values from Step7.
    It's just the same if you use T DW0 and later T DW1 in your PLC program.

    If you know S5: With S5, it was different. In S5, DW0 was one word and DW1 another WORD. Bytes of DW0 where named DR0 and DL0, the L and R meaning left and right.

    Generally, you should know S7 memory layout AND your programming language in order to use Libnoddave sucessfully.
    It is always a good idea to do tests with a test PLC, where you can write deliberately. On such a test system, just create a DB with values 0,1,2,3,4,5,6,7... or any other sequence that allows you to remember very easily which value is where.
    If in doubt about S7 memory usage, look at DB contents as DBB, DBW, DBD using Step7.
    Then read with Libnodave and see where the same data goes to in your buffer memory.

  5. #15
    Registriert seit
    19.06.2003
    Beiträge
    2.200
    Danke
    85
    Erhielt 259 Danke für 175 Beiträge

    Standard

    a=daveGetU16(dc);
    b=daveGetU16(dc);
    printf("DB1: DW0: %d\n",a);
    printf("DB1: DW1: %d\n\n",b);
    a=daveGetU16(dc); // This uses two bytes from the bufffer and hence advances the buffer pointer by 2 bytes;
    // So here the buffer pointer points at what is the copy of DW2
    b=daveGetU16(dc); // therefore, b is DW2
    printf("DB1: DW0: %d\n",a);
    // and printf("DB1: DW1: %d\n\n",b); should be
    printf("DB1: DW2: %d\n\n",b);

    Maybe this example can help:

    davereadBytes(dc,daveDB,1,0,100,NULL); // read more bytes than we might ever use...
    // After this, the buffer pointer points to start of our buffer. There begins a copy of DW0 or DBD 0 or DBB0.
    a=daveGetU32(dc);
    // After this, the buffer pointer points to the 5th of our buffer. This is where copies of DW4 or DBD4 or DBB4 begin.
    b=daveGetU16(dc); // fetches a copy of DBW4
    // After this, the buffer pointer points to the 7th of our buffer. This is where copies of DW6 or DBD6 or DBB6 begin.
    b=daveGetU8(dc); // fetches a copy of DBB6
    // After this, the buffer pointer points to the 8th of our buffer. This is where copies of DW7 or DBD7 or DBB7 begin.
    a=daveGetU32(dc); // fetches a copy of DBD7
    // After this, the buffer pointer points at the 13th byte in buffer, which is the start of the copy of DW11 ( or DBB11, or DBD11)

    Another example, now reading from a different address:
    davereadBytes(dc,daveDB,1,117,100,NULL); // read more bytes than we might ever use...
    // After this, the buffer pointer points to start of our buffer. There begins a copy of DW117 or DBD 117 or DBB117.
    a=daveGetU32(dc);
    // After this, the buffer pointer points to the 5th of our buffer. This is where copies of DW121 or DBD121 or DBB121 begin.
    b=daveGetU16(dc); // fetches a copy of DBW121
    // After this, the buffer pointer points to the 7th of our buffer. This is where copies of DW123 or DBD123 or DBB123 begin.
    b=daveGetU8(dc); // fetches a copy of DBB123
    // After this, the buffer pointer points to the 8th of our buffer. This is where copies of DW124 or DBD124 or DBB124 begin.
    a=daveGetU32(dc); // fetches a copy of DBD124
    // After this, the buffer pointer points at the 13th byte in buffer, which is the start of the copy of DW128 ( or DBB128, or DBD12
    Geändert von Zottel (09.06.2011 um 01:10 Uhr)

  6. #16
    vanvanero ist offline Neuer Benutzer
    Themenstarter
    Registriert seit
    07.06.2011
    Beiträge
    24
    Danke
    0
    Erhielt 0 Danke für 0 Beiträge

    Standard

    I am getting an error that has never happened before. When I try running a test program in DOS I get the following error: "testISO_TCP" is not recognized as a n internal or external command, operable program or batch file"

    I am very sure that my path is correct and in C++ the program compiles and builds fine.

    Thanks for any help.

    Van
    Zitieren Zitieren unexpected error....  

  7. #17
    Registriert seit
    03.04.2008
    Beiträge
    6.200
    Danke
    237
    Erhielt 815 Danke für 689 Beiträge

    Standard

    Zitat Zitat von vanvanero Beitrag anzeigen
    I am getting an error that has never happened before. When I try running a test program in DOS I get the following error: "testISO_TCP" is not recognized as a n internal or external command, operable program or batch file"

    I am very sure that my path is correct and in C++ the program compiles and builds fine.

    Thanks for any help.

    Van
    Did you try to search for the Programm?
    Maybe the path to the programm is not correct.

    If the compile was successful and the linking also the program should run.


    bike

  8. #18
    vanvanero ist offline Neuer Benutzer
    Themenstarter
    Registriert seit
    07.06.2011
    Beiträge
    24
    Danke
    0
    Erhielt 0 Danke für 0 Beiträge

    Standard

    Thanks for the quick response. I have checked the path very carefuly and it is correct. this is my path:

    C:\Documents and Settings\reya\Desktop\libnodave>testISO_TCP

  9. #19
    Registriert seit
    19.06.2003
    Beiträge
    2.200
    Danke
    85
    Erhielt 259 Danke für 175 Beiträge

    Standard

    Zitat Zitat von vanvanero Beitrag anzeigen
    When I try running a test program in DOS I get the following error: "testISO_TCP" is not recognized as a n internal or external command, operable program or batch file"

    I am very sure that my path is correct and in C++ the program compiles and builds fine.

    Thanks for any help.

    Van
    I am not sure what you mean by "in DOS". The test programs are made to be run on the windows command line. They are WINDOWS executables, NOT DOS executables. This means that the CANNOT run under real DOS operating systems, like MSDOS, IBMDOS, FreeDOS etc.

  10. #20
    vanvanero ist offline Neuer Benutzer
    Themenstarter
    Registriert seit
    07.06.2011
    Beiträge
    24
    Danke
    0
    Erhielt 0 Danke für 0 Beiträge

    Standard


    Zuviel Werbung?
    -> Hier kostenlos registrieren
    Zitat Zitat von Zottel Beitrag anzeigen
    I am not sure what you mean by "in DOS". The test programs are made to be run on the windows command line. They are WINDOWS executables, NOT DOS executables. This means that the CANNOT run under real DOS operating systems, like MSDOS, IBMDOS, FreeDOS etc.
    Yes, I mean the command line. I go to start, run, cmd and then type my directory.

Ähnliche Themen

  1. .Net Library PLCCom S7
    Von Indi.An-er im Forum Werbung und Produktneuheiten
    Antworten: 5
    Letzter Beitrag: 28.09.2010, 13:41
  2. LibNodave mit Routing und Connection Library...
    Von Jochen Kühner im Forum Hochsprachen - OPC
    Antworten: 0
    Letzter Beitrag: 21.06.2010, 11:49
  3. Symbol Library
    Von K-SYSTEM-D im Forum Hochsprachen - OPC
    Antworten: 7
    Letzter Beitrag: 08.06.2010, 18:03
  4. LibNoDave und Connection Library mit Routing...
    Von Jochen Kühner im Forum Hochsprachen - OPC
    Antworten: 2
    Letzter Beitrag: 27.05.2010, 08:06
  5. FB in library???
    Von rene im Forum Simatic
    Antworten: 1
    Letzter Beitrag: 24.10.2007, 08:22

Lesezeichen

Berechtigungen

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