Host Engineering Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 22, 2012, 04:40:16 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: PC-PLC Communication  (Read 3288 times)
cncwapner
Jr. Member
**
Posts: 10


« on: March 04, 2007, 07: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
Logged
BobO
Host Moderator
*****
Posts: 1149


Yes Pinky, we *are* going to control the world!


« Reply #1 on: March 04, 2007, 08: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, 08:36:48 pm by BobO » Logged

BobO

The Constitution does not guarantee us freedom from being offended...but we can choose not to be, and life gets so much easier.
cncwapner
Jr. Member
**
Posts: 10


« Reply #2 on: March 04, 2007, 09: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
Logged
BobO
Host Moderator
*****
Posts: 1149


Yes Pinky, we *are* going to control the world!


« Reply #3 on: March 04, 2007, 09: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 05, 2007, 12:57:03 am by BobO » Logged

BobO

The Constitution does not guarantee us freedom from being offended...but we can choose not to be, and life gets so much easier.
Greg
HOS†ech
Host Moderator
*****
Posts: 320


Hmmm...


WWW
« Reply #4 on: March 05, 2007, 09: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.

Logged

"You have to believe in free will. You have no choice." -Isaac Bashevis-Singer
caestrada
Newbie
*
Posts: 7


« 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,
Logged
Greg
HOS†ech
Host Moderator
*****
Posts: 320


Hmmm...


WWW
« 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? Smiley
Logged

"You have to believe in free will. You have no choice." -Isaac Bashevis-Singer
cncwapner
Jr. Member
**
Posts: 10


« 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?
Logged
Greg
HOS†ech
Host Moderator
*****
Posts: 320


Hmmm...


WWW
« 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.
Logged

"You have to believe in free will. You have no choice." -Isaac Bashevis-Singer
MikeS
Host Moderator
*****
Posts: 176



WWW
« 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.
Logged

Good design costs a lot. Bad design costs even more.
keith
Jr. Member
**
Posts: 18


« 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 » Logged
NitraMa
Newbie
*
Posts: 4


« 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 » Logged
Greg
HOS†ech
Host Moderator
*****
Posts: 320


Hmmm...


WWW
« 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.
Logged

"You have to believe in free will. You have no choice." -Isaac Bashevis-Singer
NitraMa
Newbie
*
Posts: 4


« 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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM