News:

  • April 15, 2024, 11:29:18 PM

Login with username, password and session length

Author Topic: PC-PLC Communication  (Read 11075 times)

cncwapner

  • Jr. Member
  • **
  • Posts: 10
PC-PLC Communication
« on: March 04, 2007, 06:00:31 PM »
I'm using the ECOM Module in a DL-05 PLC and need to monitor the inputs through a program
I have written. I've been tring to use the EtherIO Example but it produces the Error 8006 when
I attempt to read the I/O once. Any ideas?

Eric

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5983
  • Yes Pinky, Do-more will control the world!
Re: PC-PLC Communication
« Reply #1 on: March 04, 2007, 07:23:02 PM »
The 8006 is a timeout, which could be caused by many things, but probably is due to the fact that the EtherIO example is for reading the I/O from an EBC, not an ECOM. The EBC responds to HEIReadIO and HEIWriteIO calls, but the ECOM does not.

To read a PLC's I/O from an ECOM, you need to use HEICCMRequest or HEIKSEQRequest to read the image register location corresponding to the locations you want to read. For HEICCMRequest the inputs are data type 0x32, and begin at 0x101.

Hope this helps!
« Last Edit: March 04, 2007, 07:36:48 PM by BobO »
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

cncwapner

  • Jr. Member
  • **
  • Posts: 10
Re: PC-PLC Communication
« Reply #2 on: March 04, 2007, 08:34:42 PM »
Awsome, that bigtime helps.
Does it matter what the DIP is set to on the unit if I'm using the MACS to define which unit data came from?
Which leads me to question 2.
I need to have the PLC output status when a input changes. So is there a callback function in the SDK?
I really don't want to keep polling the PLC, I'd rather the PLC handles everything and the app is just listening.

Eric

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5983
  • Yes Pinky, Do-more will control the world!
Re: PC-PLC Communication
« Reply #3 on: March 04, 2007, 08:41:36 PM »
Nope. Dip sets the node id which only matters if you do a node id data query to resolve the address. Primary purpose is to provide a MAC independent way of finding a node. If you don't mind using the MAC, it's not needed.

As for polling vs. interrupting....well, the easy way is to poll. However, we do have a method for initiating a message from within the PLC. I don't have all the details with me right now, so it'll have to wait until tomorrow, but we can hook you up with the details for "report by exception".

BTW, if you need more info on the CCM requests, download the DirectNET Protocol Manual from AutomationDirect. The part number is "DA-DNET-M" and is available free from ADC via download.
« Last Edit: March 04, 2007, 11:57:03 PM by BobO »
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 676
  • Hmmm...
    • Host Engineering, Inc.
Re: PC-PLC Communication
« Reply #4 on: March 05, 2007, 08:34:55 AM »
...but we can hook you up with the details for "report by exception"...

Goto www.hosteng.com --> Products --> ECOM / ECOM100 --> 4th bullet down. There you can read about (and download) the Report-by-Exception information.

There are two types of people in the world; those that can extrapolate from incomplete data sets.

caestrada

  • Newbie
  • *
  • Posts: 7
Re: PC-PLC Communication
« Reply #5 on: April 02, 2007, 03:03:18 PM »
Greg,

I tried to use that Report-By-Exception feature, which would be great but does not work.

Why don't you guys write an example how to use it in UDP or TCP...it would be
a fantastic help to have it ready to download into DL05 or DL06...

If I have to pay for that, just let me know...

Regards,

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 676
  • Hmmm...
    • Host Engineering, Inc.
Re: PC-PLC Communication
« Reply #6 on: April 02, 2007, 04:52:38 PM »
Hmmm... well there is an example in that link I pointed you to. The project (RBE.PRJ) included in the download is for a DL260, but you can change that to a DL06 by going to PLC --> Offline Setup... and changing the CPU to a DL06. Then you should be able to connect to a DL06 and download it.

Of course, you will have to modify the V-memory for your particular PC's MAC address and IP address. But the Word document explains that (Using RX_WX.DOC).

Then, after you download and make those address modifications, then on the PC you are sending data to, you run the viewer.EXE program which will then receive the telegrams the ECOM is initiating.

If you have specific trouble getting that to work, please feel free to e-mail me your project with some details and I'll see if I can't get you up and running. K? :)
There are two types of people in the world; those that can extrapolate from incomplete data sets.

cncwapner

  • Jr. Member
  • **
  • Posts: 10
Re: PC-PLC Communication
« Reply #7 on: April 04, 2007, 12:01:25 PM »
I'm tring to get this to work on a DL-05 with no sucess. I've followed the Doc and other instruction, set the Dip7 to on and changed the Mac/IP
values in the ladder. Is there anything else that needs to be set for use with a DL-05?

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 676
  • Hmmm...
    • Host Engineering, Inc.
Re: PC-PLC Communication
« Reply #8 on: April 04, 2007, 01:09:15 PM »
There are no other settings on the DL05 that have to be done. But obviously something is wrong or not working properly. Couple of things you could do that might help me figure out what is happening:
  • Zip up your project and e-mail it to me.
  • Download a copy of Ethereal (a free Ethernet sniffer) and install it on the PC your are trying to send data to; take a sample of the network while trying to get it to work; save the sample; e-mail it to me as well.

