• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

There are problems setting the aileron position (Managed Code C#)

Messages
4
Country
mexico
Greetings! First, I'm a totally newbie developing for FSX, and I'm glad to join to a serious forum like this, I tried looking for the solution by myself in every thread I could in order of not generating a unnecesary Thread, but I did not have an answer :(.

So there is the issue, Setting the aileron position must include a value from 0 to -16000 according to the SimConnect Documentation, so im leaving the code with detailed info in the comments.

private void testinputValues()
{
if (simconnect != null && Simactivo == true)
{
while (true)
{
//!!! Positive Number equals right? negative number equals left? zero equals center !!!
//The Documentation manage a range from -16000 to 0 ( how is it posible :'( ? )
//DATADEFINITION : simconnect.AddToDataDefinition(DATA_DEFINE_ID.AILERON, "AILERON POSITION", null, SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
//ac.aileronpos is a double variable

//Fully Right
ac.aileronpos = 160.00;
simconnect.SetDataOnSimObject(DATA_DEFINE_ID.AILERON, (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 0, ac.aileronpos);
Thread.Sleep(3000);
//Center
ac.aileronpos = 0.00;
simconnect.SetDataOnSimObject(DATA_DEFINE_ID.AILERON, (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 0, ac.aileronpos);
Thread.Sleep(3000);
//FullyLeft
ac.aileronpos = -160.00;
simconnect.SetDataOnSimObject(DATA_DEFINE_ID.AILERON, (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 0, ac.aileronpos);
Thread.Sleep(3000);
}
}


}
So I just have 3 possible states of the yoke (must be 16001), I dont have access to the intermediate values and it is going fully to the right and fully to the left, and the center (so bad for a plane),
so please if you can help me it will be pretty apreciated.

Please feel free to ask for extra info if is it needed.

Thanks in advance!!! :D
 
You almost have it.

First the values are not SIMCONNECT_DATATYPE.FLOAT64. Change them to SIMCONNECT_DATATYPE.FLOAT32

Code:
simconnect.AddToDataDefinition(DEFINITIONS.AILERON, "AILERON POSITION", null, SIMCONNECT_DATATYPE.FLOAT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);

Now make your ac.aileronpos = -16000 to 0

As an edit - I find that setting ac.aileron to -0.8 or +0.8 rather than 16000 will fine tune the aileron position.

So once again the SDK is misleading. (Copy paste errors)

I added three buttons to the form.

Code:
        private void buttonMoveAileron_Click(object sender, EventArgs e)
        {
            //Center
            ac.AileronControl = 0;
            simconnect.SetDataOnSimObject(DEFINITIONS.AILERON, (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 0, ac);
        }

        private void buttonAileronLeft_Click(object sender, EventArgs e)
        {
            //Left
            ac.AileronControl = -0.08f;
            simconnect.SetDataOnSimObject(DEFINITIONS.AILERON, (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 0, ac);

        }

        private void buttonAileronRight_Click(object sender, EventArgs e)
        {
            //Right
            ac.AileronControl = 0.08f;
            simconnect.SetDataOnSimObject(DEFINITIONS.AILERON, (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 0, ac);

        }

It's a quick and dirty example.
 
Last edited:
First of all thanks for your quick response! :D

This is the list of changes that you suggested me and the results:

  • I modified the value type of the struct field to int32.
  • I modified the SIMCONNECT_DATATYPE.FLOAT64 to
    SIMCONNECT_DATATYPE.INT32.
  • Removed the decimals.
The following code had been tested:

Code:
           //Fully Right
                    ac.aileronpos = 0;
                    simconnect.SetDataOnSimObject(DATA_DEFINE_ID.AILERON, (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 0, ac.aileronpos);
                    Thread.Sleep(3000);
                    //Center
                    ac.aileronpos = -8000;
                    simconnect.SetDataOnSimObject(DATA_DEFINE_ID.AILERON, (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 0, ac.aileronpos);
                    Thread.Sleep(3000);
                    //Fully Left
                    ac.aileronpos = -16000;
                    simconnect.SetDataOnSimObject(DATA_DEFINE_ID.AILERON, (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 0, ac.aileronpos);
                    Thread.Sleep(3000);

With this it must work without problems but when I tested it, it only keeps the yoke centered 3 seconds, then it turns to right all the way and keeps the position until the 6 seconds ends...

Am I missing something? :(
 
Last edited:
I changed my post from INT32 to FLOAT32 and use numbers +1.0 to -1.0 the SDK looks wrong. Reread my post.
 
I changed my post from INT32 to FLOAT32 and use numbers +1.0 to -1.0 the SDK looks wrong. Reread my post.
Oh I'm sorry I just came from the university without refreshing the page, but when I posted the reply why your edit did not appear ? So Weird, I'll try your solution instead of the Int32 one. Thanks ! :D
 
Omg!, you're right! without that info probably I'll spend a lot of hours looking for the solution. I just had to return to define the data as FLOAT64 to function, this will be presented on a exposition of the university relative to the Mechatronic engineering and the use of sensors to control (Kinect, for example) anything we want, there are not too many chances of getting your both passions together :D, sure your name will be on the credits, thank you so much! :D (probably i will publish a video on YT about the reactions i think in october)
 
Back
Top