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 » Inverted IO in SysFs
Inverted IO in SysFs [message #1724681] Thu, 25 February 2016 12:35 Go to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 199
Registered: February 2016
Senior Member
I found in the code that when writing a pin in the SysFs module, the output is inverted. When a true is desired, it writes a 0 to the actual output and when a false is desired a 1 is written.

The code from the forte source of the writePin() method:

if(OUT_X()){
res = write(fd, "0", 1);
}
else{
res = write(fd, "1", 1);
}


And the readPin() method is as it suppost to be:

if('0' == result[0]){
IN_X() = false;
}
else if('1' == result[0]){
IN_X() = true;
}
Re: Inverted IO in SysFs [message #1725062 is a reply to message #1724681] Mon, 29 February 2016 13:18 Go to previous messageGo to next message
Waldemar Eisenmenger is currently offline Waldemar EisenmengerFriend
Messages: 4
Registered: February 2016
Junior Member
Hi,

after your post I tried to debug the sysfs-module in forte. And I came to the conclusion that you are partly right. It is depends on the application because sometimes you need inverted values for your inputs and outputs. It is just a point of view if "true" should be mapped to "0" or "1". But I agree with you, it is more intuitive when an "0" is returned for "false" and "1" for "true" on an output. For the inputs I would expect "0" returned at the "true" state, because I expect the "true" state when I push a button for example. So you see it is a little bit confusing on the way in which the sysfs-module is programmed in forte.
For this cases sysfs actually provides a method for pulling the I/O up or down. So the user could always decide how an I/O can be used.
I think this method should be also implemented in the sysfs-module of forte. But the question is how to put the information in the IX and QX function blocks? Should they provide more parameters or should the current PARAMS input be extended?
Re: Inverted IO in SysFs [message #1725262 is a reply to message #1725062] Wed, 02 March 2016 08:19 Go to previous message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 199
Registered: February 2016
Senior Member
You are right. As you say, in some cases a pull-up is already configured in the hardware or is better for the design, and a "true" for a pressed button will be seen as a 0.

But without any specific configuration it seems to me that it's more intuitive that a "false" represents a "0" and also low voltage (0 normally) in the pin (whether it's output or input) and a "true" represents a "1" and a high voltage (5 normally) in the pin.

Now, like you said, sometimes it would be nice to have the option of inverting this convention (making actually the program lighter, since instead of an additional NOT block, the QX/IX would take care of that). I think that a good convention for that would be to represent the inversion with a negative value. So if the gpio 50 must be inverted, the PARAM would be actually -50. That way, when the FB parse the PARAM in the INIT event, it could convert it to a signed integer, and in case it's < 0, the active_low file would be set to true.
Previous Topic:problem with opc da and FORTE_1.8_M1
Next Topic:Homepage general
Goto Forum:
  


Current Time: Fri Apr 19 07:31:20 GMT 2024

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

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

Back to the top