Ethereal can be downloaded at www.ethereal.com. I think it is actually called Wireshark now. So you might Goggle Wireshark instead. Either one will work.
There are two types of people in the world; those that can extrapolate from incomplete data sets.

MikeS

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 254
    • Host Engineering, Inc.
Re: PC-PLC Communication
« Reply #9 on: April 05, 2007, 12:07:16 PM »
Assuming the IP address information and the MAC address information is correct, the 'next-most-likely' thing to check is the SPxxx bit, and then the slot designation in the first LD instruction.

The Spxxx bits in the DL05 are SP120 = Comm Busy, SP121 = Comm Error; the expansion slot in the DL05 is number as slot 1, so you should have NOT( SP120) ----- LD K0190.
Good design costs a lot. Bad design costs even more.

keith

  • Full Member
  • ***
  • Posts: 21
Re: PC-PLC Communication
« Reply #10 on: April 19, 2007, 08:16:02 PM »
I communicate with 06's 250-1's and 260's using Host engineering's SDK.
I am using HEICCMRequest to read and write the plc's vmemory from the
PC.

Here is a code fragment:

#pragma warning(disable:4103)
#include "hei.h"

static HEIDevice device;
static HEITransport tp;
static int warn = 1;

void PlcioOpen ()
{
unsigned s;
unsigned short count;
long ip;

  memset(&tp, 0, sizeof(tp));
  memset(&device, 0, sizeof(device));
  s = HEIOpen(HEIAPIVERSION);
  if (s && warn) lprintf ("Open %d\n", s);
  tp.Transport = HEIT_WINSOCK;         
  tp.Protocol = HEIP_IP;
  s = HEIOpenTransport(&tp, HEIAPIVERSION, 0);
  if (s && warn) lprintf ("Open Transport %d\n", s);
  count = 1;
  s = HEIQueryDevices(&tp, &device, &count, HEIAPIVERSION);
  if (s && warn) lprintf ("Query Device %d, %d found\n", s, count);

/* The open routine in this example is rather weak.  It is hard-coded to */
/* hex 0x0114a8c0 which is 192.168.20.1.  There are better ways to do this. */
  device.Address.AddressIP.AddressingType.lAddr = 0x0114a8c0;

   s = HEIOpenDevice(&tp, &device, HEIAPIVERSION, 25, 3, FALSE);
  if (s && warn) lprintf ("Open device %d\n", s);
  device.Retrys = 0;
  device.Timeout = 100;
}

int PlcioRead (long vloc)
{
unsigned s;
unsigned short vdata;
 
    s = HEICCMRequest (&device, FALSE, 0x31, vloc + 1, 2, (BYTE *) &vdata);
    if (s && warn) lprintf ("PlcRead failed, status %x\n", s);
    return s ? -1 : vdata;
}

int PlcioWrite (long vloc, int vdata)
{
unsigned s;
unsigned short bvdata;

    bvdata = vdata;
    s = HEICCMRequest (&device, TRUE, 0x31, vloc + 1, 2, (BYTE *) &bvdata);
    if (s && warn) lprintf ("PlcWrite failed, status %x\n", s);
    return !s;
}

In practice, it is better (performance) to exchange small blocks of v memory
each direction, rather than to read individual locations.

This is done by changing the 2 to 2 * n (where n is the number of words to
transfer), and making the last argument to HEICCMRequest an array.

But this should at least get you started.
« Last Edit: April 19, 2007, 08:33:35 PM by keith »

NitraMa

  • Newbie
  • *
  • Posts: 4
Re: PC-PLC Communication
« Reply #11 on: June 05, 2007, 12:50:54 PM »
I try your code and I can write something somewhere, but I don't know where...  I try to increment the value at "V4010" but in the PLC I see nothing.  Here is my code using your exemple :

void main(int argc, char *argv[])
{
int rep;
PlcioOpen();
rep = PlcioRead(0xFAA);
rep = PlcioWrite(0xFAA,rep+1);
rep = PlcioRead(0xFAA);
}

My code increment perfectly the value (rep=20 at the first reading and 21 at the second reading), but I don't know which register it's increment (the one I want is V4010... so 0xFAA if I don't mistake).  I try to unplug my PLC to see if I write in the good one (I only have one PLC !?!?!) and when is unplug, my program can't read and write correctly (error value in "rep"). So I write in the good PLC.

Someone can help me with this problem...

Thank
« Last Edit: June 05, 2007, 12:53:21 PM by NitraMa »

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 676
  • Hmmm...
    • Host Engineering, Inc.
Re: PC-PLC Communication
« Reply #12 on: June 05, 2007, 12:59:44 PM »
Hi NitraMa,

V4010 is in octal, so the value in hex is actually 0x808 instead of 0xFFA. 0xFFA would be V7772. That would be the first place to look, I believe. I could be wrong, but that just might be it. One of the other programmers on the forum should be able to tell you for sure.
There are two types of people in the world; those that can extrapolate from incomplete data sets.

NitraMa

  • Newbie
  • *
  • Posts: 4
Re: PC-PLC Communication
« Reply #13 on: June 05, 2007, 01:03:02 PM »
AAARRRRGGGGG!!!!
the address is in octal so 0xFAA mean V7652
and V4010 is 0x808

and now...  IT'S WORKING!!!!!!!!!!!!

Thank Greg, but I found It at the same time you write your post