Connect to Siemens S7 plc with C# and S7.Net

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 113

  • @rigoltee
    @rigoltee 2 года назад

    Hi, Thanks for the useful video, what software would you recommend to simulate the PLC device if we have no PLC to connect to?

    • @Mesta-automation
      @Mesta-automation  2 года назад

      I think the simulator of TIA Portal works. Or eventually just mock the driver altogheter. There is an example on "HMI with WPF part 3" where I use a DummyPlcService.

  • @shuvendudas2807
    @shuvendudas2807 4 года назад +1

    Hello Mesta Thanks for your video.Can you please tell me that how I can connect to "S7 200 smart" plc? Will it require tsap and what is the configuration for PLC?

  • @JustoDisla
    @JustoDisla 4 года назад +1

    Can s7 be used in real time production environment with Siemens controllers?

  • @zaweerzulkivly4405
    @zaweerzulkivly4405 7 лет назад +2

    hi there, this is a very useful video for me. Currently I am doing TIA Openness, do you have any idea on it? The concept is still the same using Visual Studio and TIA Openness. I really hope i can contact you

  • @rafaelbonatto9143
    @rafaelbonatto9143 4 года назад

    Thank you very much for the video.
    Is it possible to place NetTOPLCSIM inside the C # library?

  • @nada2668
    @nada2668 4 года назад

    Thank you for watching the example
    I'm testing it now
    When using S7.Net, we ask if there is a license
    Should I buy and use it?

  • @walterp7125
    @walterp7125 3 года назад

    But must to pay for this library ?

  • @maxencecharbonnier708
    @maxencecharbonnier708 5 лет назад

    Hello Thao,
    Do you remember what was your firmware?
    I can easily connect to my plc, but i can't read anything :( while i desactivitez optimized block, and all protections.
    Thank you

  • @draqos
    @draqos 3 года назад

    Hey man, do you know any possibility for a PLC like S7-1200 to work as a TCP socket listener so any random IPs from the same subnet could connect at it ? (I am not thinking to MODBUS, just TCP only) - thanks!

  • @mohamedabdel-raouf3476
    @mohamedabdel-raouf3476 6 лет назад +2

    Hello ,
    Can you guild me to what i should do to read data continuously from PLC ?

  • @LorridoWelcome
    @LorridoWelcome 7 лет назад +1

    Thanks for this tutorial, but when it comes to LReal and LInt how do you convert them to get the right value in c#?

  • @eduardoescobar5786
    @eduardoescobar5786 Год назад

    How do I assign the offset ?, e.g. 0.0, 0.1 that you have shown.
    It shows that I can't modify that value
    I am using tia 16

  • @yasirhabibkhugiani
    @yasirhabibkhugiani 8 лет назад

    thank for the video, it is helpful. I have a question, is there any way we can access the DBs dynamically from the PLC?
    like lets say we want to find out how many DBs are there in a PLC?

  • @manzarkazmi3658
    @manzarkazmi3658 5 лет назад +1

    Thank you for the tutorial. My question is can we read the values without using datablocks in TIA portal? thank you

  • @massiv0n
    @massiv0n 3 года назад

    Hey Buddy! can you help me? I'm trying to write and get the value to this address DB14.STRING6.20 and I can't do it. Is giving me the error WrongVariableFormat or something like that.
    Do you know KEPServer tool ? I can access, write and read to this address without problems. Do you know how I can make it ?
    Sometimes, the factory line production is giving me the batch number or another important stuff and this is important for me.
    Thanks!

  • @libnerrr
    @libnerrr 8 лет назад +1

    Exactly what I've been looking for last few weeks! Thank you!

  • @fcibe1
    @fcibe1 3 года назад

    Very interesting video, hi, I'm using this library, unfortunately I haven't found a way to use the events on datachange, can you help me? thank you

  • @JMMedinaDev
    @JMMedinaDev 6 лет назад

    Ciao Michele, Can you pls tell me if the Dll packed on Nugets is the full Dll with no dependencies to other libraries? I am trying to build this in unity Game Engine and I want to be sure it havent more dependencies than his own Dll. I dont want to go Web Server way , its not professional.

  • @nitinmajgaonkar3060
    @nitinmajgaonkar3060 2 года назад

    What is the difference between S7.net Library & Snap7 library ? Thank you in advance

  • @NathanStorniolo
    @NathanStorniolo 3 года назад

    Hi, how can i connect a live chart, showing the present value?

  • @azdasheerkhader2120
    @azdasheerkhader2120 3 года назад

    Hello i need the port can help me ?

  • @Matt-bf4wp
    @Matt-bf4wp 4 года назад

    Ciao, funziona anche con s7 300 usato col vecchio simatic manager?

  • @jurajschmidt5254
    @jurajschmidt5254 6 лет назад

    Is it compatible with different PLC, (B&R, Mitsubishi)?

  • @PIDOtomasyon
    @PIDOtomasyon 5 лет назад +1

    hi, can I syncr time of plc with c# ?
    Can you help me? urgent please.

  • @mattiapavoni6635
    @mattiapavoni6635 7 лет назад

    Hi, there is a possibility that after some time without closing the connection with the plc the read class read some strange value? Like 2.xxxE-38 instead of 170666 for a double variable. if i have a service, it's better to keep connection always open or close it and reopen after some times? Thanks.

    • @Mesta-automation
      @Mesta-automation  7 лет назад

      It shouldn't happen. Do you check LastErrorCode and/or LastErrorString after every read, before using the values? Usually with TCP sockets it's normal to keep the socket open and check from time to time if the connection is still alive.
      You probably need to investigate more, if this happens only with the double or also if other values are corrupted. Also try to replace ReadClass with a ReadBytes and assign the values manually, to check if it is an issue of the ReadClass method.

  • @leonesmoura8756
    @leonesmoura8756 3 года назад

    It's possible conexion in C++?

  • @nqaiser
    @nqaiser 6 лет назад +1

    hello, Thanks For a great tuturial, Can you confirm if this library will work for PCS7 system (Siemens s7 4105h plcs)
    Thanks.

  • @shaileshbangale1395
    @shaileshbangale1395 3 года назад

    Can you provide same for Profibus driver? I want to communicate VB.net application with S7-300 with Profibus driver. Please help.

  • @mattiapavoni6635
    @mattiapavoni6635 8 лет назад

    Hello, if i want to use the method ReadClass with a dataBlock bigger than 200 Bytes, how can i do it? I must create 2 different classes?
    Thanks!

    • @Mesta-automation
      @Mesta-automation  8 лет назад

      +Mattia Pavoni it should work also for more than 200 bytes. The comment is outdated.

    • @mattiapavoni6635
      @mattiapavoni6635 8 лет назад

      Ok, thanks. Sorry but i have some other question. If i want to use ReadClass, i have to use the same name for the variable inside the PLC and inside the class? if i have to read a block of byte representing a string how can i do that? i try declaring an array of bytes but it doesn't work...
      Thank you very much!

    • @Mesta-automation
      @Mesta-automation  8 лет назад

      Strings are not supported in ReadClass at the moment, but you can download the sources and contribute to the project.
      Regarding the names, it's not needed that the names in the class are the same as the names of the DB. The order and variable type in C# must be the same of the DB.

  • @kenhthoinontre1628
    @kenhthoinontre1628 7 лет назад +1

    WHICH VERSION TIA PORTAL DO YOU USE IN THIS VIDEO???
    I USE TIA PORTAL V13 STEP 7 PROFESSIONAL BUT CAN NOT OPEN YOUR FILE

    • @michelecattafesta9122
      @michelecattafesta9122 7 лет назад +1

      Tia V13 SP1. Unzip in a folder then on Tia portal: Project -> Open

  • @captfcknut
    @captfcknut 7 лет назад

    Can you tell me why you only use DBXX addresses instead of usong the native addresses of the PLC, such as %Q, %I, %QW, %IW? Thanks!

  • @PsykeBr
    @PsykeBr 8 лет назад

    Hello! Nice work!
    Is possible to use that code with advanced HMI controls?
    Thx!

    • @Mesta-automation
      @Mesta-automation  8 лет назад +1

      You can use them togheter.
      The easiest and safest way is to write the "Value" property of the HMI controls from the code.
      You can also implement the interface ICommComponent, that permits to assign a Tag to a control and the control gets the value by polling the plc.
      Personally I would go with the first approach.

    • @PsykeBr
      @PsykeBr 8 лет назад

      +Mesta Automation Could you provide an exemple? That would help me a lot!
      Thanks again!

    • @Mesta-automation
      @Mesta-automation  8 лет назад +1

      I'll see if I can do that this weekend.

  • @waqarhissam3331
    @waqarhissam3331 7 лет назад

    Hi,
    I have downloaded the TIA Portal Step 7 Professional version V13 from Siemens offical website. During installation it is giving errror that file "SIMATIC_STEP_7_Professional_V13.001 is not found" even the file is existing in the same dierectory where it is looking for it. Please recommend me some solution for it.

  • @earth2201
    @earth2201 7 лет назад +1

    Thanks you so much! This tutorial is so useful!

  • @matejhlaca1152
    @matejhlaca1152 4 года назад

    Helo..how you convert byte (inside is data in hex) to decimal?

  • @shelkadimka
    @shelkadimka 4 года назад

    Thank a lot !! But in v 0.4.0 has no error processing(var result = plc.Open();), plc. Open return void and has no lasterrorcode .....

  • @lechklimczak3976
    @lechklimczak3976 6 лет назад

    Thanks for this video. Function Read / Write Class is working perfectly on newest version TIA15. Regards

  • @alideniz2326
    @alideniz2326 4 года назад +1

    thanks a lot . thank you for posting project.

  • @mustafayurtseveri84
    @mustafayurtseveri84 9 месяцев назад

    The best tutorial. thanks

  • @luslus..19
    @luslus..19 8 лет назад

    Very nice video, thanks for sharing.
    Is it easy to create an HMI on C# with Siemens Logo ?

    • @Mesta-automation
      @Mesta-automation  7 лет назад

      I recently wrote an article on another C# driver that should be compatible with Logo: www.mesta-automation.com/how-to-write-a-siemens-s7-plc-driver-with-c-and-sharp7/
      You can check that out.

    • @luslus..19
      @luslus..19 7 лет назад

      Hello Mestz Automation, The procedure that you did for the S7-1200 is the same for a Logo ?
      I am installing the package S7.Net will try it and will give you a feed back
      Thanks

    • @luslus..19
      @luslus..19 7 лет назад

      The only issue will be with write and read variables because DBs does not exists in logo you have only Input,Outputs, M and NetworkVariable !!!

    • @Mesta-automation
      @Mesta-automation  7 лет назад

      I don't know much about logo plc. You can download the sources from Github and make it work anyway.

  • @hoanghuynhminh9056
    @hoanghuynhminh9056 5 лет назад

    Can you tell me when i use DBW, DBX, and DBD please ? Thank you so much

    • @reverz3
      @reverz3 5 лет назад

      DBX is a bool, DBW a word and DBD a double word

  • @pell5589
    @pell5589 7 лет назад

    I can't read A SINGLE VARIABLE bool type of both DBx... and Qx.y. please help me...thanks so much

  • @nguyenquocbao3812
    @nguyenquocbao3812 5 лет назад

    I got 3 errors that I cant build Visual:
    CS0815 Cannot assign void to an implicitly-typed variable (LINE 17)
    CS1061 'Plc' does not contain a definition for 'LastErrorCode' and no extension method 'LastErrorCode' accepting a first argument of type 'Plc' could be found (LINE 20)
    CS1061 'Plc' does not contain a definition for 'LastErrorString' and no extension method 'LastErrorString' accepting a first argument of type 'Plc' could be found (LINE 20)
    Can you help ?

  • @TheObstkuchen1
    @TheObstkuchen1 6 лет назад

    thank you very much for this awesome tutorial.

  • @rodtaylor6585
    @rodtaylor6585 8 лет назад

    Brilliant video! Thank you for posting it!!

  • @KeshavKumar20
    @KeshavKumar20 7 лет назад +1

    Hi, I'm not using PLCSIM. How can I read the DBs by using this program if PLC is connected directly?

    • @kenhthoinontre1628
      @kenhthoinontre1628 7 лет назад

      HI am the same you too .
      if you have the anwer .please let me know. thanks.
      and when you connect if you not clear it yet , you can communication with me
      my email: hoangtung2205@gmail.com

    • @KeshavKumar20
      @KeshavKumar20 7 лет назад +1

      Hi, I got the solution but I have not tried it yet. We should use Sharp7 library instead of S7.Net.

    • @kenhthoinontre1628
      @kenhthoinontre1628 7 лет назад

      Keshav Kumar
      hi I am not understand yet .about yours talking .
      I have real pleasure S7-1200 .type 1212c .V3
      now I want make 1 project to practice.

    • @kenhthoinontre1628
      @kenhthoinontre1628 7 лет назад

      but I have no idea .

    • @KeshavKumar20
      @KeshavKumar20 7 лет назад

      Do you want to connect your PLC using C#?
      Use Sharp7 library. Do not use S7.Net.
      www.mesta-automation.com/how-to-write-a-siemens-s7-plc-driver-with-c-and-sharp7/

  • @jalmarihuitsikko7211
    @jalmarihuitsikko7211 7 лет назад

    I tried this code on visual studio 2017 But I keep getting "System.InvalidCastException" on a row that reads variable from plc. When I open example project it doesn't throw same exception. What could be a problem? I did get and install the .dll from nuget.

    • @jalmarihuitsikko7211
      @jalmarihuitsikko7211 7 лет назад

      I'd like to add that command like IsConnected() seems to work just fine there's some kind of problem I don't understand yet with commands that read variables.

  • @lukaaEverything
    @lukaaEverything 6 лет назад

    Hello
    I can not read the M1000.0 bit marker.
    MD1004 read well
    System.InvalidCastException: "The specified cast is invalid."
    Thank you

  • @HaiPham-pv5lp
    @HaiPham-pv5lp 5 лет назад

    I got an error :
    System.InvalidCastException: 'Specified cast is not valid.'
    Can you help me to fix it.
    Thank you.!

  • @PIDOtomasyon
    @PIDOtomasyon 5 лет назад

    hi, I cant read and write strings, can you show please.

  • @gabrcatt
    @gabrcatt 4 года назад

    it's appearing error: "Couldn't establish the connection to 127.0.0.1.
    Message: WrongNumberReceivedBytes"
    What is wrong?

  • @НиколайТорощин-е6э
    @НиколайТорощин-е6э 4 года назад

    this library has an error in the file PLCAddress.cs Row 164. you need to fix VarType.Byte to VarType.Bit

  • @99westi
    @99westi 2 года назад

    Great work

  • @JMMedinaDev
    @JMMedinaDev 6 лет назад

    You can only use S7.net and Sharp 7 in C#7 or higher, I have been working around with unity for weeks by now to just notice you simply cant, till unity dont support C# 7. I hope it goes to everyone whom is trying the same. Its simply pointless, tuplas are not supported in unity C# right now and both libraries use it. I just feel I wasted my time :( Gonna turn to try to sniffer the web server from Unity and see how it goes. Give visibility to that, will safe ppl time.

  • @ucanhnguyen1134
    @ucanhnguyen1134 4 года назад

    in reality. We have to update data every mms, how can I do that?

  • @MarioCrispino
    @MarioCrispino 3 года назад

    Interesting video.

  • @faressalah2672
    @faressalah2672 7 лет назад

    can we use it withe S7-200 ??

    • @Mesta-automation
      @Mesta-automation  7 лет назад

      +fares salah no but there is another tutorial in this channel that uses Sharp7, which will work with S7 200

    • @faressalah2672
      @faressalah2672 7 лет назад

      can you give the link of video ? and thanks

  • @libnerrr
    @libnerrr 7 лет назад

    I find ReadClass(); very unstable. Its necessary to keep class properties in order but making any action with class can affect it. According to MSDN " GetProperties(); method does not return fields in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which fields are returned, because that order varies.
    I consider creating an array with names and addressed of variables from plc and looping through to make many single Read();

    • @libnerrr
      @libnerrr 7 лет назад

      I found a better solution. You can create two the same classes. Use ReadClass(); only with one of them and process only the copy.

    • @Mesta-automation
      @Mesta-automation  7 лет назад

      I agree that ReadClass it's not the best implementation possible.
      The point of ReadClass is just to match the same exact structure of a DB in a class, so it can be filled with the data from the plc with a single instruction.
      Of course if you change the order of variables, in the program or in the plc, it will break. It is more fragile than indexing and convert manually all the data, but it saves you a lot of code.

  • @wuchris5242
    @wuchris5242 Год назад

    why readbytes function use 38 bytes?? i'm sorry not understand clearly

  • @loita6112
    @loita6112 6 лет назад

    I can't connect to PLCSIM.Could you tell me why,please!!

    • @Souldk86
      @Souldk86 6 лет назад

      try checking your PG/PC interface, windows "control panel" - switch to small icon, and then "set pg/pc interface" (or similar), the s7 online has to be connected to the PLCsim, for running af simulated PLC, or the network card a real PLC is connected to, if you have one a real one

  • @MrPowerm
    @MrPowerm 4 года назад

    Danke für die Infos :D

  • @simonedallai48
    @simonedallai48 7 лет назад

    ciao michele sei italiano? avrei diverse domande da farti?

    • @Mesta-automation
      @Mesta-automation  7 лет назад

      Ciao, si sono italiano.

    • @simonedallai48
      @simonedallai48 7 лет назад

      Già da tempo programmo in plc e hmi siemens ma a dire il vero sono molto attratto da queste interfacce! Ora la domanda è usando visual studio come interfaccia posso andare a modificare le Db del plc? Mi consiglieresti più vstudio o visual basic da imparare? Grazie

    • @Mesta-automation
      @Mesta-automation  7 лет назад

      Puoi leggere o scrivere sulle DB, non puoi aggiungere/rimuovere variabili, perche' ci sarebbe da compilare e trasferire il software sul plc.
      Visual Basic e' dal 2008 che non e' piu' mantenuto da Microsoft.
      La scelta sta su C# e VB.Net, entrambi in Visual Studio. Tutto lo sviluppo e le novita' di Microsoft sono in C#.
      VB.Net e' mantenuto solo per motivi storici e per la user-base, comunque molto ridotta, e ha valore 0 sul mercato. Il 99% dei nuovi software in .Net usano C#, come tutte le librerie open source.

  • @asphalt_therapy
    @asphalt_therapy 8 лет назад

    Best vid ever

  • @vuminhtien5331
    @vuminhtien5331 6 лет назад

    I can't connect to my real PLC (1212c dc/dc/dc), can someone help me? please

  • @loita6112
    @loita6112 7 лет назад

    i can't fine S7.net.dll

  • @nobleparti
    @nobleparti 7 лет назад

    can u send visual studio C # software link free ware and key? ur video is very helpfull me

    • @Mesta-automation
      @Mesta-automation  7 лет назад +1

      Visual Studio 2017 Community is free. Search it on google.

  • @TheAdlcn
    @TheAdlcn Год назад

    Very very well

  • @caubehinhbong
    @caubehinhbong 5 лет назад

    thank a lot

  • @lexobsm
    @lexobsm 4 года назад

    the only command working on this package is : isconnected, isavailable, open() ..... the others no !!!!
    not usefull really, try to work with a real PLC !!

  • @imran271981
    @imran271981 8 лет назад

    please send your email

  • @Josempe1
    @Josempe1 3 года назад

    Can I use S7.Net with STEP 7? I have a s7400.

  • @matejhlaca1152
    @matejhlaca1152 4 года назад

    Also..how to pass the string? does the program know that first byte is total lengh and second the actual lenght?

    • @matejhlaca1152
      @matejhlaca1152 4 года назад

      Already solved this...if it will help somebody
      string Koda = S7.Net.Types.String.FromByteArray(db4Bytes.Skip(6).Take(40).ToArray());
      Koda = Koda.Replace("\0", string.Empty); //remove blank positions from stirng

    • @lamsonlemai6516
      @lamsonlemai6516 3 года назад

      @@matejhlaca1152 hi matej, can you explain for details ? FromByteArray with its contructors ?

    • @lamsonlemai6516
      @lamsonlemai6516 3 года назад

      @@matejhlaca1152 thanks, I've just solved it.