Boushard

MX-Component V4.09K to VB.Net

9 posts in this topic

Hi guys,

I'm currently on a positioning project with a Servo and I need to pull my data from a VB.NET application!

I try to "link" MX-Component into my VB.Net application but I'm in a struggle right now!

Anyone of you have ever use this combination to send data to a PLC!

 

Current setup:

PLC: FX3U-32MT/DSS

Ethernet Card: FX3U-ENET-ADP

Drive: MR-JE-20A

Servo:HG-KN23JK

Software:

VisualStudio 2013/15

MX-Component V4.09K

GX-Works 2 

 

Thanks in advance to anyone who can help me!

Edited by Boushard

Share this post


Link to post
Share on other sites

Hi,

Take a look at the following topics and see if they can help you. If not, post back. It is supposed to work, but the registration of the components is a hazzle. If possible, I would recommend using an OPC client for .NET and then poll data via the OPC server.

Let us know how it works out.

 

 

Share this post


Link to post
Share on other sites

Thx SIr,

I'll take a look at this and will replie positive or negative!!

Share this post


Link to post
Share on other sites

The connection part is fixed. I can read/write PLC data from example included in MX-Component.

I'm now on the integration of the fonction into my application.

Basically I want to:

  • write DWord(32bit) data into 4 "D" register when I click on a button.
  • Live Read value of a simple Counter
  • Live Monitor the "D8340, Y000 Current_value_register" and convert the data into "mm" on the fly
  • Monitor I/O 
  • Control Output with "M" relay

If someone want to take a look at the VB.Net app I can post the code and also post my PLC program.

Share this post


Link to post
Share on other sites

Little update!

My application can send DWORD to PLC when I press a button.

But since I switch to Ethernet connection type I have a 0x01808007 error code. According to the MX-Component manual, this error refer to "Socket object generation error; Creation of the Socket object failed"  

I can access the plc with GX-Works 2 via Ethernet, but the communication with my application isn't working.  I try to open port 5556 in both ways on TCP protocol without success.

Communication utility of MX-Component is correctly set, since the connection test is successful, I've copied every value into the "AxActProgType1" property and still no go.

Connection setting in VB.NET

AxActProgType1.ActUnitType = UNIT_FXETHER
AxActProgType1.ActProtocolType = PROTOCOL_TCPIP

Anyone have an idea what's wrong!?! 

I've attached the connection setting automatically generated by the "Communication Setup utility" and a print screen of the ethernet adapter setting in GX-Works 2.

Capture.JPG

Connection setting.txt

Edited by Boushard

Share this post


Link to post
Share on other sites

Finally everything work on the VB.NET app side!!

However I can't make a connection without the "Communication Setup Utility" installed on the pc.

The VB code is probably not the prettiest but everything work as it should.

Thanks to all of you for your help!!

Share this post


Link to post
Share on other sites

Hi Boushard,

Does this " Communication Setup Utility " comes with MX Component.

Is it possible for you to post your VB.net app.  I am a newbie to this and i have the same requirements as your basic requirements.

  • write DWord(32bit) data into 4 "D" register when I click on a button.
  • Live Read value of a simple Counter

Thanks...

 

Share this post


Link to post
Share on other sites

https://drive.google.com/folderview?id=0B18MSGbV_z7RYXlrU2tMd2RsWTg&usp=sharing

 

To VB is written in french so if you have any question let me know!

The MX-Component bundle include 3 software:

-Communication Setup Utility

-Label Utility

-PLC Monitor Utility

 

Basically you have to add the "AxActUtlType1" function to all of the forms who require a communication with the PLC.

Add "ActDefine.vb" to your project

Add "MITSUBISHI ActUtlType Controls Ver1.0" to your reference.

 

After that I use 3 functions

first:

'before all of your code to run the function below
Const ELEMENT_SIZE_32BITINTEGER = 2 'Size of elements, when write/read '32bit Integer' data to the PLC.


byarrBufferByte0 = BitConverter.GetBytes(CInt(number you want to write)

            sharrBufferForDeviceValue(0) = BitConverter.ToInt16(byarrBufferByte0, 0) 	'conversion into two Dxxx if the number is too big for a 16bit
            sharrBufferForDeviceValue(1) = BitConverter.ToInt16(byarrBufferByte0, 2)

            'The WriteDeviceBlock2 method is executed.(to D14-D15)
            LRET = AxActUtlType1.WriteDeviceBlock2("D308", _							'where you want to write
                                                         ELEMENT_SIZE_32BITINTEGER, _	'do not toutch this line
                                                         sharrBufferForDeviceValue(0))	'data obtain whit the conversion above

 LRET = AxActUtlType1.WriteDeviceRandom2("M400", _						'where you want to write
                                                    "1", _				'leave this at 1
                                                                  "1")	'what you want to write

'Monitoring internal relay or input
		Dim LDATA(2) As Long	'set according to the number of relay you want to monitor starting with 0 as first
        Dim LRET As String
        

        LRET = AxActUtlType1.GetDevice("M30", LDATA(0))
        LRET = AxActUtlType1.GetDevice("M160", LDATA(1))

It's almost that!!

 

If you have any question don't hesitate!! 

Share this post


Link to post
Share on other sites
On 9/8/2016 at 9:20 PM, Boushard said:

Finally everything work on the VB.NET app side!!

However I can't make a connection without the "Communication Setup Utility" installed on the pc.

The VB code is probably not the prettiest but everything work as it should.

Thanks to all of you for your help!!

Hi, do you have any way to connection PLC without "Communication Setup Utility", please help me

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