Results 1 to 10 of 15
-
10-17-2011, 08:42 PM #1
- Join Date
- Jan 2008
- Location
- Sydney, Australia
- Posts
- 29
SIOC and Encoders (ROTATE function, etc)
Hi guys, I'm trying to understand the way SIOC handles rotary encoders in the variable processing function.
Say I bind a function to changes of encoder value, what value does it take as I turn the encoder?
Is it the successive increments starting at 0 e.g. 0 -> 1 -> 2 -> "+inf" and to "-inf" as encoder is turned the other way? If so then acceleration attribute makes sense as defining the speed sioc goes through the sequence.
Why then in the scripts for, say, MCP the heading value is directly assigned from the encoder?
e.g. MCP_HEADING = ROTATE 0 to 360, ENCODER_VALUE
That doesn't quite make sense to me... unless the MCP_HEADING takes the delta, adjusting the real heading somewhere?
Can someone clarify exactly what values are coming in from the hardware(into SIOC variable)?
Cheers!
-
10-18-2011, 04:16 AM #2
- Join Date
- Jul 2013
- Posts
- 917
Re: SIOC and Encoders (ROTATE function, etc)
Try this site for excellent sioc coding advice. Also elswhere on the site is an example of using encoders in a nav1 example
http://www.lekseecon.nl/howto.html#rotaryencode
-
10-18-2011, 06:38 AM #3
- Join Date
- Jan 2008
- Location
- Sydney, Australia
- Posts
- 29
Re: SIOC and Encoders (ROTATE function, etc)
Hi, thanks for you reply, but I have seen Nico's website and it doesn't answer the question. Neither does the help file coming with SIOC. I really want a doco stating exactly how the hardware interfacing works
So far what I've see are "working" examples... Problem is they don't work for me and the way I ended up writing my event processing function is by incrementing current value, say:
heading = heading + &ENCODER_VALUE.
Now that suggest to me that ENCODER_VALUE is the change in encoder's position and not absolute value
And here's Nico's example:
Code:Var 1 Link IOCARD_ENCODER Input 40 Aceleration 2 Type 2 { L0 = v1 // * -1 turning clockwise should be plus v2 = ROTATE 0 359 L0 } Var 2 // heading (0 .. 359)
Is var2 taking a change in value and not the value itself?
Hope I explain my problem clear enough.
-
10-18-2011, 07:26 AM #4
- Join Date
- Jul 2013
- Posts
- 917
Re: SIOC and Encoders (ROTATE function, etc)
In the example you quote above
Var 1 only provides the direction of encoder travel, it has no absolute value
Var 2 has the absolute value of the heading.
When the encoder moves then Var 2 value is inc/dec according to the direction of travel within the range of 0 to 360.
Var 2 does not receive an absolute value from the encoder. Var 2 will get its initial value from either a definition, or as a result of an arguement within another function
If you use the IOCPconsole within the main SIOC window you will see the variables within your script and their changing values arising from your h/w changes
-
10-18-2011, 07:32 AM #5
- Join Date
- Jan 2008
- Location
- Sydney, Australia
- Posts
- 29
Re: SIOC and Encoders (ROTATE function, etc)
That's what I don't get. I see assignment statement v2 = (Expression), where Expression is result of ROTATE function
Now how does rotate function get from increment/decrement to absolute heading??? It must return absolute value because its result is assigned to v2..
Now unless I'm missing something obvious here..
Thanks for your help though, I appreciate it.
Edit:
When the encoder moves then Var 2 value is inc/dec
In other C++ you'd write: var2 += (var1), and note var2 = ROTATE(var1), because ROTATE doesn't know anything about var1 in this case.
-
10-18-2011, 07:40 AM #6
- Join Date
- Jul 2013
- Posts
- 917
Re: SIOC and Encoders (ROTATE function, etc)
var 2 does not get an absolute value from the rotate function. Think in terms of Var 2 equals its current value inc or dec by the encoder movement direction within the range (for Var 2) of 0 to 359. The Rotate command does not have a persistent or global value.
-
10-18-2011, 07:48 AM #7
- Join Date
- Jan 2008
- Location
- Sydney, Australia
- Posts
- 29
Re: SIOC and Encoders (ROTATE function, etc)
So hold on...
When I write var2=blah
does it mean var = var + blah? It doesn't make sense... Either var2=blah or var2 = var2 + blah, can't be both..
And I know that var2 = blah acts as assignment operator because if I hardcode var2 = 123 for example I get 123 and not var2 incremented by 123 every time.
Edit:
Is it maybe just special handling of variable assignment in the encoder routine?
PS: Sorry, I work as a programmer, so can't just accept some code without understanding
-
10-18-2011, 07:53 AM #8
- Join Date
- Jan 2008
- Location
- Sydney, Australia
- Posts
- 29
Re: SIOC and Encoders (ROTATE function, etc)
Ah! I think some "global variable" magic happens with ROTATE and LIMIT functions!
I'm experimenting right now and what I see is when I use LIMIT function, var2 does not exceed certain value, so that means that either LIMIT keeps track of the actual value and doesn't let it drift outside the limits or some magic happens during assignment
-
10-18-2011, 07:57 AM #9
Re: SIOC and Encoders (ROTATE function, etc)
nope,
var2 = blah does set the value of blah in var2
however, the ROTATE function will take the value of var2 and increment it with the increment value (which can be positive or negative) and then it will check the limits as stated in the first two parameters.
using the value of the encoder directly in the rotate function will allow to jump some values if you turn the rotary fast.
if you do not want that then you have to condition the encoder value to be +1 if >=0 and -1 if <= -1.
Greetz PeterFS9+PM+AST+opencockpits
-
Post Thanks / Like - 1 Thanks, 0 Likes, 0 Dislikes
aVaTar thanked for this post
-
10-18-2011, 08:00 AM #10
- Join Date
- Jul 2013
- Posts
- 917
Re: SIOC and Encoders (ROTATE function, etc)
Peter
Precisely
David
Hi...realize this has been a long time, but I'm heading down the path of building my own 777...
B777 Overhead Panel Design