Sign in to follow this  
Followers 0
massimo

omron VB6

5 posts in this topic

Hi, I ask someone that uses OMRON with Visual Basic, I don't succeed in planning the formulations of objects net OCX, for which succeed only to communicate installments to 9600 bounds. I beg you to see the photo that I have attached. Thanks in advance. Immagine.zip

Share this post


Link to post
Share on other sites
Hello, Find the attached module for Hostlink communication. mdlPLC.zip

Share this post


Link to post
Share on other sites
Thank you for having answered me, for the communication with OMRON I use CX-Server Lite and it doesn't serve me program in Basic to communicate in HostLink, what I don't succeed in doing and to change the formulations of communication in the object OCX in the photo that I have attached, it makes me plan the type of CPU "CJ1M", the type of communication "ToolBus" but not the formulations of speed. For which communicates only to 9600, but I would like to communicate to 115200 with this object OCX made by OMRON available.

Share this post


Link to post
Share on other sites
Why 115200 baud..... whats the distance to the PLC from the Computer... I am sure that 19200 would be more then adequate....

Share this post


Link to post
Share on other sites
Hello Massimo, I was in a hurry and could not wind any chance to explain about the module. I am not in trust with CX-Server Lite, it sometimes hang the communication to PLC and do not give any feedback about the lost connection. And it is not light at all, runs much on system resources. So I have decided to develop the attached module. I have made only data memory read, write ,change and read PLC status functions. Place an MSComm object and change name to cmmPLC on a form named frmMain. "OpenPLC" function opens the communication port, however you need to do communication port settings in this function. I have loaded the settings from an ini file to global variables. Here is the code: Public Function OpenPLC() As Boolean On Error GoTo errHandler frmMain.cmmPLC.CommPort = CommPort frmMain.cmmPLC.Settings = Settings frmMain.cmmPLC.Handshaking = Handshake frmMain.cmmPLC.PortOpen = True OpenPLC = frmMain.cmmPLC.PortOpen Exit Function errHandler: PrintLog 0, "OpenPLC> " & Err.Description OpenPLC = False Exit Function End Function You need to change CommPort, Settings and Handshake values. (Also please see the timeout global variable at the beginning of module; Public TimeOut As Integer, I have also loaded this setting from ini file, however you can define it as constant.) If OpenPLC returns true, you can use other commands. You can read the DM by ReadDM function. Eg. Dim Data As String Data = ReadDM("2000", 5) If Len(Data) > 4 Then ' At least 1 word read successfully. If returned data length is smaller than 4, it is the error code MsgBox "Data read successfully:" & Data Else MsgBox "Error:" & Data End If Above sample shows how to read 5 words from DM2000. Below sample shows how to write "1234" to DM2000 and "ABCD" to DM2001 Dim Status As String Status = WriteDM("2000","1234ABCD") If Status = "00" THen MsgBox "Write operation successfull" Else MsgBox "Error on writing. Error:" & Status End If However, with this code you can read / write max. 28 words. For continuos data areas, you need to call the functions with the new parameters. And I agree sleepy, 19200 is enough and safe. If the distance is long and you are working in electromagnetical noisy environment, 115200 may cause problems. And another note, I have never tried my codes with CJ series, this codes are working with C200HE for 5 months without error. Best Regards,

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