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 » I2C/SPI Support(Help on interfacing an I2C/SPI device with Raspberry Pi running Forte)
icon3.gif  I2C/SPI Support [message #1756223] Tue, 14 March 2017 09:44 Go to next message
Akshai M is currently offline Akshai MFriend
Messages: 10
Registered: February 2017
Junior Member
Hi,

I am looking for help to interface ADXL345 <http://www.analog.com/en/products/mems/accelerometers/adxl345.html> sensor which has I2C and SPI interfaces with Raspberry Pi running forte. I have found an I2C module in forte build but I am unaware of interfacing the device in 4DIAC IDE.
My goal is to read data from I2C/SPI bus, show it in FBRT and then use it to control a relay board.I am able to control a relay board using the QX and read the status of relay using IX blocks.

Thanks.

Akshai M
Re: I2C/SPI Support [message #1756281 is a reply to message #1756223] Tue, 14 March 2017 21:47 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 644
Registered: January 2014
Senior Member
Hi,

What you can do as starting point is to define your own SIFBs whith which you read the values of the ADXL345. Inside of this FB you could make use of the SPI class which is implemented in the conmeleon module. This class gives you a very convenient access to SPI. The only thing would you should note is to not activate the full conmellon module but just reference the needed SPI class from your module. You can have a look in the PiFace module for reference.

The next point is that typically you need to read and write registerd of the SPI device. This now depends on the operation mode and offerings of your chip and which modes you would like to use.

I hope this helps you for getting started.
Re: I2C/SPI Support [message #1756303 is a reply to message #1756223] Wed, 15 March 2017 08:57 Go to previous messageGo to next message
Milan Vathoopan is currently offline Milan VathoopanFriend
Messages: 25
Registered: August 2016
Junior Member
Hi Akshai,

Just for your quick reference, you can see the PiFace module only in the "development" branch and it is not there in the default branch. Please checkout the development branch for your PiFace module

use "git checkout develop"

Milan

[Updated on: Wed, 15 March 2017 09:03]

Report message to a moderator

Re: I2C/SPI Support [message #1756388 is a reply to message #1756303] Thu, 16 March 2017 10:11 Go to previous messageGo to next message
Akshai M is currently offline Akshai MFriend
Messages: 10
Registered: February 2017
Junior Member
Hi Milan and Alois,

Thank you for the reply. I will have a look at PiFace process interface files and SPI interface in conmeleon module. I will try a ping program using SPI bus in Arduino and will get back.
If you can find some help files on PiFace process interface implementation please do share.

Regards.

Akshai M
Re: I2C/SPI Support [message #1763451 is a reply to message #1756388] Tue, 16 May 2017 10:52 Go to previous messageGo to next message
Akshai M is currently offline Akshai MFriend
Messages: 10
Registered: February 2017
Junior Member
Hi,
I moved to the develop branch but then CMAKE gives me configuration errors. So I copied the PiFace module to master branch and CMAKE successfully gave me the makefile.
I checked FORTE_MODULE_CONMELEON_C1 and FORTE_MODULE_PiFace in CMAKE but then build fails. Please find the screenshot of the error.

Regards,

Akshai M
Re: I2C/SPI Support [message #1763452 is a reply to message #1756388] Tue, 16 May 2017 10:52 Go to previous messageGo to next message
Akshai M is currently offline Akshai MFriend
Messages: 10
Registered: February 2017
Junior Member
Hi,
I moved to the develop branch but then CMAKE gives me configuration errors. So I copied the PiFace module to master branch and CMAKE successfully gave me the makefile.
I checked FORTE_MODULE_CONMELEON_C1 and FORTE_MODULE_PiFace in CMAKE but then build fails. Please find the screenshot of the error.

Regards,

Akshai M
Re: I2C/SPI Support [message #1763456 is a reply to message #1756281] Tue, 16 May 2017 11:36 Go to previous messageGo to next message
Milan Vathoopan is currently offline Milan VathoopanFriend
Messages: 25
Registered: August 2016
Junior Member
Alois Zoitl wrote on Tue, 14 March 2017 21:47


The only thing would you should note is to not activate the full conmellon module but just reference the needed SPI class from your module. .


Please make sure as stated above that you are not activating the complete conmeleon module. Just make sure the conmeleon module is there in the forte modules directory. The referencing is given within PiFace processinterface, which will find the required SPI class while building. Hope this helps.

Milan
Re: I2C/SPI Support [message #1763652 is a reply to message #1763456] Thu, 18 May 2017 11:27 Go to previous messageGo to next message
Akshai M is currently offline Akshai MFriend
Messages: 10
Registered: February 2017
Junior Member
Hi Milan,

Thank you for the support.

I was able to compile PiFace separately with the following edits.
Updated header in
/src/modules/piface/processinterface.h
#include <thread.h> to #include <thread> , practice used in C++11.

Also, I had to give -std=c++11 flag in CMake.

Regards,

Akshai M
  • Attachment: Update.png
    (Size: 91.10KB, Downloaded 66 times)
Re: I2C/SPI Support [message #1763663 is a reply to message #1763652] Thu, 18 May 2017 12:32 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 644
Registered: January 2014
Senior Member
thanks for pointing this out. Unfortunately your corrections are not fully in line with FORTE classes. Instead of chaging it to #include <thread> it should be #include <forte_thread.h>. The reason is that forte has its own thread abstraction which works also on platforms where the c++11 thread is not supported. Also it is a little bit more lightweighted.
Previous Topic:BOOL to ANY_BIT converstion (IEC61131-3 Bitwise Operators)
Next Topic:OPC Client in 4diac TERMINATED error
Goto Forum:
  


Current Time: Wed Oct 17 13:58:52 GMT 2018

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

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

Back to the top