Linuxcnc and Profibus

More
05 Oct 2021 13:43 #222282 by Aciera
Linuxcnc and Profibus was created by Aciera
This is a quick demonstration of a Festo CPV10-GE-DIO2-8 valve block connected through Profibus-DP interface using the PC-serial port. This uses the 'pyprofibus-master' found here:
github.com/mbuesch/pyprofibus
Note that since this is a python project it runs in userspace. So really only interesting for I/O extension modules. None the less it might be very useful for refitting larger machines:

Videolink: user-images.githubusercontent.com/460672...3b9-0c0c37a73e04.mp4
The following user(s) said Thank You: RotarySMP, tommylight

Please Log in or Create an account to join the conversation.

More
05 Oct 2021 18:11 - 05 Oct 2021 18:13 #222298 by RotarySMP
Replied by RotarySMP on topic Linuxcnc and Profibus
That is cool. Now I feel bad for buying the direct control module my CPV10. Did you connect this through one of those USB widgets which Andy posted?
forum.linuxcnc.org/26-turning/41498-scha...fit?start=200#220605

Looking through the GitHub, I would have no idea where to start to use this widget.  Im not a complete idiot (I hope), but there is no clear thread in there which would give an indication to a low level user, which of the large number of files need to be downloaded, where they need to be installed,  how to integrate them into LinuxCNC, or how to use it to control a profibus device.

The link to hardware is broken.


Maybe it was good this idiot got the Festo multipol control module :)
Mark
Attachments:
Last edit: 05 Oct 2021 18:13 by RotarySMP.

Please Log in or Create an account to join the conversation.

More
06 Oct 2021 06:21 - 06 Oct 2021 06:24 #222333 by Aciera
Replied by Aciera on topic Linuxcnc and Profibus
Well, it did take me a couple of days to figure it out, mostly because I really had no clue about Profibus.

The author doesn't recommend using a usb to RS485 adapter, because of the time lags that can happen with USB, although I did quickly try with one and it seemed so be working well enough. The recommended way is to use an RS232 port with a TTL to RS485 adapter like this:

I use a serial port on a pc that can be configured as an RS485 in the BIOS. In any case you just need to connect the two data lines to the device, no other connection is needed.
As for which files are needed from the github site, it's probably the easiest  to just download all of it and copy the whole lot into your linuxcnc config folder. I haven't whittled it down to the bare necessities yet but the folders 'micropython' and 'phy_fpga' can be deleted right away. 

Getting the configuration right takes a few steps. First you need to get the .gsd (german) or .gse (english) files from the manufacturer website as these contain the required parameter settings for the device. (note that if you use the .gse file it will need to have the extension changed to .gsd). There are some demos for linuxcnc included. Basically the file 'pyprofibus.conf' needs to be modified to set up the profibus connection ( ie port and baudrate, bus address of all the slaves and the number of input and output bytes for each of them and the path to the respective .gsd files).
One problem was that the current version of 'pyprofibus' did not support devices that don't send data back to the master during communication. The valve block only sends an acknowledge byte back and that was not recognized as a response leading to timeouts and the master shutting down. I reached out to the author on his github page ,he's really quite responsive and helpful, and got it working.
To get everything hooked up to linuxcnc and hal you need to modify 'profibus.hal' and add it to your .ini then you run the startup script provided in the demo-folders and the relevant hal pins are created. 

As usual things seem very logical in retrospect but it definitely involved a bit of a learning curve.

You can actually connect extension modules with up to 32inputs and 32outputs to that valve block, but I don't have any of those.
Attachments:
Last edit: 06 Oct 2021 06:24 by Aciera.
The following user(s) said Thank You: RotarySMP, tommylight

Please Log in or Create an account to join the conversation.

More
06 Oct 2021 13:22 #222355 by andypugh
Replied by andypugh on topic Linuxcnc and Profibus
What would be really cool would be a driver for the Mesa UART.
(And it _probably_ isn't all that hard to do)

Please Log in or Create an account to join the conversation.

More
06 Oct 2021 13:42 - 06 Oct 2021 13:50 #222360 by Aciera
Replied by Aciera on topic Linuxcnc and Profibus
Yes, using the serial port the maximum speed is 19.2kbaud but with a mesa uart one might actually increase that towards the maximum of 12Mbaud preferably with the profibus stack being integrated into the FPGA.

[edit]
There is actually also a folder containing verilog code to intergrate a profibus stack on an FPGA. 
github.com/mbuesch/pyprofibus/tree/master/phy_fpga
Just in case anybody is looking for a fun project.
Last edit: 06 Oct 2021 13:50 by Aciera.

Please Log in or Create an account to join the conversation.

More
20 Oct 2021 08:17 #223639 by Aciera
Replied by Aciera on topic Linuxcnc and Profibus
A little update on this. To try the extension capability I bought a 8 channel digital output module and a 16 channel digital input module to connect to the CPV valve block on ebay for less than 30$. All works quite nicely:

user-images.githubusercontent.com/460672...237-dad902cac355.mp4

For those interested I attach the zipped config folder:

 

File Attachment:

File Name: pyprofibus...nfig.zip
File Size:158 KB
Attachments:
The following user(s) said Thank You: RotarySMP, 0x2102

Please Log in or Create an account to join the conversation.

Time to create page: 0.108 seconds
Powered by Kunena Forum