TommyGoh

MITSUBISHI PLC TO VB SETDEVICE

6 posts in this topic

Hi,

Have anybody knows how to SetDevice ? I only managed to make GetDevice working here on VB script here

Share this post


Link to post
Share on other sites

Can you be more specific? I assume you are working with MX components? 

Which version are you using ?

Have you checked the sample scripts?
[User specified folder] - [Act] - [Samples] - [VBScript] - [SampleHTML]

varRet = object.SetDevice2(varDevice, varData)

VARIANT varRet Returned value (LONG type) Output
VARIANT varDevice Device name (character string type) Input
VARIANT varData Set data (SHORT type) Input

Share this post


Link to post
Share on other sites

yeah. i'm working with MX Components. and doing it with VB

i managed to make the GetDevice working. but not successful with SetDevice. Here's the code

        Dim lData(20) As Long 'Monitor device value storage
        Dim lRet As Long 'Return value

        lRet = AxActEasyIF1.GetDevice("Y001", lData(0))
        lRet = AxActEasyIF1.GetDevice("Y002", lData(1))
        lRet = AxActEasyIF1.GetDevice("Y003", lData(2))
        lRet = AxActEasyIF1.GetDevice("Y004", lData(3))
        lRet = AxActEasyIF1.GetDevice("Y005", lData(4))
        lRet = AxActEasyIF1.GetDevice("Y006", lData(5))
        lRet = AxActEasyIF1.GetDevice("Y007", lData(6))
        lRet = AxActEasyIF1.GetDevice("Y008", lData(7))

        lRet = AxActEasyIF1.GetDevice("X0", lData(13))
        lRet = AxActEasyIF1.GetDevice("X1", lData(14))
        lRet = AxActEasyIF1.GetDevice("X2", lData(15))
        lRet = AxActEasyIF1.GetDevice("X3", lData(16))
        lRet = AxActEasyIF1.GetDevice("X4", lData(17))
        lRet = AxActEasyIF1.GetDevice("X5", lData(18))
        lRet = AxActEasyIF1.GetDevice("X6", lData(19))
        lRet = AxActEasyIF1.GetDevice("X7", lData(20))

        lRet = AxActEasyIF1.GetDevice("D1", lData(8))
        lRet = AxActEasyIF1.GetDevice("D2", lData(9))
        lRet = AxActEasyIF1.GetDevice("D3", lData(10))
        lRet = AxActEasyIF1.GetDevice("D4", lData(11))
        lRet = AxActEasyIF1.GetDevice("D5", lData(12))

        If lRet <> 0 Then
            txtStatus.Text = "Error occurrence (Error code: " + (lRet).ToString + ")" 'Display the error code at error
        End If

        If cb1.Checked Then

            lRet = AxActEasyIF1.SetDevice("Y001", 1)
            System.Console.WriteLine(lData(0))
        End If

 

Am I missing something ? Or do I set wrongly ?

Share this post


Link to post
Share on other sites

Have you checked the sample code from MX components?

C:\MELSEC\Act\Sample\Vb.NET\Sample\AssemblyInfo.vb Assembly information file
C:\MELSEC\Act\Sample\Vb.NET\Sample\Sample.resx Resource file
C:\MELSEC\Act\Sample\Vb.NET\Sample\Sample.sln Visual Studio Solution file
C:\MELSEC\Act\Sample\Vb.NET\Sample\Sample.vb VB file
C:\MELSEC\Act\Sample\Vb.NET\Sample\Sample.vbproj VB main project file

Have you tried  SetDevice 2 as  SetDevice  is for a long type

 

Share this post


Link to post
Share on other sites

yeah. I have checked the files. But they have no references for SetDevice. Have tried SetDevice2 also. Still same problem

Share this post


Link to post
Share on other sites
On 12/02/2018 at 4:58 AM, TommyGoh said:

yeah. I have checked the files. But they have no references for SetDevice. Have tried SetDevice2 also. Still same problem

I did't try the Setdevice, but I managed to write bit to plc using this fonction!

LRET = AxActUtlType1.WriteDeviceRandom2("M406", _                                 where you want write
                                                         "1", _                    how much data you want write
                                                         "1")                      what you want write

I change the "m406" to the output/registrary, keep the middle line as it, and change the last line to my needs!!

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