PDA

View Full Version : Rudder Trim Display in Airbus



brianwilliamson
04-11-2014, 08:41 PM
I am trying to get the trim output for the Airbus A321 in FSX to read out on my 4 seven segment digits. With the program I sort of devised !! I have the readouts working in 3 digits but only reading the raw figures which are 0 for the center and 0 to 16384 for the Right and 65537 = (0) to 49153 for Left. There only needs to be one decimal place in the readout which will be fixed. The readout goes from 0 to R20.0 and 0 to L20.0

For those extremes I am reading on the 3 displays 491 to the Left and 163 to the Right, which are the first 3 digits of the raw figures. The 0 reads 000 which I think I can blank first 2 ok.
That is where I am in trouble trying to find out how to convert those numbers to read the 0 to 20.0 correctly.
So I would really appreciate any advice that some of the experts on SIOC can pass on, in this regard.
Many thanks, regards.....................Brian W.



//****************************************************************************
Var 1 Link FSUIPC_INOUT Offset $0C04 Length 2 // RUDDER TRIM VALUE & CONTROL in

FSUIPC
{
v2 = v1 // new value from FSUIPC
}
Var 2
{
v4 = v2 // write to my 3-digit display
}
Var 4 Link IOCARD_DISPLAY Digit 0 Numbers 3 // Display
//*******************************************************************************

Perik
04-12-2014, 03:58 PM
Hello Brian

Here is a piece of code you could try.
I've split up the display in single digits and
I hope you get some ideas from the code. Please adapt to your addressing.
BTW - Remember the Type 1 in "Link FSUIPC_IN" statement. Makes the conversion a lot easier.



//**************************************************************************
// $0C04 Rudder trim value/control: –16383 to +16383
// 16383/X=200, Xmax=81,915, OK so divide by 82 we should be safe.
// I think displayed number will run from -199 to 199.

Var 1 name TRIM_RAW Link FSUIPC_IN Offset $0C04 Length 2 Type 1 // RUDDER TRIM VALUE & CONTROL in FSUIPC

{
L0 = ABS &TRIM_RAW // Get the absolute value

IF &TRIM_RAW < 0 // Check if negative - display (L)eft else display (R)ight
{
&D_TRIMSIGN = -999998 // I set minus sign in the fourth display just to verify.
}
ELSE
{
&D_TRIMSIGN = -999999 // Else blank the sign position
}

// Now start to process the trim-value which is stored in L0
L0 = DIV L0 82 // Now we have max 199 in L0
L1 = MOD L0 10 // Grab right digit (D_TRIM0)
&D_TRIM0 = L1 // and write to display 0 ( the decimal number)

L1 = DIV L0 10 // Grab the middle digit (D_TRIM1)
&D_TRIM1 = MOD L1 10

L1 = DIV L0 100 // Then get the hundreds
IF L1 = 0 // Blank if less than 100 or 10.0 in display
{
L1 = -999999 // blank
}
&D_TRIM2 = L1 // Write the digit.
}


//*******************************************************************************
Var 10 name D_TRIM0 Link IOCARD_DISPLAY Device 0 Digit 0 Numbers 1 // decimal digit
Var 11 name D_TRIM1 Link IOCARD_DISPLAY Device 0 Digit 1 Numbers 1 // next - should also have DP set
Var 12 name D_TRIM2 Link IOCARD_DISPLAY Device 0 Digit 2 Numbers 1
Var 13 name D_TRIMSIGN Link IOCARD_DISPLAY Device 0 Digit 3 Numbers 1 // "L" and "R" or Sign digit

brianwilliamson
04-13-2014, 02:53 AM
Per-Erik, Many thanks for that code. Works like a charm. I would have spent weeks trying to figure out how to convert those numbers !!

I have had the complete IO Cards setup for years on my first build,but changed over to InterfaceIT cards, so was going dispose of the IO Cards. It worked out well for the trim.

Again many thanks......................Brian W.

brianwilliamson
04-20-2014, 01:59 AM
One of the main problems I have is that I do not understand Spanish and most of the instructions to me, leave a lot to be desired.
Well I have spent the last week trying to figure out how to get the 3 momentary buttons working on the Rudder trim. I have had no trouble getting this type of switch to work in FSUIPC but am at a loss woth SIOC. I have studied that many scripts etc., I think I am going blind !!

Var 3 Link IOCARD_SW Input 23 Type P
{
IF v4 = 0
{
v4 = 1
}
ELSE
{
v4 = 0
}
}

