DeviceNet with a Raspberry Pi

Hello,
I'm trying to write a driver that would control one simple I/O module using DeviceNet for simple bench testing.
The device is a Turck FDN20-S0404G-0220. The CAN converter I'm using is an MCP2515 connected to a Raspberry Pi 4b.
I've been able to send CAN data successfully between the raspberry and an arduino-type device, so I'm confident I've got that part down. I also have the .eds file for FDN20.
I've been using GPT 4.o to try and help me format the data frame correctly, but I'm only getting echoes back, and the device's green flashing status LED indicates its "Waiting for network connection".
I must be missing some initial configuration message or a join network request, but I haven't been able to find an direct documentation on this device; the eds file was found by a colleague and took serious digging. I'll attach that.
I appreciate any information that can help me get a little further into this project. All I'm trying to do is get the input status from the device, and control it's outputs. One device at a time.
 

Attachments

  • RSI_EDS_010000070DC10400_FDN20 S0404G 0220 Rev 4.2.txt
    17.8 KB · Views: 18
Welcome to the forum, fellow washingtonian!

I would love to see what ChatGPT came up with. I implemented a class 1 adapter with roughtly 700 lines of code. This is a non-trivial task, you have to implement portions of the EIP/CIP protocol.

Do you have your code posted somewhere? Others may be able to comment on the microcontroller, I'm not sure what hardware would be necessary for DeviceNET.
 
Ah, that's what I was afraid of.

I'll attach the python code ChatGPT came up with, but there really isn't much there. It sort of just puts the polling command in with the MAC ID in the Identifier portion of the CAN frame and sends a 0x00 in the data and hopes for a response. I never messed with the code much, I mostly tried manually sending frames through the console, hitting object paths from the eds file.

I would love any help you're willing to give. This isn't really a top priority project here at work, just a passion one I do in my free time, learning more programming where I can. I know the maintenance team here would get a kick out of being able to test the solenoids the FDN20 controls with just an M12 connection and a few buttons, instead of how they do it now, prodding the terminals with stripped wires.
 

Attachments

  • Dnet_python.zip
    1.8 KB · Views: 11
I think it would be far easier, if the purpose is test bench only, to go to eBay and find a used SST of Hilsher board, for which the Windows software is available, and setup a Windows test system.
 
Oh man! You weren't kidding about the hard-to-find EDS file. Did Turck support send it to you?
You might be able to upload the EDS file directly from the device since you have it on hand.
 
I think it would be far easier, if the purpose is test bench only, to go to eBay and find a used SST of Hilsher board, for which the Windows software is available, and setup a Windows test system.
That would make sense; this is mainly just to see if it could be pulled off. Nobody is going to want to spend money on this particular project, it's just for my enrichment.

Oh man! You weren't kidding about the hard-to-find EDS file. Did Turck support send it to you?
You might be able to upload the EDS file directly from the device since you have it on hand.
Yes, Turck had to rustle it up themselves. What do you mean by upload the EDS file directly?

This is what it took to interface with a generic module in the I/O tree via Ethernet: pylogix/pylogix/adapter.py at experimental · dmroeder/pylogix

I think your situation would be the reverse, you'd have to write the end that would be the PLC. When you're done, our adapters can sit there and talk to each other lol.

Like I said, I'm unsure about the hardware, hopefully someone else will comment.
Thank you for sharing! That looks quite comprehensive. That would be fun to slowly develop my system to parse any .eds file and control VFDs and all that fun stuff...as soon as I can get something back from the device besides echoes!

Are you able to show an example data frame your program there is setup to receive from the master? I'm trying to find a raw example to check my format against.
 
That would make sense; this is mainly just to see if it could be pulled off. Nobody is going to want to spend money on this particular project, it's just for my enrichment.
Then you would have to study the DeviceNet specification. There is something called the pre-defined master connection set which explains which CAN IDs correspond to which message (i.e slave poll response, etc.), You may find the attached MS Excel sheet useful. I did this worksheet over 20 years ago when I was studying DeviceNet. You only need to input the three-hex digits CAN ID and it gives some description of the meaning of the message, as per the specification.
Yes, Turck had to rustle it up themselves. What do you mean by upload the EDS file directly?
I think this means whether you are using a DeviceNet scanner that supports EDS parsing, etc., (such as RSNetworx) which is of course not your case.
 

