PDA

View Full Version : Rotary encoder and FSUIPC



kees69
05-20-2014, 06:07 PM
For a friend of mine i try to write a little script that can turn the COM frequency by using a gray type rotary encorder of open cockpits. The script should see in which directory the encoder is turning. If it is turning left, it should generate an other button in FSUIPC then when turning right. I use the virtual Joystick in FSUPIC at the offset $3343.
Now i did write this script:

Var 158 Link IOCARD_ENCODER Input 1 Aceleration 1 Type 2 // input 52 voor Paul
{
L0 = v158
IF L0 > 0
{
&COM1 = setBIT 5 // set bit 5 of joystick COM1 incr
&COM1 = CLEARBIT 6 // clear bit 6 of joystick
}
ELSE
{
&COM1 = setBIT 6 // set bit 6 of joystick COM1 decr
&COM1 = CLEARBIT 5 // clear bit 5 of joystick
}
}

Var 160 name COM1 Link FSUIPC_OUT Offset $3343 Length 4

The script works fine. According to the direction of the encoder, another button in FSUIPC is activated. But The problem is that it will not repeat that button when I keep turning the encoder in the same direction.

eg. If the COM = 120.25 and I turn the encoder to the right, it becomes 121.25. But it doesn't go further. Now when I turn the encoder to the left it goes back to 120.25, but again not further...

Does anybody have a clue on this?

Kind regards,
Kees Schroijen

HansJansen
05-23-2014, 04:43 PM
Kees,

You'll have to set the activated input back to 0, else the Master card thinks you are holding the switch and will not send new data to the software. Maybe you'll have to delay the resetting for a while; if it follows too quickly on the setting action the software may not see it.

I am not familiar with your setup, so I cannot give more precise instructions, but I think you should be able to find out for yourself now. Otherwise, take a peek at <cite>www.lekseecon.nl, </cite>Nico Kaan's excellent site; he gives a number of examples for programming SIOC scripts.

Good luck!

kiek
06-09-2014, 02:35 AM
Var 156 name GreaterState value 0
Var 157 name LessState value 0


Var 158 Link IOCARD_ENCODER Input 1 Aceleration 1 Type 2 // input 52 voor Paul
{
L0 = v158
IF L0 > 0
{
IF &GreaterState = 0
{
&COM1 = SETBIT 5 // joystick COM1 incr
}
ELSE
{
&COM1 = CLEARBIT 5 // joystick COM1 incr
}
&GreaterState = CHANGEBITN 0 &GreaterState // toggle state (from 0 to 1 or from 1 to 0)
}
ELSE
{
IF &LessState = 0
{
&COM1 = SETBIT 6 // joystick COM1 decr
}
ELSE
{
&COM1 = CLEARBIT 6 // joystick COM1 decr
}
&LessState = CHANGEBITN 0 &LessState // toggle state (from 0 to 1 or from 1 to 0)
}
}


Var 160 name COM1 Link FSUIPC_OUT Offset $3343 Length 4



Nico

KLM366
06-09-2014, 09:52 AM
Hi Nico,

I am the A320 cockpit builder who Kees is asking the question for and Kees informed me that he posted the request here.
Today I checked the forum and I saw your script.
Ofcourse I tried it and it works !!

Until now I used Mjoy's (a printed circuit developed by Mindaugas, that is recognized as joystick), but they are rather unstable and frequently give wrong indications.

At the advice of Kees I switched to OC and that is much more reliable and stable indeed.
I will now connect all Autopilot rotaries via Gray encoders and use your script.

Hartstikke bedankt (as they say in Dutch:wink:

KLM366