hi, please i want some help, I wrote a simple code that have to write and read into a PLCsim (S71500) the I/O and the memory adress using sharp7 library and i used a block of cyclicintrrupt (OB30) / and timedelay(OB10) to repeat my function (just 50 times) , I tried at first to code it with multivars:
i need to read I0.0//Q0.0// %MD0//%MD4,
this what i found in the console application
{Connected to PLC
Error write: CPU : Function not available
Error Read: ISO : Invalid PDU received }
this is my code:
{
S7Client client = new S7Client();
intresult=client.ConnectTo("192.168.0.100",0,1);if(result==0){Console.WriteLine("Connected to PLC");}else{Console.WriteLine(client.ErrorText(result));return;}floaty2;floatx;boolQ,I;byte[]db1Buffer1=newbyte[10];TextWriterwriter1=newStreamWriter(@"C:\folder\saffae.txt");writer1.Write("les entrées les sorties");writer1.WriteLine("");// Write multivars vars7MultiVar=newS7MultiVar(client);byte[]db10=newbyte[10];S7.SetBitAt(refdb10,0,0,true);s7MultiVar.Add(S7Consts.S7AreaPE,S7Consts.S7WLBit,0,0,db10.Length,refdb10);;intresult0=s7MultiVar.Write();if(result0!=0){Console.WriteLine("Error: "+client.ErrorText(result0));}// Read multi varsvars7MultiVar1=newS7MultiVar(client);byte[]db1=newbyte[1];s7MultiVar1.Add(S7Consts.S7AreaPE,S7Consts.S7WLBit,0,0,db1.Length,refdb1);byte[]db11=newbyte[1]s7MultiVar1.Add(S7Consts.S7AreaPA,S7Consts.S7WLBit,0,0,db10.Length,refdb11);byte[]db12=newbyte[8];// i need tow real (%MD0 and %MD4)s7MultiVar1.Add(S7Consts.S7AreaMK,S7Consts.S7WLByte,0,0,db10.Length,refdb12);intresultt=s7MultiVar1.Read();if(resultt!=0){Console.WriteLine("Error: "+client.ErrorText(resultt));}I=S7.GetBitAt(db1,0,0);if(I==true){do{x=S7.GetRealAt(db12,10);y2=S7.GetRealAt(db12,11);Q=S7.GetBitAt(db11,0,1);writer1.Write("\t"+x+"\t"+"||"+y2);writer1.WriteLine("");}while(Q!=true);}writer.Close();MessageBox.Show("saved");Console.ReadKey();}Pleasehowcanresolveitorcodeitinotherways???://
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Mr Nardella, i 'm actually able to read and write data with plcsim by the sharp7 library but i when i tried to use a real plc (1215C dc/dc/dc (new version)) the same error is shown for both the read and the write part ( error PDU passed to send/receive) , i configured the plc just like it mentionned on the documentation of the library..
could you please tell me the cause of this error and how it could be fixed..
please i'm waiting for your reply
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi, please i want some help, I wrote a simple code that have to write and read into a PLCsim (S71500) the I/O and the memory adress using sharp7 library and i used a block of cyclicintrrupt (OB30) / and timedelay(OB10) to repeat my function (just 50 times) , I tried at first to code it with multivars:
i need to read I0.0//Q0.0// %MD0//%MD4,
this what i found in the console application
{Connected to PLC
Error write: CPU : Function not available
Error Read: ISO : Invalid PDU received }
this is my code:
{
S7Client client = new S7Client();
S7WLBit needs 1 as size, look at Snap7 reference manual.
Last edit: Safa boumaiza 2017-04-14
ok I'll take a look right now, thank you !! ^^
ok I'll take a look right now, thank you !! ^^
Hi Mr Nardella, i 'm actually able to read and write data with plcsim by the sharp7 library but i when i tried to use a real plc (1215C dc/dc/dc (new version)) the same error is shown for both the read and the write part ( error PDU passed to send/receive) , i configured the plc just like it mentionned on the documentation of the library..
could you please tell me the cause of this error and how it could be fixed..
please i'm waiting for your reply