SIOC encoder reading problem[SOLVED]

This is a new forum for the OC4BAv4.
Post Reply
lorenzinmarco
Posts: 7
Joined: Sun Mar 05, 2017 10:01 am

SIOC encoder reading problem[SOLVED]

Post by lorenzinmarco »

Hi guys,
after dozens of attemps and hours spent to understand why SIOC/OC4BA doesn't read my Overhead Panel's encoders properly, I try to ask here in the forum about my new issue.
I'm using the rotary encoder linked below (FLT ALT and LAND ALT rotary encoders):

https://www.sabdel.com/shop/electronics ... ray-scale/

It's a 2-bit gray type encoder as you can see. Encoders are connected to an Opencockpits "Input connection + Encoders" Card like this:

http://www.opencockpits.com/catalog/inp ... Path=21_27

Encoders are connected directly to the card's standard inputs.
I try to test the script below, but it doesn't work properly. The digit display seems to be crazy!!! I think there's a problem on SIOC encoder reading.

Here's the script I tested:

Var 0598, static, Link IOCARD_ENCODER, Device 30, Input 108 Aceleration 3, Type 2 // Encoder input for FLT ALT
{
L1 = &FlightAlt
L0 = 500 * V0598
&FlightAlt = LIMIT -1000 ,42000 ,L0
L2 = &FlightAlt
IF L2 > L1
{
IF &PRESS_F_ALT_K = 0
{
&PRESS_F_ALT_K = 1
}
ELSE
{
&PRESS_F_ALT_K = 0
}
}
ELSE
{
IF &PRESS_F_ALT_K = 8192
{
&PRESS_F_ALT_K = 8193
}
ELSE
{
&PRESS_F_ALT_K = 8192
}
}
}

I tried to change aceleration number, but nothing different happens.
Thank you in advance for responses.
Best regards

Marco
Alpin-Flier
Posts: 44
Joined: Sun May 24, 2015 2:59 pm

Re: SIOC encoder reading problem

Post by Alpin-Flier »

Hi Marco

I wrote a new compact script for the flight and landing altitude. Adjust encoder inputs to your setup and then it should work:

// Flight and Landing Altitude

Var 2700, name PRESS_F_ALT_K, static
Var 0598, Link IOCARD_ENCODER, Device 30, Input 126, Aceleration 3, Type 2 // Encoder input for FLT ALT
{
L0 = -50 * V0598
&FlightAlt = LIMIT -1000 ,42000 ,L0
&PRESS_F_ALT_K = 0
IF L0 > 0
{
&PRESS_F_ALT_K = 16384
}
ELSE
{
&PRESS_F_ALT_K = 8192
}
}

Var 2701, name PRESS_L_ALT_K, static
Var 0599, Link IOCARD_ENCODER, Device 30, Input 128, Aceleration 3, Type 2 // Encoder input for LAND ALT
{
L0 = -50 * V0599
&LandAlt = LIMIT -1000 ,42000 ,L0
&PRESS_L_ALT_K = 0
IF L0 > 0
{
&PRESS_L_ALT_K = 16384
}
ELSE
{
&PRESS_L_ALT_K = 8192
}
}

Please let us know if you succeeded.
Regards
Urs
Alpin-Flier
Posts: 44
Joined: Sun May 24, 2015 2:59 pm

Re: SIOC encoder reading problem

Post by Alpin-Flier »

Hi Marco

I made a short review and found an even simpler solution :) . Try this:

// Flight and Landing Altitude

Var 2700, name PRESS_F_ALT_K, static
Var 0598, Link IOCARD_ENCODER, Device 30, Input 126, Aceleration 3, Type 2 // Encoder input for FLT ALT
{
&PRESS_F_ALT_K = 0
IF V0598 < 0
{
&PRESS_F_ALT_K = 16384
}
ELSE
{
&PRESS_F_ALT_K = 8192
}
}