Attachments

  • D-NMODEL.zip
    244.9 KB · Views: 14
Attached to this message I send you a couple of DeviceNet traces. You can use the MS Excel sheet to work out the meaning.

Good luck.
 

Attachments

  • fail01.TXT
    56.6 KB · Views: 14
  • norm01.TXT
    56.7 KB · Views: 15
Then you would have to study the DeviceNet specification. There is something called the pre-defined master connection set which explains which CAN IDs correspond to which message (i.e slave poll response, etc.), You may find the attached MS Excel sheet useful. I did this worksheet over 20 years ago when I was studying DeviceNet. You only need to input the three-hex digits CAN ID and it gives some description of the meaning of the message, as per the specification.
Wow, that spreadsheet appears to be very useful. This is the first time I'm getting actual responses from the device other than echoes. I think my issue really is coming down to how the Identifier Field is being calculated.

I'm getting responses now after changing the ID on the device itself, and basically sending anything. This is the response: 57F [7] 00 00 01 23 83 D0 04.

I haven't found a match anywhere yet as to what the data field means, but the identifier seems to check out as sending it's MAC ID: 10 back and the function code for Slave Status Response: 23. After sending anything after that, it just goes back to echoing.

With your spreadsheet and perusing more on the ODVA's documentation, I really feel I'm getting much closer to an understanding of the structure. There's a few things I'm getting hung up on.

What's the difference between (when to use) the Source MAC ID and MAC ID?

Initial messaging. From the documentation:
DeviceNet is a connection-based network, meaning that a relationship (i.e., connection) with a device must first be established in order to exchange data with that device. Connections are established via either an Unconnected Message Manager (UCMM) or a Group 2 Unconnected Port.
Does this mean a properly structured group 2 message should be sent to initialize the connection before checking and controlling I/O? Is there one listed in the device's eds file?

What all makes up the Identifier Field? Up to this point, I'm putting 2 pieces of data in it: The MAC ID of the device I'm trying to communicate with, and a function code of some sort:

0: Reserved
5: Polling Request
29: Polling Response
16: Explicit Request
17: Explicit Response
23: Slave Status Response
39: COS or Cyclic Data Response

Are these proper codes? Chat GPT came up with these, but I can't find any documentation to support this. Based on your spreadsheet, Alfredo, it looks like there's a bit more to it.

Thank you all very much for the responses, this is really exciting to start getting some results!
 