Var 4

This is a statement that I tried to figure out but as there are no instructions as to what does what and when, I am unable to understand the next move.

So if anyone can help trying to figure out what I thought would be easy on how to make 3 momentary buttons either send the Rudder SET to 00 and the left and right buttons to change the values for right and left trim I would be extremely grateful. In FSUIPC I have been trying to use $2EC0 with values of 66278 for LEFT and 66379 for Right and 66732 for SET which I presume is 00.

Many thanks...............Brian W.

Perik
04-21-2014, 06:03 PM
Hello Brian.

Let's see if I can help you out with a few SIOC statements.
Not sure if RudderTrim works for your A320 as it seems to differ how
well this is implemented. In the stock A321 (FSX) it seems to work well at least.

And don’t forget to look here for SIOC examples: http://www.lekseecon.nl/howto.html

I’m sure the code can be optimized but for test purposes it should do;)


//*******************************************************************************
//
// 1. Reset Rudder Trim
// 2. Left and right Rudder Trim
// As long as either Left or right momentary switch is pushed
// the according rudder displacement is adjusted with a rate
// of 0,1 (Max deflection is 20) pr. 0,2 second.
// The rate can easily be modified by the timer values.
//
// Reset Rudder
Var 20 name RUDDER_RESET Link IOCARD_SW Input 38 type P //
{
&TRIM_RAW = 0
}
//
// Left Rudder Trim (decrease rudder trim value)
//
Var 21 name RUDDER_LEFT Link IOCARD_SW Input 43 Type I
{
IF &RUDDER_LEFT = 1
{
&TIMER_RUDDER_L = 0 // Set timer to 0 (startvalue)
&TIMER_RUDDER_L = TIMER 1000 1 20 // Trigger at each 0,2s and continue
}
ELSE
{
&TIMER_RUDDER_L = 999 // Stop timer asap
}
}
Var 30 name TIMER_RUDDER_L
{
&TRIM_RAW = &TRIM_RAW - 82
}
//
// Right Rudder Trim (increase rudder trim value)
//
Var 22 name RUDDER_RIGHT Link IOCARD_SW Input 62 Type I
{
IF &RUDDER_RIGHT = 1
{
&TIMER_RUDDER_R = 0
&TIMER_RUDDER_R = TIMER 1000 1 20 // 0,2 second interval from 0 to 1000
}
ELSE
{
&TIMER_RUDDER_R = 999 // Stop timer asap
}
}
Var 31 name TIMER_RUDDER_R
{
&TRIM_RAW = &TRIM_RAW + 82
}

brianwilliamson
04-22-2014, 12:04 AM
Perik, many thanks again for your great help. I am learning slowly !!

I had a problem to start wit which turned out to be a bad IDC connector. As soon as I replaced that and did some mods, all ok. I had to change the Link FSUIPC_INOUT, Offset $0C04 which then worked.


Again you are worth your weight in gold.


Thanks again......................Brian W.

brianwilliamson
04-22-2014, 02:02 AM
Here is a question that one would have thought easy to find the answer, but I am hanged if i can see an answer anywhere.
Basically I am trying to hook up an output from the leds to drive the Decimal Point, which is stated:

"The decimal point of a 7-segment display cannot be controlled via the Opencockpits Display card. You do that via an output of the Master card. Just connect an output (WITHOUT A RESISTOR) directly to the DP pin of the 7-segment display (just a single wire, NO GROUND NEEDED) "


So I put the necessary in to start:

Var 1 Link IOCARD_OUT Device 1 Output 18 // led


Then I tried every variation of things that I could find, but no go. Now I thought this would be simple to turn on the power to led 18 to power up the DPoint, but no......


"Note that you should only assign values 0 or 1 to Var 1. A 1 will imply that the led will lit."

Var 2
{
v1 = 1
}

And so-on .......................but no luck.
Now I think if someone can give me an answer I will feel pretty dumb, but I am exhausted !!!

Help will be a blessing..............................Brian W.

Perik
04-22-2014, 02:31 PM
Brian,

Try this simple line:

Var 1 Link IOCARD_OUT Device 1 Output 18 value 1

It’s an initialization and executes once and Output 18 will stay at 1 as long as
you do not change it deliberately. Your DP should shine without any further coding.

If you want to control the activation of DP as well as the displays – for instance
from Cold&Dark and up, then you need to do a lot more coding.

The missing part in your short script seems to be that you need something to change v2.
v1 will never be executed until v2 is changed.
BTW – I expect you have tested a working DP e.g. from SIOCMonitor.

