Vai al contenuto
PLC Forum


PLC and C# communicate via snap7


zoltanherczeg

Messaggi consigliati

Hello,

I have a problem with C# (visual studio 2015) and siemens PLC. I would like to write a program which can controll my PLC via Buttons in C# (SET/RST). I could write one which can connect and read/write the Data and multiple.
But unfortunately I can not find how i can Set/Rst an output on PLC with Button.

There is a photo of my code and there what i need also.!

link to  photo

I would be so happy if someone could . me.

Have a nice day.

 

 

 

Link al commento
Condividi su altri siti


You may have a solution this way...for example you can send a frame (buffer out) where you map your information in. First byte could  be the udentification of the area , second byte the number of the bit and third byte the value , 1=set , 0=reset .You can call this function into your click event when the button is pressed down .When you release the button you have to send the same information but the value=0 instead of 1 .

try to image what can happen when you set a bit into a plc and then you loose the communication ....If you want to set permanent bit into a plc you have to control when the communication has a fault or it drop down .

Otherwise try to check by using the intellisense if you have some function already done to do this job , client [dot] and take a look about the purpose of intellisense,it maybe shows you some function for bits using .I would like to suggest you to get a status of the connection and to use it before write something to the plc , and also the try-catch-exception to catch the exception and manage it .Try to think what the application will do if the connection isn't estabilished or it something wrong ....

Finally , if your application SCADA is complex or medium -big , I think it's better you study and understand some of the 23 design patterns to get a well solutions and let your application gains several performances. Design patterns you may use are Proxy, Adapter, Observer (you can do this with delegation) , Facade .When you have an industrial application which is working with local and remote databases, interaction with human and plc and else , you have to design it well to avoid bad surprises. 

ciao 

Walter

 

Link al commento
Condividi su altri siti

Crea un account o accedi per commentare

Devi essere un utente per poter lasciare un commento

Crea un account

Registrati per un nuovo account nella nostra comunità. è facile!

Registra un nuovo account

Accedi

Hai già un account? Accedi qui.

Accedi ora
×
×
  • Crea nuovo/a...