digital inputs and outputs RPI [message #1753996] |
Mon, 13 February 2017 17:36 |
Gustavo Caiza 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 159 times) -
Attachment: PRUEB1.fbt
(Size: 5.28KB, Downloaded 143 times)
|
|
|
Re: digital inputs and outputs RPI [message #1754021 is a reply to message #1753996] |
Mon, 13 February 2017 21:00 |
|
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 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03179 seconds