OK, there is a lot to cover here.
57F is duplicate MAC ID check message. Have a look at the serial number of the device and it should be 01 23 83 D0 04. Maybe you have to reverse the bytes and convert to decimal. This should have been obvious if you had actually used my excel worksheet.
Yes, the most common DeviceNet messaging is the IO messaging, or the pre-defined connection set. By the way, I have to use "master/slave" terminology because this is how the specification is written.
In this predefined connection set, it is necessary to establish a connection. For example in the text I sent there is the message:
3DA, which is Group 1 source MAC ID 26, message ID 15 (Slave's I/O Poll Response or Change of State/Cyclic Acknowledge Message)
4CD, which is Group 2 "destination MAC ID 26, message ID 5 (master IO poll)

Group 1 messages are responses from slave, and group 2 are requests from master or DUP MAC ID check.
The CAN ID for group 1 are lower than group 2, which are lower than group 3 and lower than group 4.
The CAN arbitration is such that the lower the CAN ID the higher the priority. If a G1 message and a G2 message would be sent by two devices at the same time, the G2 message would not be transmitted because the CAN transceiver listens at the same time it transmits and is able to detect whether its CAN ID did not go through and stops transmitting the rest of the message.

In order to establish a connection, you need to consult the DeviceNet specification. You have to understand how connection is established and also the specific profile of the slave device, as the request will only start communication if it is asked to provide the kind of data that it supports.
 
I really do appreciate your patience with this, I understand how frustrating it can be dealing with people less technical than yourself.

Your worksheet, at first was quite the information dump, and I really didn't know where to start processing. You even said "You only need to input the three-hex digits CAN ID..." You're right, it would have been obvious if I knew it was interactive like that. Really impressive.

This is the only really useful documentation I've been able to find: DeviceNet ODVA

I would think this is too high level to actually create the pre-defined master/slave or UCMM connections, unless I'm missing something very obvious.

When you say "Study the devicenet documentation", did you have a specific document in mind, and do you mind sharing where it's stored? As far as Turck's go for this specific device, there really isn't anything. I've found other documentation for VFDs and other sensors from other manufacturers, and it begins to get apparent how complex this can get. Unfortunately, anything else I've been able to find is always in the context of some software that does all the low level stuff for you.
 
I really do appreciate your patience with this, I understand how frustrating it can be dealing with people less technical than yourself.

Your worksheet, at first was quite the information dump, and I really didn't know where to start processing. You even said "You only need to input the three-hex digits CAN ID..." You're right, it would have been obvious if I knew it was interactive like that. Really impressive.
amcollumn, I am sorry. I should have explained it clearer about the interactiveness part.
I am glad it is useful for you. It is very crude. Maybe I will improve it this month and send you a new version. I have some ideas.

When you say "Study the devicenet documentation", did you have a specific document in mind, and do you mind sharing where it's stored? As far as Turck's go for this specific device, there really isn't anything. I've found other documentation for VFDs and other sensors from other manufacturers, and it begins to get apparent how complex this can get. Unfortunately, anything else I've been able to find is always in the context of some software that does all the low level stuff for you.
The ODVA specification is an open standard, but it is only available to ODVA paying members.
This document from Rockwell is freely accessible from the link below.
https://literature.rockwellautomation.com/idc/groups/literature/documents/um/1769-um009_-en-p.pdf
https://literature.rockwellautomation.com/idc/groups/literature/documents/in/1756-in566_-en-p.pdf
You can get the class codes and things like that.
Since EtherNet/IP is also a CIP protocol, some Rockwell manuals for EIP may be useful as there are many services and classes which are common (CIP= Common Industrial Protocol).

Even if you had the ODVA specification, it would take a lot of work to go from the specification to a working Phyton code. The spec is too abstract and does not have sample code.
For your reference, if you asked a company such as Real Time Automation (a Wisconsin company which is a specialist in industrial communication and with a strong emphasis on CIP networks such as DeviceNet and other Rockwell networks), with whom I have had the pleasure to work and whom I have represented in Japan, for a DeviceNet scanner or master SDK (stack development kit), you may be impressed by the price tag.

It is not obvious the development of a scanner application.

There is a shortcut if you only need to confirm the device is working. Since the connection manager is so complex, I advice you use the UCMM (unconnected message manager). There is something called the Assembly class (Class ID 0x04). This is a mandatory class for all CIP adpaters, including DeviceNet.
Find out which instances for the assembly class are supported for your device. Normally assembly class instances start from instance 100 (0x64), which is a range that is free to use by generic devices. The EDS of the device or the documentation will tell you which instances (input and output) are supported. In CIP input or output is though as from the process point of view. So for a sensor the input is the data that the sensor sends to the scanner.

When using UCMM you can write an application that periodically sends GetAttributeSingle (service ID 0x0e) to class 0x04 (assembly class), instance number (whatever the device supports) to attribute ID 0x03 (which is the "data" attribute). You may be even be able to write data to the device with the SetAttributeSingle (ID 0x10) service, again to the "data" attribute.

Hope this helps. It is very motivating for me to explain the younger generation about this stuff. Explaining this stuff to young engineers like yourself helps me disabuse myself of the sad thought that lurks deep in my mind that young kids all they want to do is become TikTok influencers. Not all it seems! Some like industrial networks which I find really cool! I will be happy to continue helping you. Good luck. Lets get this working!
 

Similar Topics

I would be so grateful for advice from this forum's Rockwell networks veterans on how to approach Rockwell on the issue I am reporting below. I am...
0
Replies
177
Views
Hi, Anyone had a go at using a PF525 and reading the position through a 25-ENC-1 over DeviceNet? I've been tasked with reinstating a 20 year...
4
Replies
278
Views
Got somewhat of a monster on site. CLX Processor 1756 a bunch of RIOs hanging off it. all easy no dramas. Nothing insane in the logic either. I...
4
Replies
378
Views
As the subject says I am looking for help with a DeviceNet Simulator. I work in a repair shop, and we have some components that use DNet for...
2
Replies
325
Views
Anyone ever update firmware on the Devicenet portion of an Ultra 100? Ran into this issue recently where an Ultra died, customer purchased a new...
0
Replies
201
Views
Top