Var 2701, name PRESS_L_ALT_K, static
Var 0599, Link IOCARD_ENCODER, Device 30, Input 128, Aceleration 3, Type 2 // Encoder input for LAND ALT
{
&PRESS_L_ALT_K = 0
IF V0599 < 0
{
&PRESS_L_ALT_K = 16384
}
ELSE
{
&PRESS_L_ALT_K = 8192
}
}

Works perfect in my cockpit.
Best regards
Urs
lorenzinmarco
Posts: 7
Joined: Sun Mar 05, 2017 10:01 am

Re: SIOC encoder reading problem

Post by lorenzinmarco »

Hi Urs,
after hundreds of attempts, finally I decided to use Opencockpits CTS288 type encoders for FLT ALT and LAND ALT:

http://www.opencockpits.com/catalog/enc ... p-100.html

Encoder central pin is connected to GND, and the other pins to two consecutives inputs in the same Input card group. No encoders' push button implemented.
Are your scripts good also for CTS88 type encoders?
I tried running scripts you suggested me, but encoders work fine only in one direction (e.g 0,500,1000,1500 and so on).
Numbers can't decrease as I rotate encoders in opposite direction.
Any suggestions?
Best regards.

Marco
Alpin-Flier
Posts: 44
Joined: Sun May 24, 2015 2:59 pm

Re: SIOC encoder reading problem

Post by Alpin-Flier »

Hi Marco

Please check the following:
Be sure that the two consecutive inputs from encoder are correct and not shifted by 1 up or down. Sometimes numbering is confusing...
Then verify by sending commands from IOCP console, that the values 16384 and 8192 change the altitude up resp. down in your setup.

Best regards
Urs
lorenzinmarco
Posts: 7
Joined: Sun Mar 05, 2017 10:01 am

Re: SIOC encoder reading problem

Post by lorenzinmarco »

Hi Urs,
after 9 months I finally solved my problem!!! Input connections were OK, I simply replaced your script with Roar script:

Var 0598, static, Link IOCARD_ENCODER, Device 30, Input 108 Aceleration 3, Type 2 // Encoder input for FLT ALT
{
L1 = &FlightAlt
L0 = 500 * V0598
&FlightAlt = LIMIT -1000 ,42000 ,L0
L2 = &FlightAlt
IF L2 > L1
{
IF &PRESS_F_ALT_K = 0
{
&PRESS_F_ALT_K = 1
}
ELSE
{
&PRESS_F_ALT_K = 0
}
}
ELSE
{
IF &PRESS_F_ALT_K = 8192
{
&PRESS_F_ALT_K = 8193
}
ELSE
{
&PRESS_F_ALT_K = 8192
}
}
}

Your script didn't work for me, Urs.
BUT another problem comes out!
When both encoder inputs labels are green in SIOC monitor, all inputs belonging to rotary encoders' inputs group start flickering without any reason.
When only one encoder input label is green, everything is OK.
When both encoder inputs label are white, everything is OK.
Any suggestion?
Best regards.

Marco
Alpin-Flier
Posts: 44
Joined: Sun May 24, 2015 2:59 pm

Re: SIOC encoder reading problem

Post by Alpin-Flier »

Hi Marco

Verify that flickering is off with each of the two inputs switched (one or the other green). --> if not, check corresponding input wire for short circuit. If yes,check ground wire of the group
Does flickering appear also when another encoder of the group has both inputs green? --> check ground wire of the group

Best regards
Urs
lorenzinmarco
Posts: 7
Joined: Sun Mar 05, 2017 10:01 am

Re: SIOC encoder reading problem

Post by lorenzinmarco »

Hi Urs,
problem solved! I'm using an Opencockpits "Input connection + Encoders", not a simple Opencockpits Input card.
I hadn't feed card with 5V!!!
Thank you anyway for your cooperation Urs.
Best regards.

Marco
mvr1918
Site Admin
Posts: 1633
Joined: Thu Aug 30, 2012 3:35 pm

Re: SIOC encoder reading problem

Post by mvr1918 »

I mark this topic as SOLVED
Post Reply