Sign in to follow this  
Followers 0
cpzao

FINS and Visual C++

16 posts in this topic

hi there!, i'm quite new into the PLC world and recently I was given the task of communicating a PC and a PLC via ethernet. After reading here and there, I bumped into FINS protocol, which I dare to say it suits my purposes. I tried the VB programs in the download area and i managed to connect to a PLC and enable outputs and read inputs successfully but I would like to work with C++. Is there any code or software available developed in C++ which allow to communicate a PC with a PLC via UDP/ethernet? Thanks in advance Carlos Edited by cpzao

Share this post


Link to post
Share on other sites
Hi, I have developed an ActiveX controller for Fins over Ethernet. It is still downloadable from : http://code.google.com/p/indafins/downloads/list with a draft documentation and sample application code. I have never tried it with C++, however it should work without any problem with any programming environment supporting ActiveX. It also works with power point and excel. I am planning to publish an updated version for next weeks, you can get information from: http://indanotes.blogspot.com/2008/11/inda...n-fins-ocx.html

Share this post


Link to post
Share on other sites
hello moosty, thanks for your help! Either way, I was advised to build my own code for this so... here I go :) Once again, thanks! Carlos

Share this post


Link to post
Share on other sites
I have a question: I'm doing the communication between PLC's OmRon and PC. But, with form data send which PC send to PLC has "*" "CR". I don't know what it's, because I see it converter to HEX is "2A0D" but I want it's ACSII code. So, what do I have to? and how do I do? Thanks a lot !

Share this post


Link to post
Share on other sites
Hiya, Isn't 2A hex the code for the * character anyway (i.e. ASCII 42) and 0D hex the "Carriage Return" or CR character (i.e. ASCII 13) checkout Ascii table Regards, Bertie

Share this post


Link to post
Share on other sites
Thanks you very much. who did write communication PLC and PC by Visual Basic? Can you help me, please? can you send or upload a simple example?

Share this post


Link to post
Share on other sites
I think you are using Host Link communications. I am attaching a sample software for host link, you can use ReadDM function for reading and WriteDM for writing into data memories. I always use mdlPLC for RS232 communication in my projects and works witohut any problem. However, I have built this sotware this morning for you and did not tried on a real PC. Comm port and communicatino settings were done in Form.Load event, you may need to change them according to your PC and PLC. By default, I have set them to com 1, 9600, e,7,2, no handshake. If you want to see how packages are prepared before being sent to PLC, you can digg functions ReadDM and WriteDM, find the lines objComm.Output = Command you can place a new textbox on form and add something like: frmMain.Text1.Text = Command before lines objComm.Output = Command Hope this helps Sample_Read.zip

Share this post


Link to post
Share on other sites
Thanks a a lot "moosty" . this is program which you wrote in above. you used what connecte PLC with PC? Is the cable or ethernet? can you speak clearly for me, please? PS:/ ReadDM command I think in INDAFINS, am not I? Edited by nguyenthucuc

Share this post


Link to post
Share on other sites
You are welcome. I had developed the module 'mdlPLC' in the attached application for Host Link protocol and it is used for RS232 communication. It has been working on several applications since 2004 without any problem. Host Link is easy to implement, but allows only 4 digits (up to DM9999) of address range, and a data package can contain at most 28 data words. FINS protocol over Ethernet is much more suitable if you deal with high amount of data and it supports data memories over DM9999. FINS protocol is also available on RS232 with just an addition of checksum as in Host Link. For that reason, I believe that Host Link is obsolete and decided to develop INDAFINS for FINS protocol. I have implemented the alpha version for Ethernet only, but I want to add support for RS232 soon. ReadDM function does same operations for both applications, but uses different communication protocols because I wanted INDAFINS to be backward compatible with my existing applications. One of the reasons that I keep ReadDM function as -nearly same- because it returns the data from PLC, making it possible to work on while debugging your application. I hope I can complete the RS232 support for INDAFINS soon.

Share this post


Link to post
Share on other sites
thank you very much. I'm going to try it. I want a question, in your example: DATA include ICF, RSV,GCT,DNA,DA1,DA2,...doesn't it? Thus len(data) will greater 28. with your helping, I will develop to complete my project. You are a charitable.

Share this post


Link to post
Share on other sites
Host Link protocol does not include ICF, RSV.. flags. So my example does not contain any of those flags. However, if you want to study on FINS protocol, I am attaching mdlFINS, which is the hearth of INDAFINS. Check the 'PackFinsRead_' function, it prepares the FINS package with ICF, RSV,GCT,DNA,DA1,DA2,... If you are going to use Ethernet communications, the package prepared by PackFinsRead_ function would be enough for you, but if you are going to communicate over RS232, you have to add checksum and '*' character at the end of prepared package, it should be same as in Host link sample I think. Hope this helps for your project. mdlFINS.zip Edited by moosty

Share this post


Link to post
Share on other sites
I also trouble you. But, I test your program which you uploaded by short circuit 2 and 3 dip(RS232). It's usually to appear "ErH" that mean the first character differ "@" PS:/ function getportData, I can change by code below, can't I? code: n = Len(command) For i = 1 To n MSComm1.Output = Mid(command, i, 1) Next I thank you very much to "moosty" because of your enthusiasm helping. Edited by nguyenthucuc

Share this post


Link to post
Share on other sites
Sure you can, but it does not make any sense actually, PC CPU is so fast that For..Next loop should be executed so quickly and PC collects the output string in com ports output buffer.

Share this post


Link to post
Share on other sites
The first next week, I'm going to test with PLC. I hope I'll success with it. I will contact with you again. can you chat with me by nickname? I think I can have better your helping and no waste time than this rely. thank you very much, "moosty"?

Share this post


Link to post
Share on other sites
Sure, I can help you If I am online. I put two Skype buttons on my blog, one adds me as a Skype contact and the other one shows my online status and starts a chat session if I am online. My Skype account name is indanotes.blogspot.com

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