Sign in to follow this  
Followers 0
Pavan

mx-components

7 posts in this topic

hi to all supports........; i have the mx- component software .... how to use mx component in vb.net programming . in order to read and write data from\ to plc................ Thanks nd regards.......

Share this post


Link to post
Share on other sites
The MX Component CD should have a directory of sample files, or it should install samples onto the hard drive during the installation. It's an ActiveX control. Add it to your program and code as you would any ActiveX control.

Share this post


Link to post
Share on other sites
hellloooo dear.....; already am having the mx component software version 4 and i have install in my pc..... but i dnt how to communicate the serial port communication with plc in vb.net......... can plz help me am fresher.....

Share this post


Link to post
Share on other sites
I don't have MX Components installed at the moment, but the manual pretty much says it all.

Share this post


Link to post
Share on other sites
it's been a while since i used MX components and it was not in .NET but the idea is to: - install Visual Studio and all updates - install MX Components - create new project in Visual Studio, - include reference to MX components (adds objects to tool bar, you should see more items among button, text, label etc) - drag and drop MX object into your project - configure MX object (before you do this you may want to try sample tools and project, they show you what connection should look like). this includes specifying type of target PLC, communication port, slot in the plc rack etc. - check and reuse code samples from provided demos, you will want to create functions to make and break connection etc. Everything you need is on MX disc...

Share this post


Link to post
Share on other sites
Imports System.Text Public Class Form1 Const ELEMENT_SIZE_16BITINTEGER = 2 Dim iReturnCode As Integer 'Return code 'Error Handler On Error GoTo CatchError 'Set the value of 'LogicalStationNumber' to the property. AxActUtlType1.ActLogicalStationNumber = CInt(txt_LogicalStationNumber.Text) 'The Open method is executed. iReturnCode = AxActUtlType1.Open() 'When ActUtlType returns error code, display error message. If iReturnCode <> 0 Then DisplayErrorMessage(iReturnCode) Exit Sub End If Exit Sub CatchError: 'Exception processing MsgBox(Err.Description(), MsgBoxStyle.Critical) End End Sub Private Sub btn_Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Close.Click Dim iReturnCode As Integer 'Return code 'Error Handler On Error GoTo CatchError 'The Close method is executed. iReturnCode = AxActUtlType1.Close() 'When ActUtlType returns error code, display error message. If iReturnCode <> 0 Then DisplayErrorMessage(iReturnCode) Exit Sub End If Exit Sub CatchError: 'Exception processing MsgBox(Err.Description(), MsgBoxStyle.Critical) End End Sub Dim iReturnCode As Integer 'Return code Dim sharrBufferForDeviceValue(ELEMENT_SIZE_16BITINTEGER - 1) As Short 'Array for using BitConverter class Dim byarrBufferByte(ELEMENT_SIZE_16BITINTEGER * 2 - 1) As Byte 'Array for reading to the PLC Dim byarrTemp() As Byte 'Temporary array for copying data Dim iNumber As Integer 'Loop counter 'Error Handler On Error GoTo CatchError 'The ReadDeviceBlock2 method is executed.(from D10-D11) iReturnCode = AxActUtlType1.ReadDeviceBlock2("D11", _ ELEMENT_SIZE_16BITINTEGER, _ sharrBufferForDeviceValue(0)) 'When ActUtlType returns error code, display error message. If iReturnCode <> 0 Then DisplayErrorMessage(iReturnCode) Exit Sub End If 'Convert the 'sharrBufferForDeviceValue' to the array for using BitConverter class. For iNumber = 0 To ELEMENT_SIZE_16BITINTEGER - 1 byarrTemp = BitConverter.GetBytes(sharrBufferForDeviceValue(iNumber)) byarrBufferByte(iNumber * 2) = byarrTemp(0) byarrBufferByte(iNumber * 2 + 1) = byarrTemp(1) Next iNumber 'Convert the 'byarrBufferByte' to 32bit integer, and set the data to the TextBox as string. txt_Read32bitInteger.Text = CStr(BitConverter.ToInt16(byarrBufferByte, 0)) Exit Sub CatchError: 'Exception processing MsgBox(Err.Description(), MsgBoxStyle.Critical) End End Sub Private Sub DisplayErrorMessage(ByVal iActReturnCode As Integer) Dim szActErrorMessage As String 'Message as the return code of ActUtlType Dim iSupportReturnCode As Integer 'Return code of ActSupportMsg 'The GetErrorMessage method is executed iSupportReturnCode = AxActSupportMsg1.GetErrorMessage(iActReturnCode, szActErrorMessage) 'When ActSupportMsg returns error code, display error code of ActUtlType. If iSupportReturnCode <> 0 Then MsgBox("Cannot get the string data of error message." & vbLf & _ " Error code = 0x" & Hex(iActReturnCode), _ MsgBoxStyle.Critical) Else MsgBox(szActErrorMessage, MsgBoxStyle.Critical) End If End Sub Private Sub DisplayErrorMessage(ByVal iActReturnCode As Integer) Dim szActErrorMessage As String 'Message as the return code of ActUtlType Dim iSupportReturnCode As Integer 'Return code of ActSupportMsg 'The GetErrorMessage method is executed iSupportReturnCode = AxActSupportMsg1.GetErrorMessage(iActReturnCode, szActErrorMessage) 'When ActSupportMsg returns error code, display error code of ActUtlType. If iSupportReturnCode <> 0 Then MsgBox("Cannot get the string data of error message." & vbLf & _ " Error code = 0x" & Hex(iActReturnCode), _ MsgBoxStyle.Critical) Else MsgBox(szActErrorMessage, MsgBoxStyle.Critical) End If End Sub i have this code am getting the output for that.....simuntanously i need another i had used same code and changed the varibles but am not getting am a fresher plz help me ....

Share this post


Link to post
Share on other sites
Not sure what you're asking, are you trying to run two readings from the PLC at the same time? The PLC can only handle one request at a time so you'll have to program a sequence that reads data one after the other...

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