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 » Help with ads1115 and 4diac(raspberry pi + ads1115)
Help with ads1115 and 4diac [message #1786474] Thu, 03 May 2018 21:50 Go to next message
Rodrigo Esposito is currently offline Rodrigo EspositoFriend
Messages: 24
Registered: August 2016
Junior Member
Hello there,
i need to read some analogic inputs with raspberry pi, so i'm using this analog to digital converter model ads1115, it uses I2C comunication. The question is that i don't how to read this through the 4DIAC-IDE can somebody help with this?


This is a reference to the converter:
https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/ads1015-slash-ads1115
Re: Help with ads1115 and 4diac [message #1786483 is a reply to message #1786474] Fri, 04 May 2018 08:16 Go to previous messageGo to next message
Martin Melik Merkumians is currently offline Martin Melik MerkumiansFriend
Messages: 117
Registered: March 2016
Senior Member
Hi!

First you should get the IO board working with a C/C++ library, as 4diac-RTE is a C/C++ program

Probably take a loot at the WiringPi library and get your analog in board running with a demo program

https://github.com/WiringPi/WiringPi

Cheers,
Martin
Re: Help with ads1115 and 4diac [message #1786508 is a reply to message #1786483] Fri, 04 May 2018 16:09 Go to previous messageGo to next message
Rodrigo Esposito is currently offline Rodrigo EspositoFriend
Messages: 24
Registered: August 2016
Junior Member
i'm running this on python and everything is good. Do you think i have to create a custon FB with this codes that you had shown me?
Re: Help with ads1115 and 4diac [message #1786532 is a reply to message #1786508] Sun, 06 May 2018 07:12 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

In IEC 61499 all IO access is handled through Service Interface Function Blocks. These FBs are typically custom tailored for the specific IOs that you have. So one starting point would be to write your one specific FB.

In 4diac we started to introduce a generic set of IO FBs (i.e., IX, IB, IW, ID, Qx, QB, QW, WD) making it easier for you to implement IOs. Here you only have to implement a class called CProcessInterface. These class will then handle the device specific IO part and will be utilized by the generic FBs in a kind of strategy pattern. For your case with I2C you can have a look on I2CDev and raspberrypi sps directories for examples.

However you will need to perform certain i"C messages specific to your chip. You can have a look into the code of the adafruit library to find out how this is performed. But from a previous experience when we tried this for a steppermotor cape I noticed that the adafruit library is quite complicated. Therefore it might be easier to just read through the data sheet of your ads1115 chip [1] and find out about the messages needed for setting it up and for reading the ADC converted values.

[1] https://cdn-shop.adafruit.com/datasheets/ads1115.pdf
Re: Help with ads1115 and 4diac [message #1786630 is a reply to message #1786532] Tue, 08 May 2018 19:26 Go to previous messageGo to next message
Rodrigo Esposito is currently offline Rodrigo EspositoFriend
Messages: 24
Registered: August 2016
Junior Member
Is there anyway to use native system libary, like stdio, when i'm creating the FB ?
Re: Help with ads1115 and 4diac [message #1786633 is a reply to message #1786630] Tue, 08 May 2018 19:44 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

As this FB you need to create is a SIFB where you only model the interface in 4diac-ide, then generate cpp code and extend this cpp code to your needs you can use all libraries you need.
Re: Help with ads1115 and 4diac [message #1786643 is a reply to message #1786633] Tue, 08 May 2018 21:23 Go to previous messageGo to next message
Rodrigo Esposito is currently offline Rodrigo EspositoFriend
Messages: 24
Registered: August 2016
Junior Member
Do you have any reference of how to procede with this? Or any example that i could follow?

for example, can i use this library directly on ECC algorithm so i can export it later?
Re: Help with ads1115 and 4diac [message #1786672 is a reply to message #1786643] Wed, 09 May 2018 07:59 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

You can use this also in ECCs. However this is not really straight forward. You have to write algorithms in any_text. There you can write C++ code and the code will be directly put into the generated include files. You can put your include statements in the header field of the compilerinfo of your FB. But this is a little bit cumbersome to do.

For an example that could be an interesting reference you might want to look at the process interface I wrote for the PIFace. This is in principle rather similar to what you would like todo the only difference is that piface is using the SPI and not I2C and has only digital I/Os if I rember correctly. For analog I/Os you could look into the Odriod module.
Re: Help with ads1115 and 4diac [message #1786706 is a reply to message #1786672] Wed, 09 May 2018 16:27 Go to previous messageGo to next message
Rodrigo Esposito is currently offline Rodrigo EspositoFriend
Messages: 24
Registered: August 2016
Junior Member
i'm thinking about compile forte with wirePI library and write and FB to use it. Do you think it could work?
Re: Help with ads1115 and 4diac [message #1786717 is a reply to message #1786706] Wed, 09 May 2018 18:21 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

Yes this will definitely work. One strength of 4diac FORTE is that it is rather easy to wrap existing C/C++ libraries in Function blocks.
Previous Topic:Watching an sub application
Next Topic:Function TIME()
Goto Forum:
  


Current Time: Thu Apr 25 19:39:32 GMT 2024

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

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

Back to the top