PDA

View Full Version : Encoders don't rotate digits forward



Jerrymc3
08-03-2011, 09:08 PM
Why is it that no matter which direction I turn my encoders the digits always count down.


// 0600-0699 - MCP DISPLAYS & ENCODERS

Var 0000, Value 0
{

V0600 = V0604 // Read temporary value of IAS
V0601 = V0605 // Read temporary value of MACH
V0602 = V0604 // Put in IAS Display
V0604 = 200 // IAS
}


Var 0600, Link FSUIPC_OUT, Offset $5406, Length 2 // IAS

Var 0601, Link FSUIPC_OUT, Offset $540E, Length 2 // MACH


Var 0602, Link IOCARD_DISPLAY, Digit 0, Numbers 3 // IAS/ MACH
{
V0604 = V0602 // Send value to PM
}
Var 0603, Link IOCARD_ENCODER, Input 51, Aceleration 6 // Encoder IAS/ MACH v0303

{
L0 = V0603 * 1
C0 = TESTBIT V0607 ,15 // MACH or IAS MODE?
IF C0 // MACH MODE
{
V0601 = LIMIT 25 ,95 ,L0 // Increment or decrement MACH value
}
ELSE
{
V0600 = LIMIT 0 ,340 ,L0 // Increment or decrement IAS value
}
}


Var 0604, Link FSUIPC_IN, Offset $04E0, Length 2 // IAS
{
CALL V0608 // Display del valor
}

Var 0605, Link FSUIPC_IN, Offset $04E8, Length 2 // MACH
{
CALL V0608 // Display del valor
}
Var 0606, Link IOCARD_OUT, Output 32 // Led . DECIMAL
Var 0607, Link FSUIPC_IN, Offset $04F0, Length 2 // MCP LIGHTS
{
C0 = TESTBIT v0607 ,15 // MACH or IAS Mode?
IF C0 // Mode Matches
{
V0601 = V0605 // Hold Temporary value
V0606 = 1 // Turn on Mach point
CALL V0608 // Put value in display
}
ELSE
{
V0600 = V0604 // Hold Temporary value
V0606 = 0 // Turn off Mach point
CALL V0608 // Put value in display
}
}

Var 0608, Link SUBRUTINE // Change IAS / MAcH
{
C0 = TESTBIT V0607 ,15 // MACH or IAS Mode ?
IF C0 // MACH MODE
{
V0606 = 1 // Turn on decimal point
V0602 = V0605 // Put value of MACH in display
}
ELSE
{
V0606 = 0
V0602 = V0604 // Put value of IAS in display
}
}


Var 0610, Link FSUIPC_OUT, Offset $5408, Length 2 // HDG

Var 0611, Link IOCARD_DISPLAY, Digit 3, Numbers 3 // HEADING

{
V0610 = V0612 // Pass value to PM
}

Var 0612, Link IOCARD_ENCODER, Input 60, Aceleration 6 // Encoder HDG

{
V0611 = ROTATE 0 ,359 ,V0612
}

Var 0620, Link FSUIPC_IN, Offset $04E6, Length 2 // VS input
{
L0 = V620 // Read value in LO
C0 = TESTBIT V620 ,15 // Check if Negative
IF C0
{
V0624 = L0 - 65536 // If it is negative becomes a negative binary d
}
ELSE
{
V0624 = L0 // If is not negative, stays positive
}
CALL V0624 // Put value in display
}



Var 0621, Link FSUIPC_OUT, Offset $540C, Length 2 // V/S output

Var 0622, Link IOCARD_DISPLAY, Digit 6, Numbers 4 // V/S

/
Var 0623, Link IOCARD_ENCODER, Input 60, Aceleration 6 // Encoder V/S
{
L0 = V0623 * 100 // Increases from 100 to next 100
V0624 = ROTATE -9000 ,9000 ,L0 // Add or subtract the time value of V/S
IF V0624 < 0 // If temporary V/S is negative
{
V0621 = V0624 + 65536 // becomes negative binary.
}
ELSE
{
V0621 = V0624 // If no, leave positive passing the value to PM
}
}

Var 0624 // Temporary value of V/S