brianwilliamson
04-23-2014, 02:44 AM
Thank you again for all your help. I have put in that line , but no luck.

I have then just put on its own to test:
Var 2 Link IOCARD_OUT Device 1 Output 18 value 1

But it will not light up. I have checked on the SIOC Monitor and I can light the decimal point from there ok., but not with the program.

Of course I can do it the easy way and just run 5V and a resistor to it, but that will not help with solving my learning !

I will keep fiddling to see if I can spot what I may have done incorrectly.


Again thanks....................Brian W.

Perik
04-23-2014, 04:14 AM
Sorry, Brian

I thought the initialization should work this way as the Sioc compiler
accepted the Value 1 statment at the end. I didn't test the code though :(

The next try will be this: ( still not tested..)



Var 1 name ColdAndDark value 0 // Set the value to current power status
{
IF &ColdAndDark = 1
{
&RUDDER_DP = 0
}
ELSE
{
&RUDDER_DP = 1
}
}

Var 2 name RUDDER_DP Link IOCARD_OUT Output 18

kiek
04-23-2014, 04:15 AM
Hi Brian,

I have then just put on its own to test:
Var 2 Link IOCARD_OUT Device 1 Output 18 value 1

But it will not light up. Are you sure about Device 1, should it not be Device 0?
Nico

brianwilliamson
04-23-2014, 04:17 PM
Per-Erik, ok, you have done it again, works with that script. It has me a little dumbfounded as to how it knows to turn that led on with that text? The first one looks more logical.

Also a big thanks to Nico. I tried the 0 but no change. Now you maybe correct in that, as I am using IOCards USB Expansion & Master card with one Display Card. But as I said I tried the 0 with no result.


Not sure if there are any codes for having a 7 segment print a R or L.


I will play around a bit more with the timing on the read write of the digits, as I suspect I am getting a little jitters on the 1st digit, due to a lag in read and write, but no big problem.(t does not do that with buttons on SIOC)


Will have a crack at writing a script for the Audio panel on the A321 next week, so I more than likely have a few more questions.


Again many thanks to both of you....................Brian W.

kiek
04-23-2014, 05:11 PM
Hi Brian,


Also a big thanks to Nico. I tried the 0 but no change. Now you maybe correct in that, as I am using IOCards USB Expansion & Master card with one Display Card. But as I said I tried the 0 with no result.

It is not related to the number of Master Cards, but to how you have 'coded' your USB Expansion Card in the MASTER statement of your sioc.ini file. It should be the same as the first number after the equal_sign. Read more about it here (http://www.lekseecon.nl/howto.html#device).

In Per-Erik's script also Device 0 is used (while if you are not using the DEVICE attribute, 0 is assumed).

Regards,
Nico

Perik
04-23-2014, 06:51 PM
Hi Brian


It has me a little dumbfounded as to how it knows to turn that led on with that text?

It’s not too difficult. If you again look at Nico’s bible here:
http://www.lekseecon.nl/howto.html#init
and read this and the following chapter about “Flow of Control at startup”, I think you may get it;)
It’s all about going from an unknown value to a known (0 in this case). This transition will
execute the code inside the bracket. It’s more code than necessary as it gives you the option to
start thinking of Cold&Dark.:D


Not sure if there are any codes for having a 7 segment print a R or L.

Are you able to program your own PIC16F876?
If, then I can make a new Hex-code for your DisplayII board giving you the option
to output L and R. The “R” letter will not be perfect though as it will be an “8” with the missing
bottom segment. As an alternative to new firmware you could use 6 outputs from your Mastercard wired to
the 7-segment in the same way as DP and then code in SIOC the correct segments according to “L” and “R”.


I will play around a bit more with the timing on the read write of the digits, as I suspect I am getting a little jitters on the 1st digit, due to a lag in read and write, but no big problem.(t does not do that with buttons on SIOC)

Do you have a RudderTrim gauge running in your FSX panel ?

brianwilliamson
04-24-2014, 12:56 AM
Thanks Nico and Per-Erik, now have combined the lot and working 100 percent.
Will do some more study on Nico's site.

I had some gear to program PICs but have not used it in a long while. Will leave that at the moment and get the Audio panel going.

Per-Erik, yes I have the gauge running perfectly in the FSX airbus, so it has all worked out well.



Look forward to some more advice as I am sure I will find some problems to solve.


Cheers................Brian W.

brianwilliamson
04-26-2014, 01:47 AM
I am having difficulty linking the second part of the equation. As in:
Var 0 Link IOCARD_SW Input 4 Type P
{
IF v1 = 0
{
v1 = 1
}
ELSE
{
v1 = 0
}
}

Var 1 Link IOCARD_OUT Device 0 Output 11 // led

This part:( Var 4 name XXXX Link FSUIPC_IN offset XXXX length y) for which I changed to:


Var 1 Link FSUIPC_IN Offset 3105 Length 1 // Set VOR1 SOUND

as the next line to get the switch to turn on and off the VOR1 Sound. Now I can see I think that there is no way it will rcognise that last statement.

So my question is how do I get a switch to turn on both a led ( which I have OK ) and the sound of the Morse code on the VOR1. There are 2 FSUIPC codes that I see, 3105 or 3122.

I have been studying the Flow control at startup on www.lekseecon., but do not seem to be able to quite get it .


At least I have half working. Not sure how I will string 8 of the same thing together !!



Cheers...........Brian W.

kiek
04-26-2014, 04:02 AM
Var 0 Link IOCARD_SW Input 4 Type P
{
IF v1 = 0
{
v1 = 1
}
ELSE
{
v1 = 0
}
}
Var 1 Link IOCARD_OUT Device 0 Output 11 // led

You should not link (anything) to Var 0.
Use another var number (say 100), and then write
IF V100 = 0

rgrds,
Nico

Perik
04-26-2014, 08:33 AM
Hi Brian

Me again…..;-)

Here is a short script to turn on and off the VOR1 beacon sound.
It seems that A321 don’t read 3105 but rather 3122.
Use FSInterrogate to smoke out what is actually going on…..



//****************************************************************************
// Taken from Pete's Offset list:
// 3122 1 Radio audio switches. Read/write bit settings as follows:
// 2^7 COM1 transmit
// 2^6 COM2 transmit
// 2^5 COM receive both
// 2^4 NAV1 sound
// 2^3 NAV2 sound
// 2^2 Marker sound
// 2^1 DME sound
// 2^0 ADF1 sound
//

Var 1 name NAV1_SOUND Link FSUIPC_INOUT Offset $3122 Length 1


Var 2 name NAV1_SOUND_SW Link IOCARD_SW Input 38 type P
{
&NAV1_SOUND = CHANGEBIT 4 &NAV1_SOUND_SW // Set bit 4 according to switch (0 or 1)
}


I’m a little bit confused as to how the A321 ACP works – could be a simplified simulation in FSX A321.
I thought the CALL bottom in the panel should be the MIC selector and not for beacon activation.
I’m used to B767 and there this function seems to a part of the Volume control.
BTW – which A320 aircraft do you use – default FSX or something else?
Another issue you’ll soon get into is synchronization between your hardware and Sim internals.
We running Level-D B767 are lucky as Nico’s Lekseecon takes care of all the “backoffice” stuff :-)
I can start the rig from a saved flight at FL350 and everything is synchronized.


Now one step back to your RudderTrim and jitter.

As long as you have both your own hardware and the RudderTrim gauge active inside simulator,
you’ll get a race between the those two “writers” as they are not in sync.
When you write to the Offset, the gauge will get the new value and during its transition
from old to new it will update the RudderTrim offset value as well.
These intermediate values will make a lot of “noise” in your SIOC code and the jitters are the result.

To get rid of the noise you need to write at a lower speed than the gauge do or filter out
the change in gauge value completely until its equal to the value set from your SIOC script.

The best would be to get rid of the gauge completely but not sure if that’s possible in your setup.
The Rudder Trim gauge may be a part for a bigger and system depended gauge.

Here is an update of the code to fix the jitter while using the default A321.
Certainly other solutions out there as well but it seems to work.




//****************************************************************************
// $0C04 Rudder trim value/control: –16383 to +16383
// 16383/X=200, Xmax=81,915, OK so divide by 82 we should be safe.
// I think displayed number will run from -199 to 199.

Var 1 name TRIM_RAW Link FSUIPC_INOUT Offset $0C04 Length 2 Type 1 // RUDDER TRIM VALUE to/from FSUIPC

