Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Snap7 and Qt ,PLC communication
Forum Updated to NodeBB v4.3 + New Features

Snap7 and Qt ,PLC communication

Scheduled Pinned Locked Moved Unsolved General and Desktop
37 Posts 6 Posters 12.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    ZekDe
    wrote on last edited by
    #27

    Thank you mmiacca ,I can wait and also How did you manage it if you explain I will be so happy.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZekDe
      wrote on last edited by
      #28

      Are you able to do it with mingw 5.3.0?

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZekDe
        wrote on last edited by
        #29

        Hi mmiacca ,could you give me an example ?,I need like you ssay,I need easy start

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mmiacca
          wrote on last edited by
          #30

          Hi (excuse my english please)

          Here is the project file to compile a gui example with snap7, no libraries, all in one..

          #-------------------------------------------------
          #
          # Project created by QtCreator 2016-11-17T17:37:17
          #
          #-------------------------------------------------
          
          QT += core gui network
          
          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
          
          TARGET = test1
          
          TEMPLATE = app
          
          # Desde http://stackoverflow.com
          # Finally, CONFIG(debug, debug|release) evaluates to true if CONFIG contains "debug" but not "release", or if it contains both
          # "debug" and "release" but "release" doesn't appear after the last occurrence of "debug".
          CONFIG(debug, debug|release){
           DESTDIR = $$_PRO_FILE_PWD_/../debug
           #DEFINES += QT_NO_DEBUG
          }
          else{
           DESTDIR = $$_PRO_FILE_PWD_/../release
          }
          
          win32:LIBS += C:\Qt\Tools\mingw530_32\i686-w64-mingw32\lib\libws2_32.a
          win32:LIBS += C:\Qt\Tools\mingw530_32\i686-w64-mingw32\lib\libwinmm.a
          
          INCLUDEPATH += ../snap7-full-1.4.1/release/Wrappers/c-cpp/ \
                         ../snap7-full-1.4.1/src/lib/ \
                         ../snap7-full-1.4.1/src/core/ \
                         ../snap7-full-1.4.1/src/sys/
          
          SOURCES += main.cpp\
           mainwindow.cpp \
              client.cpp \
              ../snap7-full-1.4.1/release/Wrappers/c-cpp/snap7.cpp \
              ../snap7-full-1.4.1/src/core/s7_client.cpp \
              ../snap7-full-1.4.1/src/core/s7_isotcp.cpp \
              ../snap7-full-1.4.1/src/core/s7_micro_client.cpp \
              ../snap7-full-1.4.1/src/core/s7_partner.cpp \
              ../snap7-full-1.4.1/src/core/s7_peer.cpp \
              ../snap7-full-1.4.1/src/core/s7_server.cpp \
              ../snap7-full-1.4.1/src/core/s7_text.cpp \
              ../snap7-full-1.4.1/src/lib/snap7_libmain.cpp \
              ../snap7-full-1.4.1/src/sys/snap_msgsock.cpp \
              ../snap7-full-1.4.1/src/sys/snap_sysutils.cpp \
              ../snap7-full-1.4.1/src/sys/snap_tcpsrvr.cpp \
              ../snap7-full-1.4.1/src/sys/snap_threads.cpp
          
          HEADERS += mainwindow.h \
              client.h \
              ../snap7-full-1.4.1/release/Wrappers/c-cpp/snap7.h \
              ../snap7-full-1.4.1/src/core/s7_client.h \
              ../snap7-full-1.4.1/src/core/s7_firmware.h \
              ../snap7-full-1.4.1/src/core/s7_isotcp.h \
              ../snap7-full-1.4.1/src/core/s7_micro_client.h \
              ../snap7-full-1.4.1/src/core/s7_partner.h \
              ../snap7-full-1.4.1/src/core/s7_peer.h \
              ../snap7-full-1.4.1/src/core/s7_server.h \
              ../snap7-full-1.4.1/src/core/s7_text.h \
              ../snap7-full-1.4.1/src/core/s7_types.h \
              ../snap7-full-1.4.1/src/lib/snap7_libmain.h \
              ../snap7-full-1.4.1/src/sys/snap_msgsock.h \
              ../snap7-full-1.4.1/src/sys/snap_platform.h \
              ../snap7-full-1.4.1/src/sys/snap_sysutils.h \
              ../snap7-full-1.4.1/src/sys/snap_tcpsrvr.h \
              ../snap7-full-1.4.1/src/sys/snap_threads.h \
              ../snap7-full-1.4.1/src/sys/sol_threads.h \
              ../snap7-full-1.4.1/src/sys/unix_threads.h \
              ../snap7-full-1.4.1/src/sys/win_threads.h
          
          FORMS += mainwindow.ui
          
          

          But the full project is here https://drive.google.com/file/d/1AWX3xe00D-WWrQwFGi18juR8KBkYkB7V/view?usp=sharing ... also the snap7 project... i'm using qt 5.9.2 with mingw... install it with default options...

          Hope this help

          1 Reply Last reply
          2
          • Z Offline
            Z Offline
            ZekDe
            wrote on last edited by ZekDe
            #31
            This post is deleted!
            1 Reply Last reply
            0
            • D Offline
              D Offline
              Daminos
              wrote on last edited by
              #32

              Hi,

              I'am intersting of this to integrate Snap7 with QtCreator,
              I test your example "test1", it's compiled, but when run the "test.exe" : there is nothing !!
              Have you an idea please ?
              thank you in advanced

              M 1 Reply Last reply
              0
              • D Daminos

                Hi,

                I'am intersting of this to integrate Snap7 with QtCreator,
                I test your example "test1", it's compiled, but when run the "test.exe" : there is nothing !!
                Have you an idea please ?
                thank you in advanced

                M Offline
                M Offline
                mmiacca
                wrote on last edited by mmiacca
                #33

                @Daminos Nothing means? the windos has only two widget that show variables from plc, put a breakpoint in the following function...

                void MainWindow::scan()
                {
                //ui->log->setText(logMessage);

                union U
                {
                    unsigned char x[4];
                    float f;
                } u;
                
                int err = Client->DBRead(380, 160, 4, u.x);
                unsigned char aux;
                
                aux = u.x[0];
                u.x[0] = u.x[3];
                u.x[3] = aux;
                
                aux = u.x[1];
                u.x[1] = u.x[2];
                u.x[2] = aux;
                
                if(!err)
                {
                    ui->value_0->setValue(u.f);
                    ui->value_1->setValue(u.f);
                
                    ui->value_0->setStyleSheet("");
                    ui->value_1->setStyleSheet("");
                }
                else
                {
                    ui->value_0->setValue(0);
                    ui->value_1->setValue(0);
                
                    ui->value_0->setStyleSheet("background-color: rgb(255, 0, 0);");
                    ui->value_1->setStyleSheet("background-color: rgb(255, 0, 0);");
                
                    // Connection
                    int error = CliConnect();
                    if(!error)
                    {
                
                    };
                
                }
                
                char valor;
                err = Client->DBRead(380, 151, 1, &valor);
                ui->checkBox->setChecked(valor & 0x01);
                

                }

                1 Reply Last reply
                3
                • D Offline
                  D Offline
                  Daminos
                  wrote on last edited by Daminos
                  #34

                  @mmiacca
                  Thanks a lot, it's worked now :D
                  I have another question please : are you tested this example with Logo_8 ?
                  Best regards,

                  M 1 Reply Last reply
                  0
                  • D Daminos

                    @mmiacca
                    Thanks a lot, it's worked now :D
                    I have another question please : are you tested this example with Logo_8 ?
                    Best regards,

                    M Offline
                    M Offline
                    mmiacca
                    wrote on last edited by
                    #35

                    @Daminos good.... i do not test this with logo, only S7-400... do you change the cpu TCP/IP address and slot in the logo and in the code?

                    D 1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      Daminos
                      wrote on last edited by
                      #36

                      @mmiacca
                      I'll test that next week (because I wait for the Logo_8), I'll tel you if it's working ;)
                      see you !
                      Best regards,

                      1 Reply Last reply
                      0
                      • M mmiacca

                        @Daminos good.... i do not test this with logo, only S7-400... do you change the cpu TCP/IP address and slot in the logo and in the code?

                        D Offline
                        D Offline
                        Daminos2
                        wrote on last edited by
                        #37

                        @mmiacca Hi mmiacca, I tested the connection code with the Logo_8, and it's worked ;)
                        Best regards,
                        Daminos

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved