Sign in to follow this  
Followers 0
WangChao

[help] have problem with MC Protocol using binary code in QnA compatible 3E frame.

6 posts in this topic

[solved] i set the ERROR network No. which leads to the fault. thank you for your replies. Hello ,im trying to communicate with my mitsunshi plc(with qj71e71 module) using MC Protocol's 3E frame. first i used the ASCII code way ,and succeeded. then to speed up the communication, i tryed the binary code way,Unfortunately it just renturned the "abnormal completion" response as the manual says. here is my main C# code: using System.Globalization; using System.Windows.Forms; using System; using System.Net; using System.Net.Sockets; using System.Data; using System.Collections.Generic; using System.Text; private void button1_Click(object sender, EventArgs e) { Socket mysock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Parse("192.168.0.2"); IPEndPoint ipend = new IPEndPoint(ip, 7100); try { mysock.Connect(ipend); MessageBox.Show("?????"); } catch { MessageBox.Show("?????"); return; } byte[] SData=new byte[] { 0x50,0x00,//3E frame //[b] 0x02,//??? network No.[/b] 0x00//0x00 is the true network No. 0xff,//pc No. 0xff,//io No 0x03, 0x08,//?? Station No 0x0c,//[i]timer?????[/i] length of the request data which is started from timer byte to end 0x00, 0x0a,//timer 0x00, 0x01,//???Main Command 0x04, 0x01,//???sub command 0x00, 0x01,//the head device No. is 1, //read the M1's value 0x00, 0x00, 0x90,//'M' device 0x01,//1 point 0x00 }; byte[] RData = new byte[256]; try { mysock.Send(SData); mysock.Receive(RData); } catch { MessageBox.Show("?????"); return; } mysock.Close(); } what can i do to solve this problem? the response from the plc is showed blow: Edited by WangChao

Share this post


Link to post
Share on other sites
Hello, 0x0c,//timer????? 0x00, 0x0a,//timer 0x00, Not sure why you have this twice for the CPU monitoring timer, but I stopped looked when I got here. ASCII is two bytes, Binary is one. Download the demo installer of PeakHMI and install it. Create a project and in configuration mode create a read for the data and use the test button to check the read. Using WireShark capture the packet and look at the bytes.

Share this post


Link to post
Share on other sites
thank you for u reply,the 0x0c and 0x00 means the request data length ,i forgot to translate the comments"?????". Edited by WangChao

Share this post


Link to post
Share on other sites
Instead of using endless hours on programming the protocol yourself why don't you just purchase MX Components? dlls for using directly in C#, a couple of lines of code and your good to go? Or, as Mark says, use Wireshark and post the results (both request and response)

Share this post


Link to post
Share on other sites
OK,i installed the iwreshark,and got the folowing info: the request from my c# code: and the response from the plc,same result as i put in the 1st post: Edited by WangChao

Share this post


Link to post
Share on other sites
Hi, I said to use PeakHMI demo installer, create the read, capture the read response and then look at the send and response data because the PeakHMI driver does create the proper packet.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0