Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » SPI on Raspberry Pi | 4DIAC(how can i wrap an SPI Library into 4DIAC)
SPI on Raspberry Pi | 4DIAC [message #1817906] Mon, 02 December 2019 22:25 Go to next message
Jakob Blum is currently offline Jakob BlumFriend
Messages: 5
Registered: December 2019
Junior Member
Hello,

i am new to 4DIAC and would need some help please.

I want to use 4DIAC to setup a CAN Network running on Raspberry PI's. I am using DEBO CAN MODULES that can be controlled via an SPI Interface. Therefore i would need SPI functionality in DIAC4.

The problem is i dont really know how to proceed here. I read somewhere else that C libraries can be integrated into function blocks. Are there any tutorials on this topic or could someone explain to me how its done?

thank you very much and best regards

Re: SPI on Raspberry Pi | 4DIAC [message #1818010 is a reply to message #1817906] Wed, 04 December 2019 08:11 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

Hi,

you can have a look at the FB creation tutorial and their specifically on the Service Interface Function Block section. What kind of CAN communication do you like to do? Is it like publish/subscribe then pelase read the documentation section on the communication architecture. If it is I/Os then I can only offer you code examples. Especially the Embrick module should be similar to what you need.

I hope this helps to get you started.
Re: SPI on Raspberry Pi | 4DIAC [message #1818021 is a reply to message #1818010] Wed, 04 December 2019 10:19 Go to previous messageGo to next message
Jakob Blum is currently offline Jakob BlumFriend
Messages: 5
Registered: December 2019
Junior Member
thank you for your reply! Some new questions came up now :)

I did not think of what kind of Can Communication i like to do, isnt the can communication handled by the Can Modules which are controlled via the SPI interface?

Do you know of a more direct way to incorporate Can Communication to 4DIAC without having to use an additional protocol? I would need as much control over the communication as possible. Maybe i have to rethink my concept

thank you and best regards
Re: SPI on Raspberry Pi | 4DIAC [message #1818048 is a reply to message #1818021] Wed, 04 December 2019 18:18 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

The reason I'm asking is mainly target towards how you would like to represent your requried CAN communication in IEC 61499. The most flexiblity you have when you are using a Publish subscirbe interface where you send plain CAN messages. However then you have to write FBs that will generate the messages and do all the padding and stuff (i.e., CAN messages have at max 8 bytes).

If you have other use cases you may want to do more in C++ code and have a simpler interface on IEC 61499 side.
Re: SPI on Raspberry Pi | 4DIAC [message #1818054 is a reply to message #1818048] Wed, 04 December 2019 21:05 Go to previous messageGo to next message
Jakob Blum is currently offline Jakob BlumFriend
Messages: 5
Registered: December 2019
Junior Member
i am planningto expand the CAN communication later with an ECYCLE FB in order to realise a time triggered behaviour

therefore would it be neccessary to use the Publish Subscripe interface approach or would it be sufficient to use C++?
Re: SPI on Raspberry Pi | 4DIAC [message #1818055 is a reply to message #1818054] Wed, 04 December 2019 21:10 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

With the information given so far I would say both is possible. However if on the other end of the CAN only IO modules or IO module like devices are connected I think the IO concept is the better solution.

However for starting the pub/sub approach may be easier (especially better documented)
Re: SPI on Raspberry Pi | 4DIAC [message #1818056 is a reply to message #1818055] Wed, 04 December 2019 21:42 Go to previous messageGo to next message
Jakob Blum is currently offline Jakob BlumFriend
Messages: 5
Registered: December 2019
Junior Member
The plan is to have a network of Pi's that communicate over the bus in that way, so no IO modules i guess.

As for the documentation, can you provide me a few links or is the documentation section on the communication architecture all there is? I am really just at the beginning for now..

thank you for your help so far. it is very much appreciatet!

Re: SPI on Raspberry Pi | 4DIAC [message #1818057 is a reply to message #1818056] Wed, 04 December 2019 21:50 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

This speaks more for the pub/sub solution. In our documentation there is a section on our communication architecture [1]. But I would strongly recommend to also work through the tutorials first. Feedback on both is very welcome. The documentation is maintained as part of the 4diac IDE source code.

[1] https://www.eclipse.org/4diac/en_help.php?helppage=html/development/forte_communicationArchitecture.html
Re: SPI on Raspberry Pi | 4DIAC [message #1818059 is a reply to message #1818057] Wed, 04 December 2019 22:22 Go to previous messageGo to next message
Jakob Blum is currently offline Jakob BlumFriend
Messages: 5
Registered: December 2019
Junior Member
thank you! i will read through the docs and let you know when there are any uncertainties
Re: SPI on Raspberry Pi I/O expand | 4DIAC [message #1848005 is a reply to message #1818010] Wed, 17 November 2021 10:25 Go to previous messageGo to next message
Monzur Murshed is currently offline Monzur MurshedFriend
Messages: 1
Registered: January 2021
Junior Member
I want to expand Raspberry Pi I/O using SPI/I2c as Analog Input or output. How can I create my own block for these? Please kindly share some documentation or example code (C++) that will help me in this issue.

Thanking You
Murshed
murshed00123@gmail.com

Re: SPI on Raspberry Pi I/O expand | 4DIAC [message #1848083 is a reply to message #1848005] Fri, 19 November 2021 11:15 Go to previous message
Jonathan Lainer is currently offline Jonathan LainerFriend
Messages: 5
Registered: November 2021
Junior Member
If you want to create your own function block (FB) to extend 4diac, I suggest you take a look at the corresponding documentation.

To embed custom code, you want to look at section Create a Service Function Block.
The documentation walks you through creating a FB interface in the IDE, exporting it and then adding your custom code to it.

If you encounter any problems or if something is unclear, please don't hesitate to ask!

[Updated on: Fri, 19 November 2021 11:17]

Report message to a moderator

Previous Topic:How to use 4diac as http server
Next Topic:opc_ua Browsepath can't use namespace 2
Goto Forum:
  


Current Time: Thu Mar 28 19:51:44 GMT 2024

Powered by FUDForum. Page generated in 0.03819 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top