# Problem with DeviceNet communication

**URL:** <https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823>\
**Category:** RobotStudio\
**Created:** [October 1, 2015, 5:43am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823 "2015-10-01T05:43:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawelbajerski](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pawelbajerski](https://tech-community.robotics.abb.com/u/pawelbajerski)\
**Post date:** [October 1, 2015, 5:43am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/1 "2015-10-01T05:43:34Z")

</div>

Hello Colleagues,

I am working on connecting externa device (electrical griiper festo) with robot controller IRC5 by using deviceNet. I have some problems, because after base configuration, external controller SFC-DC shows me that devicenet is in operational mode. But, if I want to communicate by RAPID code, prgram has problems with instruction “open”. Please find files like EDS file and backup my station in attachment.  
I would be grateful for your help.

Best regards  
Pawel  
[EDS file for SFC\_DC.zip](https://tech-community.robotics.abb.com/uploads/short-url/7wUUnU0Rm2tKxkd76nZIwQlFSEg.zip) (21.4 KB)  
[New\_System\_2011\_BACKUP\_2015-09-29.zip](https://tech-community.robotics.abb.com/uploads/short-url/hqOgIPh8x4a3I0PIyZW0JfgMW1G.zip) (358 KB)

---

<div class="post-metadata">

**Author:** ![kioog](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kioog](https://tech-community.robotics.abb.com/u/kioog)\
**Post date:** [October 1, 2015, 7:19am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/2 "2015-10-01T07:19:37Z")

</div>

Hello,  
If i look at your code  
you do the command : Open “/FCI1:/board328”, io\_device \Bin;  
but you don’t have declared what is board328 i think, you have declared in your IO.SYS a board “IED\_device\_unit”

# 

EIO\_UNIT:

-Name “IED\_device\_unit” -UnitType “Device\_IED\_Type” -Bus “DeviceNet1”  
-UnitLabel “9” -TrustLevel 2 -RegainCommunicationReset -DN\_Address 3

so maybe you should try to do Open “/FCI1:/IED\_device\_unit”, io\_device \Bin;  
It’s is only a quick thought, because i have never worked this way with devicenet

---

<div class="post-metadata">

**Author:** ![pawelbajerski](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pawelbajerski](https://tech-community.robotics.abb.com/u/pawelbajerski)\
**Post date:** [October 5, 2015, 7:43am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/3 "2015-10-05T07:43:52Z")

</div>

Hello,  
I tried to modify program, but still I have some problems. If I try to send a message in order to get status Device controle (param10 in EDS file), I obtain nothing.  
Example code:

```auto
MODULE Module1
    CONST robtarget home:=[[511.36,-7.11,714.35],[0.709925,0.0106723,0.704196,0.000937047],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    CONST robtarget target1:=[[511,-7.11,400],[0.709925,0.0106723,0.704196,0.000937047],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
 
    CONST robtarget board1home := [[223.04,-154.57,-159.66],[0.613404,-0.560875,-0.422732,-0.36118],[-1,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    CONST robtarget Target_10:=[[476.377532198,75.790964764,329.998886795],[0.006634996,0.000000077,0.999977988,-0.000000033],[0,-1,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
    CONST robtarget Target_20:=[[476.377564349,-79.852510653,329.999196286],[0.006635425,-0.000000054,0.999977985,-0.000000177],[-1,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
    CONST robtarget Target_30:=[[476.377648812,-1.144353486,329.999431058],[0.006635615,-0.000000149,0.999977984,-0.000000072],[-1,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
    VAR num dlugosc;
    VAR iodev io_device;
    VAR rawbytes raw_data_out;
    VAR rawbytes raw_data_in;
    VAR num input := 46;
    VAR string return_status;
    VAR string return_status_in;
    VAR string wynik := "0";
    VAR byte bit := 122;
    CONST robtarget Target_50:=[[476.377617427,-1.144352136,470.80365528],[0.006635644,-0.000000406,0.999977984,-0.000000065],[-1,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
    PROC main()
        MoveJ home,v1000,z100,tool0\WObj:=wobj0;
        devicenet;
        MoveJ target1,v1000,z100,tool0\WObj:=wobj0;
        MoveJ home,v1000,z100,tool0\WObj:=wobj0;
        Stop;
    ENDPROC
    
    PROC devicenet()
        wynik := ByteToStr(bit);
        Close io_device;
        ClearRawBytes raw_data_out;
        PackDNHeader "0E", "6,20 64 24 01 30 0E, **207D,00**", raw_data_out;
        !    I think here is the main problem - how to correct define PackDNHeader based on EDS file?
        PackRawBytes input,raw_data_out,(RawBytesLen(raw_data_out)+1) \INTX := UDINT;
        dlugosc :=RawBytesLen(raw_data_out)+1;
        Open "/FCI1:/IED_device_unit", io_device \Bin;
        !trzeba znalezc ID w plik EDS urzadzenia IO, aby otworzyc z nim polaczenie
        WriteRawBytes io_device,raw_data_out;
        ReadRawBytes io_device,raw_data_in\Time:=1;
        Close io_device;
        UnpackRawBytes raw_data_out,9,return_status \ASCII:=46;
        UnpackRawBytes raw_data_in,9,return_status_in \ASCII:=46;
    ENDPROC
    
ENDMODULE

```

If you have some suggestions, please let me know.

---

<div class="post-metadata">

**Author:** ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)\
**Post date:** [October 5, 2015, 7:32pm UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/4 "2015-10-05T19:32:16Z")

</div>

What if you use this

PackDNHeader “16”,“20 64 24 01 30 03,1,C6,1”,raw\_data\_out;

---

<div class="post-metadata">

**Author:** ![pawelbajerski](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pawelbajerski](https://tech-community.robotics.abb.com/u/pawelbajerski)\
**Post date:** [October 6, 2015, 9:32am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/5 "2015-10-06T09:32:50Z")

</div>

Unfortunately it doesn’t work. If I use: PackDNHeader “16”,“6,20 64 24 01 30 03,1,C6,1”,raw\_data\_out; prgram works but I have no response from slave controller.  
Should I create fieldbus commands and field bus command types?

Do you have other suggestions how to solve the problem?

---

<div class="post-metadata">

**Author:** ![pawelbajerski](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pawelbajerski](https://tech-community.robotics.abb.com/u/pawelbajerski)\
**Post date:** [October 7, 2015, 6:49am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/6 "2015-10-07T06:49:47Z")

</div>

I wonder if I properly set up PackDNHeader. I should send to slave controller 8 bytes acc. to SFC-DC Festo documentation. How to correct define message?

---

<div class="post-metadata">

**Author:** ![msalminen](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@msalminen](https://tech-community.robotics.abb.com/u/msalminen)\
**Post date:** [October 7, 2015, 9:30am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/7 "2015-10-07T09:30:08Z")

</div>

Hi,

I collect here some lines from my working program. Notice this is just sample and not complitetly working PROC, but this is more or less what works for me. You need to find your path from EDS file and add data into rawbyte if needed to send some data.

* * *

! Constants  
CONST string DNET\_GET\_ATTR\_SINGLE := “0E”;  
! paths get from EDS file  
CONST string DNET\_PATH := “6,20 64 24 02 30 01,C4,4”;  
CONST num DNET\_READ\_WAIT\_TIME := 1;

! Variables  
VAR iodev devDNet;  
VAR string strDNetService;  
VAR rawbytes rbWrite;  
VAR rawbytes rbRead;  
VAR string strPath;  
VAR string strData;  
VAR string strDeviceName;

PROC foo()

strDNetService := DNET\_GET\_ATTR\_SINGLE;  
strPath := DNET\_PATH;  
strDeviceName := “YOUR\_DEVICE\_NAME”;

! clears all rawbytes variables/data.  
ClearRawBytes rbWrite;  
ClearRawBytes rbRead;

! If needed add Data to message  
! e.g add string data to rawbyte variable  
strData := “ASCII string here”;  
PackRawBytes strData, rbWrite, (RawBytesLen(rbWrite)+1) \ASCII;

! Set DeviceNet header  
PackDNHeader strDNetService, strPath, rbWrite;

! Open FCI device  
Open “/FCI1:” \File:=strDeviceName, devDNet \Bin;

! Write the contents of rawbyte to devDNet  
WriteRawBytes devDNet, rbWrite \NoOfBytes := RawBytesLen(rbWrite);

! Read the answer from devDNet  
ReadRawBytes devDNet, rbRead \Time := DNET\_READ\_WAIT\_TIME;

! Close device  
Close devDNet;

ENDPROC

* * *

Regards,

Mika

---

<div class="post-metadata">

**Author:** ![pawelbajerski](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pawelbajerski](https://tech-community.robotics.abb.com/u/pawelbajerski)\
**Post date:** [October 8, 2015, 6:35am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/8 "2015-10-08T06:35:50Z")

</div>

Thank You Mika.  
I have now communication between controllers IRC5 and Festo SFC-DC. I can get values from festo controller.  
But I have one more question: What type of procedure should we use in order to send command as SET type? Path should be improved? I think more parameters we need to send.

CONST string DNET\_SET\_ATTR\_SINGLE := “10”;  
! paths set LCD contrast from EDS file  
CONST string DNET\_PATH := “6,20 64 24 01 30 10,C6,1”;

I can for example set up LCD contrast by set values between 0-63. How to do it?

Thank you very much for help.

---

<div class="post-metadata">

**Author:** ![msalminen](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@msalminen](https://tech-community.robotics.abb.com/u/msalminen)\
**Post date:** [October 8, 2015, 6:50am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/9 "2015-10-08T06:50:03Z")

</div>

Hi,

For SET use same procedure as GET with comments following…

- Path is same. Path is just as pointer to the register in your device and you should see from your device doc if register support GET, SET or both.

- When making the header use SET service “10” instead of GET “0E”

- Add your data with PackRawBytes into the message, see my sample how to add ASCII data. Remember different data types need different parameters.

Mika

---

<div class="post-metadata">

**Author:** ![pawelbajerski](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pawelbajerski](https://tech-community.robotics.abb.com/u/pawelbajerski)\
**Post date:** [October 8, 2015, 8:39am UTC](https://tech-community.robotics.abb.com/t/problem-with-devicenet-communication/6823/10 "2015-10-08T08:39:52Z")

</div>

Thanks a lot for help.  
Program works very good after changing lines in code:

! Set DeviceNet header  
PackDNHeader strDNetService, strPath, rbWrite;  
PackRawBytes strData, rbWrite, (RawBytesLen(rbWrite)+1) \ASCII;

This topic we can close.
