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 » digital inputs and outputs RPI
digital inputs and outputs RPI [message #1753996] Mon, 13 February 2017 17:36 Go to next message
Gustavo Caiza is currently offline Gustavo CaizaFriend
Messages: 3
Registered: February 2017
Junior Member
Hello
Sorry for my english
I want to create new function blocks to control the digital inputs and outputs of the raspberry, when creating a function block I can use the digital inputs and outputs, but when I create two fb one to declare the input pins and another to execute the process does not work, I do not know if I'm programming wrong or maybe I should also schedule the events.
Attached my code,
Thank you
Gustavo

*******1 fb******
case scm_nEventINITID:
wiringPiSetup();
pinMode (2, INPUT);
while(1)
{
if (digitalRead(2)==0)
{VALUE1() = true;}
else {VALUE1()=false ;}
}
sendOutputEvent(scm_nEventINITOID);
break;

+++++++2 Fb++++++++++
case scm_nEventINITID:
wiringPiSetup();
pinMode (0, OUTPUT);
while(1)
{
if (true== VALUE2())
{digitalWrite(0,HIGH);}
else {digitalWrite(0,LOW);}
}
break;
.............................
  • Attachment: PRUEB2.fbt
    (Size: 5.28KB, Downloaded 28 times)
  • Attachment: PRUEB1.fbt
    (Size: 5.28KB, Downloaded 23 times)
Re: digital inputs and outputs RPI [message #1754021 is a reply to message #1753996] Mon, 13 February 2017 21:00 Go to previous messageGo to next message
Herwig Eichler is currently offline Herwig EichlerFriend
Messages: 18
Registered: February 2016
Junior Member
Hi Gustavo,
there is no need to program your own FB to access the GPIO's of the Raspberry Pi. You can compile FORTE with the SYSFS module and use IX function blocks to read and QX function blocks to write your GPIO when you create the application in 4DIAC IDE.

kind regards
Herwig
Re: digital inputs and outputs RPI [message #1754022 is a reply to message #1754021] Mon, 13 February 2017 21:24 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 617
Registered: January 2014
Senior Member
Hi,

I totally agree with Herwig. But if there is a special need for adding your own function blocks please note that function blocks on 4diac must not block. So you can not have a while 1 loop inside of them. IEC 61499 fbs are event driven so in order that they do something they need a event trigger from the application.

For writing outputs it is better to have your own REQ event triggering the writing. For inputs either you use an input event for triggering the read or you have separate thread which scans all the inputs and sends according output events. But please be aware that in this case you need to follow some special rules for the FORTE runtime which I would not recommend for 4diac starters.

Alois
Re: digital inputs and outputs RPI [message #1754223 is a reply to message #1754022] Wed, 15 February 2017 14:03 Go to previous message
Gustavo Caiza is currently offline Gustavo CaizaFriend
Messages: 3
Registered: February 2017
Junior Member
Thank you Alois
Previous Topic:4DIAC: Copy-Paste FBs
Next Topic:4DIAC: Show FB in application
Goto Forum:
  


Current Time: Sat Aug 18 04:30:42 GMT 2018

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

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

Back to the top