Var 0625, Link SUBRUTINE // Pinta V/S
{
C0 = TESTBIT V0626 ,0 // Check to see if they should be turned off
C0 = NOT C0
IF C0 // Only in the case of being lit
{
IF V0624 < 0 // If V/S is negative, change to positive
{
L0 = ABS V0624
V0627 = -999998 // Light the minus sign
}
ELSE
{
V0627 = 0 // Turn off the minus sign
L0 = V0624
}
V0622 = L0 // Send the adjusted value of v/S to display
}
}

Var 0626, Link FSUIPC_IN, Offset $051C, Length 2 // MCP Indicators
{
C0 = TESTBIT V0626 ,0 // Checks if V/S display Is off?
IF C0 // If yes, then
{
V0622 = -999999 // Turns off rest of digits
V0627 = -999999 // Minus sign is off
}
ELSE // If not,then
{
CALL V0625 // Put value in V/S display
}
}

Var 0627, Link IOCARD_DISPLAY, Digit 10, Numbers 1 // - Sign V/S display


Var 0630, Link FSUIPC_IN, Offset $04E4, Length 2

Var 0631, Link FSUIPC_OUT, Offset $540A, Length 2 // ALT
{
V0632 = V0631
}

Var 0632, Link IOCARD_DISPLAY, Digit 13, Numbers 3 // ALT
{
V0631 = V0632 // Pasa el valor al PM
}

Var 0633, Link IOCARD_ENCODER, Input 58, Aceleration 1 // Encoder ALT
{
L0 = v0633 * 1
V0632 = LIMIT 0 ,500 ,L0
}

Var 0634 // Temporary value v0305

Var 0635, Link IOCARD_DISPLAY, Digit 11, Numbers 2 // ALT
{
V0635 = 0
}

Goldmember
08-04-2011, 06:00 AM
It looks like SIOC for MCP but they have scripts for that. Maybe download them and have a look? Also, have you tried turning really slow? My original OC MCP sometimes increases wrongly when I turn too fast. HTH

fordgt40
08-04-2011, 08:36 AM
Two suggestions:-

Isolate one small simple section of code for an encoder function eg the HDG and run that monitoring thru IOCPConsole to see what is actually happening

I assume that your encoders are suitable for OC, preferably supplied by them and that they are wired up to the mastercard with the 2 data lines going to 2 adjacent inputs within the same "bank" as the common/ground line

David

CanberraACT
08-05-2011, 02:58 AM
I haven't been able to check my references (at home) but from the top of my head, don't you have to enter a "Type" of encoder? either "1" "2" or "3". Maybe the default is not matching your encoder? As David says they do need to be connected to consecutive terminals as well.

fordgt40
08-05-2011, 04:23 AM
Good spot!

Jerrymc3
08-05-2011, 09:54 AM
I'm using Encoders purchased from OpenCockpits. From what I understood, the encoders need to be connected to two consecutive "logical" inputs, not necessarily adjacent pins, ex. logical numbers 18 & 19, would be physical pin numbers 21 & 27 of group three. In another place I read two consecutive pins so I was a little uncertain about that. I tried it both ways but when I tried the second way controlador would only detect one of the inputs when I turned the hdg encoder. I tried a different encoder, tried different pins, checked for loose connections but never got it to work right.

fordgt40
08-05-2011, 10:07 AM
I had assumed that you were using a OC breakout input board. If connecting to the 40 pin header then you must use two adjacent logical inputs eg 3,4 or 11.12 etc within the same bank of nine. So it sounds like software then:(

Re your sioc code for the MCP, is this a pristine copy of a known ok script, or did you amend it, or write it yourself? Also, have you tried CanberraACT advice above

David

Jerrymc3
08-06-2011, 07:08 PM
I made my own inputs board out of stripboard, 40 pin headers and screw terminals. Logical inputs are IAS-51,52; HDG-60,61; VS-54,55; ALT-58,59. I got the script from the OpenCockpits forum, can't remember the original name and not absolutely sure that it worked, but I reordered and renumbered everything to my liking and changed the inputs to match mine. Not sure about "Type" but I'm using 2 bit encoders from OC. There wasn't any type in the script I copied. It never occurred to me to copy the script for the OpenCockpits MCP. Maybe I should start over and do that.

Jerrymc3
08-06-2011, 08:01 PM
David

Guess what! I started over with the OC MCP file and everything is working. Thanks for the tips everyone.

fordgt40
08-07-2011, 04:19 AM
Good news, well done

David