Author Topic: Using a DLL  (Read 3984 times)

thebestg2002

  • Newbie
  • *
  • Posts: 26
    • View Profile
Using a DLL
« on: October 23, 2017, 10:29:49 AM »
Morning everyone
I have a project I'm working on that uses a Keyence TM inspection system. By default, the Keyence TM does not use the ethernet port for its communication to output it's measurement data. It is typically done serially. Unfortunately, I missed that when I purchased my Real Time Automation Ethernet TCP/IP to Ethernet I/P gateway. I spoke with my Keyence representative and he sent me a DLL (attached) that I think I should be able to implement into my solution. The problem is I have no idea how to do this.

A friend at work knows a little about .Net and he said I needed to add it as a reference. When I try to add it as a reference, I get the following error: "A reference to the "....dll" could not be added.Please make sure that the file is accessible and that it is a valid assembly or COM component." I have added them to a test project using "add existing item" for the .dll, .h and .lib files but I don't know how to access the measurement values in the project.

There is also an entire solution/project that I can add to my solution, but again I'm not sure how to do this and the files are too large to attach. I can post them on Dropbox or something if you'd like.

I'm hopeful one of you can lend a hand and get me pointed in the right direction. I'm using VSExpress 2012,  but I'm not opposed to updating to a newer version if necessary. This is going to be my first work related project using AHMI and I want it to be a success.

If there is anything else you need, please let me know.

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: Using a DLL
« Reply #1 on: October 23, 2017, 12:03:34 PM »
If your Keyence vision system is using serial port, first make use which protocol uses. It can be simple ascii text where you would not need any DLL, just configurate you serial port on the PC application and receive the data. If it uses another protocol, like Rockwell uses DF1 over serial, then you need that DLL or another that is able to communicate using it.

Advanced HMI is not needed here unless you use one of its drivers, which are the protocols to communicate over different serial port types (RS232, RS485, Modbus) or Ethernet (Ethernet/IP, Modbus TCP).

So first thing, if you want some help, tell us what protocol is using the Keyence system.

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: Using a DLL
« Reply #2 on: October 23, 2017, 12:12:01 PM »
Looking at the readme file you have some sample code and help file, there you should see for instructions on how to use it. You could help us by telling us which Keyence system you have, and if it has Ethernet port besides serial (most do).

Your intention on using the RTA Ethernet TCP to Ethernet/IP? Is this the system (460ESTCP-N34-D) you bought?

https://www.rtaautomation.com/product/460estcp/

About the issue not being able to add the reference, I really could not help in that part.

thebestg2002

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Using a DLL
« Reply #3 on: October 23, 2017, 01:21:47 PM »
If your Keyence vision system is using serial port, first make use which protocol uses. It can be simple ascii text where you would not need any DLL, just configurate you serial port on the PC application and receive the data. If it uses another protocol, like Rockwell uses DF1 over serial, then you need that DLL or another that is able to communicate using it.

Advanced HMI is not needed here unless you use one of its drivers, which are the protocols to communicate over different serial port types (RS232, RS485, Modbus) or Ethernet (Ethernet/IP, Modbus TCP).

So first thing, if you want some help, tell us what protocol is using the Keyence system.

The Keyence TM controller part number is TM-3001P. It has both ethernet and rs232 communication ports. By default, Keyence expects you to use rs232 for connecting to a PLC. I did not realize this and so I planned on using the ethernet tcp/ip port along with the RTA 490NBX-NNA1-D to get the measurement data from the TM to my Compactlogix PLC (1769-L18ER-BB1B).

I have other ways of getting the data serially, but I would like to learn more about .Net so I would like to try to use the prebuilt DLL from Keyence if possible. If you are not able to help with that, Sprungmonkey, then I thank you for your time.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Using a DLL
« Reply #4 on: October 23, 2017, 07:58:12 PM »
Here is an easier option:

call the RTA guy and tell them you need a firmware that will flash your existing Enet Gateway to ASCII to EnetIP
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Using a DLL
« Reply #5 on: October 23, 2017, 08:24:28 PM »
Since the DLL does not add as a reference into a .NET application, I am guessing it will require using PInvoke, which is not very straight forward. This article will give some idea:

https://www.codeproject.com/articles/14180/using-unmanaged-c-libraries-dlls-in-net-applicatio

I did notice in the ReadMe file that it mentions there are some sample files on using the DLL in VB.NET

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: Using a DLL
« Reply #6 on: October 24, 2017, 09:41:34 AM »
According to the user manual, the serial port sends and receives ASCII commands and data. Try getting online with it setting up the port configuration on the vision system, and use the hyperterminal in your PC. You should be able to see data as a result of inspections (you also have to setup that in Keyence's system) and will be able to send text commands through it. Maybe the DLL is just an "interface" for those text commands, but I do not see why you could not use it directly (sending ASCII commands directly from VB.net) without having to use the DLL.
« Last Edit: October 24, 2017, 09:44:37 AM by Sprungmonkey »

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: Using a DLL
« Reply #7 on: October 24, 2017, 09:42:43 AM »
Ethernet port seems to be for programming only, not for communication, looks like only TM-Navigator can be used with it.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Using a DLL
« Reply #8 on: October 24, 2017, 04:22:38 PM »
Using PC is the last resort.  Think about the additional cost of adding a PC & added  program complexity. Since you already have Keyence & RTA & PLC.  Just call the RTA guy, flash the firmware and you are done.
« Last Edit: October 24, 2017, 04:24:44 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

thebestg2002

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Using a DLL
« Reply #9 on: October 27, 2017, 09:42:13 AM »
I'm trying to learn .Net on the fly so I appreciate everyone's responses.

Archie
There is a .Net sample program that I can pick apart to get the information I need without needing the DLL in its entirety. It will be a more productive conversation if I hold off until I actually receive the unit and start messing around with it myself.

Thanks again.