Sign in to follow this  
Followers 0
joven

Visual Basic program to communicate FX2n PLC

21 posts in this topic

Hi, I am developing a visual basic program and PLC program (FX2n) but i don't know the code to communicate this two programs. Please help...

Share this post


Link to post
Share on other sites
Hi There are several ways to make this connection, do you use the comunication port or and communication module?? Visual Basic 6.0 or .NET?

Share this post


Link to post
Share on other sites
The easiest way would be to get an ActiveX control that handles the PLC communications. Mitsubishi offers a package called MX-Component that does just that. You just go into a wizard and configure your PLC, assign it a logical station number, and then call the ActiveX and give it that station number.

Share this post


Link to post
Share on other sites
Private Sub Timer 1-Timer() Form l. MSComm l. CommPort=1 Form l. MSComm l. Settings="9600,e,7,2" Form l. MSComm l. Port Open=True R$="@ 00RD00000004" RD$=R$+fcs(R$) Form 1. MSComm 1.In Buffer Count=0 Form 1. MSComm 1.Output=RD$+Chr$(13) Do Dummy=Do Everts(1) Loop Until Form 1. MSComm 1. In Buffer Count>=27 Instring$=form1. MSComm 1. Input Label 1(0). caption=MID$(instring$,8,4) Label 1(1). caption=MID$(instring$,12,4) Label 1(2). caption=MID$(instring$,16,4) Label 1(3). caption=MID$(instring$,20,4) From1. MSComm 1. Port Open=Faise End Sub Function fcs(O$) Dim B??I?????FF$ B?=0 ??=Len(O$) For I?= I TO ?? B?=B?×or Asc(Mid(O$?I??1)) Next I? FF$?He×$(B?) 1f Len(FF$)=1 Then FF$="0"+FF$ End If Fcs=FF$+"*" End Function enjoy this

Share this post


Link to post
Share on other sites
Hi Calvin, i am using VB 6.0 using FX232-BD Port. Hi Chris, i still have to search for that component if it is available on the web, i hope it would also help. hi hero, i will try your code and will inform you later rgds to all

Share this post


Link to post
Share on other sites
MX-Cmoponent is commercial product. You won't find it on the web....

Share this post


Link to post
Share on other sites
hi joven Like panic said, MX component is commercial so you need to buy it, same for OPC server. Back to the basic solution, develop a Visual Basic Aplication! I thing that the VB aplication is simple, but the PLC program can be a litle harder. To use serial communication on Visual Basic you need the MScomm object: Menu, Project->Components->Microsft Comm Control 6.0 I leave an very basic example, for tests use the windows hyperterminal that is even easier. For the PLC program, see the RS function (FNC 80) on the manual.

Share this post


Link to post
Share on other sites
Hi Calvin, Thanks for your very important sample. PLC programming is easy for me since I am using it for so long time already. below is my sample PLC program Ladder program: X0 Y0 -----| |-------------------------( ) ------------------------------( END ) X0 - input device (e.g switch) Y0 - output device (e.g lamp ) My VB form will be: Commandbutton for input and Checkbox for output. If I will press the Commandbutton, the lamp (Y0) will activate and Checkbox will be active. Can you give me a sample VB program for the conditions above... Please help...

Share this post


Link to post
Share on other sites
i am not sure this will work since input table will be updated before each scan. i would recommend writing to internal memory such as M or D instead of X.

Share this post


Link to post
Share on other sites
Unfortunately i don't have an FX232-BD. The only 232 module available is a A1SJ71UC24-R2 with a A1S CPU. In this example the left checkbox controls Y10, the right checkbox monitorize X0. The plc code is only for serial communication, there isn't any relation between X0 and Y10. For the FX series is available a RS function for a easier control of serial communications. Hope this help Serial_sample.zip

Share this post


Link to post
Share on other sites
Hi all, anyone that have problem with visual basic link to plc mitsubishi may contact me, thanks

Share this post


Link to post
Share on other sites
All you have to do is get a ICP-DAS WinCon 8000 with WinCe.Net thats it! no extra code for com ports it is all in one (PAC)

Share this post


Link to post
Share on other sites
Hi Calvin, I can manage to assign the inout into M or D. Can you give the sample code?

Share this post


Link to post
Share on other sites
Hi Calvin and Mr panic mode, Can you help me on this base on the conditions above?

Share this post


Link to post
Share on other sites
I’m not sure of what you really want! You want to control the lamp (Y0) with a switch (X0) or with a Command button in Visual Basic. On the PLC side, the serial communication is based in integers (D’s), but you can convert to boolean, see my example. I forgot to say but the code is made on GX IEC Developer 5.0.

Share this post


Link to post
Share on other sites
Hi Calvin, I want to control the lamp either by the X0 and CommandButton. X0 is used in remote area, and the CommandButton is used in the Machine PC. I either of the X0 or CommandButton is active, the lamp will turn-ON.

Share this post


Link to post
Share on other sites
Well the hard work will be how to send/receive data and not what to do with it But there it is an small example. PC Program: Send command button state to serial port (ON/OFF), with end message code (0A0D) Receive a message with a boolean variable and attribute its value to a checkbox (Lamp) On PLC program: send Y0 to PC, for monitorization receive command button order (ON/OFF) and attribute to M0 Y0=M0 or X0 P. S. In my opinion, checkbox are better than command buttons for this situation, you want that the same button set and reset M0, so you must change the caption to display the correct action.

Share this post


Link to post
Share on other sites
Hi Calvin, Thanks a lot but still doesnt work. I have attached a new conditions and i hope this would help now. I will also attached some pdf file which has the mitsubishi protocol format. I couldnt interpret it well and i hope you can help me on how to deal by providing me a simple example and i think i can do the rest. In my conditions: * When the Command1 button is clicked, the M0 of the PLC will be active and energizing the Y0 output of the PLC. * When the Command2 button is clicked, the M1 of the PLC will be active and de-energizing the Y0 output of the PLC. * The listbox will display "Y0 is ON" if Y0 is ative and "Y0 is OFF" if Y0 is inactive. The signal to listbox should be from the PLC. If the VB program could not receive any response from the PLC, MessageBox will display "Communication Error". Everyone in the net are also invited to help...

Share this post


Link to post
Share on other sites
This is the extracted FX2N Communication manual which i have found from this net. I need your help to interpret this for me by giving a simple VB program base on my conditions above... FX2n_Communication.pdf

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