//
// To get rid of intermidiate values from FSX trim gauge.
// We just skip those until the FSX gauge has catched up
// with our value set by SIOC.
// A consequence is that we can not set the trim by the gauge.
//
{
IF &TRIM_RAW = &TRIM_VALUE // Test if current trim value is equal to final value
// If not, do nothing.
{
L0 = ABS &TRIM_RAW // Get the absolute value

IF &TRIM_RAW < 0 // Check if negative - display (L)eft else display (R)ight
{
&D_TRIMSIGN = -999998 // I set minus sign in the fourth display just to verify.
}
ELSE
{
&D_TRIMSIGN = -999999 // Else blank the sign position
}

// Now start to process the trim-value which is stored in L0

L0 = DIV L0 82 // Now we have max 199 in L0
L1 = MOD L0 10 // Grab right digit (D_TRIM0)
&D_TRIM0 = L1 // and write to display 0 ( the decimal number)

L1 = DIV L0 10 // Grab the middle digit (D_TRIM1)
&D_TRIM1 = MOD L1 10

L1 = DIV L0 100 // Last get the hundreds
IF L1 = 0 // Blank if less than 100 or 10.0 in display
{
L1 = -999999 // blank
}
&D_TRIM2 = L1 // Write the most significant 7-segment.
}
}
//*******************************************************************************
Var 10 name D_TRIM0 Link IOCARD_DISPLAY Device 0 Digit 0 Numbers 1 // decimal digit
Var 11 name D_TRIM1 Link IOCARD_DISPLAY Device 0 Digit 1 Numbers 1 // next - should also have DP set
Var 12 name D_TRIM2 Link IOCARD_DISPLAY Device 0 Digit 2 Numbers 1
Var 13 name D_TRIMSIGN Link IOCARD_DISPLAY Device 0 Digit 3 Numbers 1 // Sign


//*******************************************************************************
// Switches for:
// 1. Reset Rudder Trim
// 2. Left and right Rudder Trim
// As long as either Left or right toggle switches ( OFF - (ON) ) is pushed
// the according rudder displacement is adjusted with a rate of 0,1 (Max deflection is 20) pr. 0,2 second.
// The rate can easily be modified by the timer values.
//

// Reset Rudder
Var 20 name RUDDER_RESET Link IOCARD_SW Input 38 type P //
{
&TRIM_VALUE = 0 // Set new value to zero
&TRIM_RAW = &TRIM_VALUE // and send to FSUIPC
}

//
// Left Rudder Trim (decrease rudder trim value)
//

Var 21 name RUDDER_LEFT Link IOCARD_SW Input 43 Type I
{
IF &RUDDER_LEFT = 1
{
&TIMER_RUDDER_L = 0 // Set timer to 0 (startvalue)
&TIMER_RUDDER_L = TIMER 1000 1 20 // Trigger at each 0,2s and continue
}
ELSE
{
&TIMER_RUDDER_L = 999 // Stop timer asap
}
}

Var 30 name TIMER_RUDDER_L
{
&TRIM_VALUE = &TRIM_VALUE - 82 // Decrease by some number
&TRIM_RAW = &TRIM_VALUE // Store the new value and send to FSUIPC
}

//
// Right Rudder Trim (increase rudder trim value)
//

Var 22 name RUDDER_RIGHT Link IOCARD_SW Input 62 Type I
{
IF &RUDDER_RIGHT = 1
{
&TIMER_RUDDER_R = 0
&TIMER_RUDDER_R = TIMER 1000 1 20 // 0,2 second interval from 0 to 1000
}
ELSE
{
&TIMER_RUDDER_R = 999 // Stop timer asap
}
}

Var 31 name TIMER_RUDDER_R
{
&TRIM_VALUE = &TRIM_VALUE + 82 // Increase value
&TRIM_RAW = &TRIM_VALUE // Store and update FSUIPC
}

Var 32 name TRIM_VALUE value 0 // Storage for Trim value set from hardware

brianwilliamson
04-27-2014, 02:06 AM
Once again a big thanks to both Nico and Per-Erik.

All works well now. The audio channels just turn the audio on or off for the Morse ID's and the 2 COMs are a bit different in that I have to turn com1 off before I turn on com2 and visa versa.
So basically it is as it should be.


Have not tried fixing the timing one yet but will do that tomorrow.


The great part about the program is that once you get one going it is easy to do the rest and even better when it combines everything. Great !!



Regards...................Brain W.

brianwilliamson
04-30-2014, 01:18 AM
Just been in the Sim doing the final testing and I am pleased to tell you that it all works perfectly with Jeehell's A320.

Thanks to both Nico and Per-Erik for helping me out with the software learning etc., as I would have been struggling on my own to understand some of it in a short space of time.


Regards...................Brian W.