Welcome to Cockpitbuilders.com. Please login or sign up.

March 01, 2021, 08:28:15 PM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
21 Guests, 2 Users
Members
Stats
  • Total Posts: 56778
  • Total Topics: 7558
  • Online Today: 38
  • Online Ever: 582
  • (January 22, 2020, 08:44:01 AM)
Users Online
Users: 2
Guests: 21
Total: 23

COUNTDOWN TO WF2021


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

737-200 AP trim wheel motor

Started by dc8flightdeck, March 05, 2013, 12:49:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dc8flightdeck

March 05, 2013, 12:49:22 PM Last Edit: March 07, 2013, 01:46:45 PM by dc8flightdeck
Im looking for a way to drive a trim wheel motor. The motor is connected to two relays, one for each direction. Pressing a yoke trim switch activates a relay to drive the motor.

Any ideas for an FSUIPC AP elevator offset I can use as a ON/OFF toggle for the relays? And how would I program it in SIOC for the USB Outputs card?

Thanks!

Here is a video link showing a first test of the FD lights via an Outputs card, SIOC, and FSX.
737 Flight Director Lights

fordgt40

March 05, 2013, 01:40:51 PM #1 Last Edit: March 06, 2013, 01:13:58 AM by fordgt40
A broad outline of the logic to convert the trim values into motor direction is roughly

Define a Null zone variable to avoid "hunting"

Trim variable from FSUIPC
If trim value is negative
   If trim value < previous trim value
      Direction = down
   Else direction = up
Trim movement = Trim value minus previous trim value
trim movement = ABS trim movement

If trim value is positive
   If trim value > previous trim value
      Direction = up
   Else direction = down
Trim movement = Trim value minus previous trim value
trim movement = ABS trim movement


Direction variable
If trim movement > null zone
   If direction = up
      Turn on output for up
      turn off output for up after a suitable delay - use the DELAY function
   Else
      Turn on output for down
      turn off output for down after a suitable delay - use the DELAY function

Note you could test the value of trim movement and use a variable argument to the DELAY function to vary the delay in turning off the motor according to the value of the trim movement


The FSUIPC Offset for the elevator trim position is 0BC0

Hope this helps

David

Edit

Justin. I just realised you asked the same question on mycockpit.org last year and got this same reply! Sorry for duplication, however, presumably you did not see the reply as there was no response? Do you need further help?

dc8flightdeck

I can see the script required is a bit beyond my comprehension of SIOC so I think I will just wait to tackle the AP trim at a later time.

Thanks for the reply David.

fordgt40

Justin

Why not try some simple parts of the code first and see what happens using the iocpconsole? The logic I have given is almost sioc code anyway, without the brackets and correct syntax.

I can fully understand the reluctance, but honestly, if you start to get your "feet wet", it is quite rewarding.

Regards

David

MLeavy737

 Just curious, why don't you just run the trim wheels when you press the trim switch? In that way you wouldn't need any code. Press up or down and the circuit runs the wheel accordingly.
I don't think you need to talk to FS at all.  In other words use the trim switches as ON-OFF switches.

Mike L
The 737 800/900... Fastest airplane with the gear down!

Boeing Skunk Works

Unless it's a DPDT switch, the problem is telling FS you need trim and running electricity through the same switch.

That was a problem I encountered with the original Cole's trim switch in my Boeing yoke. It is a DPDT switch, but they are wired in series so that both switches have to be pressed for the signal to pass.
Why yes...I am a rocket scientist...

Boeing, Collins, Gables, Sperry, PPG, Korry, Pacific Scientific, Honeywell

dc8flightdeck

Quote from: Boeing Skunk Works on March 06, 2013, 07:48:23 AM
Unless it's a DPDT switch, the problem is telling FS you need trim and running electricity through the same switch.

That was a problem I encountered with the original Cole's trim switch in my Boeing yoke. It is a DPDT switch, but they are wired in series so that both switches have to be pressed for the signal to pass.

That is not a problem for me because I have the yoke trim buttons wired with 12v DC  to trigger two DP relays. Push the trim up and the up relay energizes which runs the trim motor one direction and  the other relay poll simultaniously sends a trim button command through a KE-108 for the interface to FSX. The end result is that both yoke trim buttons have to be pressed for the AP trim to work which of course is how it should be.

(On a side note Ive though about disconnecting the  button circuit from the relay to the KE-108 and installing a rotary switch to the trim wheels instead. When the motor spins the trim wheel that would send a directional command via the rotary SW to FSX, plus the same would happen if the wheel is moved manually. My current configuration doesnt allow for manual wheel operation).

Mike, the current configuration works exactly as you described. However, If I were to simply use two outputs from the OC Outputs card to trigger the relays I can use the AP offset via the outputs card to run my trim motor when AP is turned on. This would be a very nice feature and would be _very simple_ for me to wire the circuit to make happen. Its my (in)ablility to write more sophisticated SIOC script that is the issue.

I have the cuttoff switch on the 737-200 TQ wired to manually cutoff the motor which adds even more realism.

You can see a clip of the trim wheels spinning in this video of it from 2010
737-200.wmv

The trim indicator is independently driven by a servo so I its always in the correct position.

MLeavy737

Justin,
  Lol, after I posted my trim wheel comment I watched your Blue Angels Sim video and though theres no way he didn't already think of that lol!  It looks like you can do pretty much anything with a sim! Nice Work :)

Mike L
The 737 800/900... Fastest airplane with the gear down!

dc8flightdeck

Thanks Mike. I'm like everyone else, I have specific areas that Im good at and need help with the rest :)

That being said, after the success with SIOC yesterday for other functions, I changed my mind today and decided to try the auto pilot. This is using the elevator position offset. Below is my first stab at turning David's outline into script. Please feel free to jump in and fills some blanks, I left plenty for everyone :)

If we can make this work it will be an easy way for folks to interface an AutoPilot controlled motorized 737 trim wheel.

Justin

****************************************************************************

Define a Null zone variable to avoid "hunting"

Var 0001, name Trim, static, Link FSUIPC_IN, Offset $0BC0, Length 2 //  Elevator trim control input: –16383 to +16383
{
IF Trim <                              //  If trim value is negative
{
If trim value <                     //  previous trim value
{
Direction = down

}
    ELSE
{
direction = up
{
Trim movement = Trim value minus previous trim value
{
trim movement = ABS trim movement


{
IF Trim >               //  If trim value is positive
{
If trim value > previous trim value
{
Direction = up
}
    ELSE
{
direction = down
{
Trim movement = Trim value minus previous trim value
{
trim movement = ABS trim movement



{
Direction variable

If trim movement > null zone
{
If direction = up
{
&up =  CHANGEBIT 0 1
    v0004 = DELAY 0 100    //  run for 1 seconds.  turn off output for up after a suitable delay - use the DELAY function
}
    ELSE
{
&down = CHANGEBIT 0 1
    v0005 = DELAY 0 100   //  turn off output for down after a suitable delay - use the DELAY function
}
}
}

Var 0004, name up, Link IOCARD_OUT, Output 1                 // toggles the up relay
Var 0005, name down, Link IOCARD_OUT, Output 2              // toggles the down relay

fordgt40

March 08, 2013, 05:12:05 AM #9 Last Edit: March 08, 2013, 07:45:27 AM by fordgt40
Justin

I have filled in the "blanks" and tidied up the code/syntax. It now compiles ok, but I have not tested it as I need to finish my MIP  :)
Suggest you read and step through my code to understand what is happening and why. Then try it and use the IOCPConsole (accessed from the main SIOC window) to follow through what is happening to the logic flow and variable values. The "log" function within IOCPConsole is also useful for tracing. Basically, by using these tools you can see what is and is not happening compared to what is expected :(

Code rarely works first time!!!
If, after trying the above, it does not work and/or you cannot work out why then post back here saying where it is wrong and I will look at it again

// *******************************************************************************************
// Trim wheel direction logic
// David J Bullock  8/3/2013
// ********************************************************************************************

var 0
{
&old_trim_val = 0 // var 0 is a special function that runs the code attached to it ONCE ONLY at startup. So you can use it to initialise variables
&null_zone = 50  // experiment with this number to avoid constant small movements, the greater the number the less movement there is and vice versa
}

Var 0001, name trim_up, Link IOCARD_OUT, Output 1       // toggles the up relay
Var 0002, name trim_down, Link IOCARD_OUT, Output 2     // toggles the down relay
var 0003, name trim_dist            // distance new trim has to move
var 0004, name old_trim_val            // store old trim value here
var 0005, name null_zone            // null zone to stop "hunting"



Var 0006, name trim_val, Link FSUIPC_IN, Offset $0BC0, Length 2 //  Elevator trim control input: –16383 to +16383
{
IF &trim_val < 0                               //  If trim value is negative
   {
   If  &trim_val < &old_trim_val                   //  previous trim value
      {
      &direction = -1            // going down
      }
       ELSE
      {
      &direction = 1            // going up
      }

   &trim_dist = &trim_val - &old_trim_val
   &trim_dist = ABS &trim_dist
   }

IF &trim_val > 0                          //  If trim value is positive
   {
   If &trim_val > &old_trim_val
      {   
      &Direction = 1
      }
     ELSE
      {
       &Direction = -1
      }
   &trim_dist = &Trim_val - &old_trim_val
   &trim_dist = ABS &trim_dist
   }
}

var 0007, name direction            // value 1 is up, value -1 is down
{
IF  &trim_dist > &null_zone
   {
   If &direction = 1
      {
      &trim_up =  1
          &trim_up = DELAY 0 100        //  run for 1 second,then turn off output for up.
      &direction = 0           // reset direction flag
   }
   If &direction = -1
      {
      &trim_down = 1
        &trim_down = DELAY 0 100      //  run for 1 second, then turn off output for down.
      &direction = 0          // reset direction flag
      }
   }
&old_trim_val = &trim_val
}

Regards

David

dc8flightdeck

March 11, 2013, 08:18:32 AM #10 Last Edit: March 11, 2013, 03:36:27 PM by dc8flightdeck
Thanks David.

It appears the scrip triggers outputs by moving past the center position. Positive movement past center causes a single 1 second output, negative movement past center causes a single 1 second output.

For the heck of it I tried the 0BC2 2 Elevator trim indicator (follows input) offset. It gave identical results. Apparently it uses identical values as the Elevator trim control input: –16383 to +16383.

fordgt40

Justin

Ok, I will look at it tomorrow - it would be a miracle to get it right first time, though debugging often takes more time than initially writing :(

Regards

David

fordgt40

Justin

A few minor tweaks and it runs. However, it is far too quick, so I need to recode it to sample the trim value every few seconds

David

dc8flightdeck


fordgt40

Hi Justin, here is the revised code. I have tested it on fsx default 737 and it seems to work ok, only of course when the AP is engaged :)

I do not guarantee that it has no bugs and I should test it for a while before hooking up anything to the outputs. I had to change the coding to poll the trim value every half a second, else it went so fast that it was impossible to set an output! Just beware that when I was testing it I found it was possible to have both up and down outputs on at the same time. This was because of the polling and the delay function built in to keep an output on for at least a second - I think I have cured this by amending the delay function but just be careful. I will not accept any responsibility for any problems/damage :(

You can fine tune it by changing the null_zone value, greater values will give less response and vice versa.
You could also introduce some code to use the trim_dist value to increase the time that the output is "on" ie the greater the value the longer the DELAY to turn off the output.

Regards

David

// *******************************************************************************************
// Trim wheel direction logic
// David J Bullock  17/3/2013
// ********************************************************************************************

var 0  Value 0
{
&old_trim_val = 0 // var 0 is a special function that runs the code attached to it ONCE ONLY at startup. So you can use it to initialise variables
&direction = 0
&poll_trim = 0
&poll_trim = TIMER 1 0 50 // the value of 50 = 500 millisecs ie 10 miilsecs x 50
}
Var 0001, name trim_up, Link IOCARD_OUT, Output 1       // toggles the up relay
Var 0002, name trim_down, Link IOCARD_OUT, Output 2     // toggles the down relay
var 0003, name trim_dist            // distance new trim has to move
var 0004, name old_trim_val            // store old trim value here
var 0005, name null_zone   value 5         // experiment with this number to avoid constant small movements, the greater the number the less movement there is and vice versa

Var 0006, name trim_val, Link FSUIPC_INOUT, Offset $0BC2, Length 2  type 1 //  Elevator trim control input: –16383 to +16383

Var 007 name poll_trim Link Subrutine
{
IF &trim_val < 0                               //  If trim value is negative
   {
   If  &trim_val < &old_trim_val                   //  previous trim value
      {
      &direction = -1            // going down
      }
       ELSE
      {
      &direction = 1            // going up
      }

   &trim_dist = &trim_val - &old_trim_val
   &trim_dist = ABS &trim_dist
   }

IF &trim_val > 0                          //  If trim value is positive
   {
   If &trim_val > &old_trim_val
      {   
      &Direction = 1
      }
     ELSE
      {
       &Direction = -1
      }
   &trim_dist = &Trim_val - &old_trim_val
   &trim_dist = ABS &trim_dist
   }
&old_trim_val = &trim_val
IF  &trim_dist > &null_zone
   {
   If &direction = 1
      {
      &trim_up =  1
          &trim_up = DELAY 0 200        //  run for 2 second,then turn off output for up.
      &direction = 0           // reset direction flag
   }
   If &direction = -1
      {
      &trim_down = 1
        &trim_down = DELAY 0 200      //  run for 2 second, then turn off output for down.
      &direction = 0          // reset direction flag
      }
   }

}

var 0008, name direction            // value 1 is up, value -1 is down

dc8flightdeck

I increased the polling time to be longer than the delay function and that seamed to cure the issue of both outputs randomly toggling at the same time. It works nicely and I will post video once the sim is back together.

The only other issue is that when I turn off the AP and use manual trim, the manual trim does toggle the output script from time to time. I will see if can use a master switch in the AP panel to physically cut off the output card wires when AP is disengaged to ensure there is no electrical crossover when the the manual yoke trim switches are engaged.

Thanks again, this will look great in the cockpit :)

fordgt40

Justin

SIOC is more powerful than people realise :)
I have amended the script so that the outputs are only triggered when the AP is engaged. Not able to test it with a manual trim input, but should work ok

David

// *******************************************************************************************
// Trim wheel direction logic
// David J Bullock  17/3/2013
// ********************************************************************************************

var 0  Value 0
{
&old_trim_val = 0 // var 0 is a special function that runs the code attached to it ONCE ONLY at startup. So you can use it to initialise variables
&direction = 0
&poll_trim = 0
&poll_trim = TIMER 1 0 50 // the value of 50 = 500 millisecs ie 10 miilsecs x 50
}
Var 0001, name trim_up, Link IOCARD_OUT, Output 1       // toggles the up relay
Var 0002, name trim_down, Link IOCARD_OUT, Output 2     // toggles the down relay
var 0003, name trim_dist            // distance new trim has to move
var 0004, name old_trim_val            // store old trim value here
var 0005, name null_zone   value 5         // experiment with this number to avoid constant small movements, the greater the number the less movement there is and vice versa

Var 0006, name trim_val, Link FSUIPC_INOUT, Offset $0BC2, Length 2  type 1 //  Elevator trim control input: –16383 to +16383

Var 007 name poll_trim Link Subrutine
{
IF &AP_state = 1
{
IF &trim_val < 0                               //  If trim value is negative
   {
   If  &trim_val < &old_trim_val                   //  previous trim value
      {
      &direction = -1            // going down
      }
       ELSE
      {
      &direction = 1            // going up
      }

   &trim_dist = &trim_val - &old_trim_val
   &trim_dist = ABS &trim_dist
   }

IF &trim_val > 0                          //  If trim value is positive
   {
   If &trim_val > &old_trim_val
      {   
      &Direction = 1
      }
     ELSE
      {
       &Direction = -1
      }
   &trim_dist = &Trim_val - &old_trim_val
   &trim_dist = ABS &trim_dist
   }
&old_trim_val = &trim_val
IF  &trim_dist > &null_zone
   {
   If &direction = 1
      {
      &trim_up =  1
          &trim_up = DELAY 0 200        //  run for 2 second,then turn off output for up.
      &direction = 0           // reset direction flag
   }
   If &direction = -1
      {
      &trim_down = 1
        &trim_down = DELAY 0 200      //  run for 2 second, then turn off output for down.
      &direction = 0          // reset direction flag
      }
   }

}
}

var 0008, name direction            // value 1 is up, value -1 is down

Var 0009 name AP_state Link FSUIPC_INOUT offset $07BC length 4

dc8flightdeck

That worked :)

Is there an online SIOC database to place script like this? That would be a great resource and save people from continuously reinventing the wheel.

Jetcos

Is there a pun in there?

"save people from continuously reinventing the wheel"  (Trim Wheel?)
Steve Cos
Flightdeck Solutions, Newmarket Ontario,Canada
Special Projects and Technical Support

dc8flightdeck

Hello, here is a video update that includes footage of the above Autopilot script driving the trim wheel. There have been new updates since this video was shot, such as the solenoid interface of the Cole start switches. Enjoy!
Justin

737 2013 Update 1

Trevor Hale

Quote from: dc8flightdeck on March 19, 2013, 09:34:16 AM
Is there an online SIOC database to place script like this? That would be a great resource and save people from continuously reinventing the wheel.

Thats what you have done.

Now when people come here and use the search tool, they will find this script :)
Trevor Hale

Owner
http://www.cockpitbuilders.com

Director of Operations
Worldflight Team USA
http://www.worldflightusa.com

VATSIM:

AVIATor-Olav

Quote from: dc8flightdeck on July 03, 2013, 08:58:15 AM
Hello, here is a video update that includes footage of the above Autopilot script driving the trim wheel. There have been new updates since this video was shot, such as the solenoid interface of the Cole start switches. Enjoy!
Justin

737 2013 Update 1


Awesome job you've done with that thing! What flight model are you using?

dc8flightdeck

thank you. Im using the default FSX 737 on the server, and Captainsim 737-200 on the clients. When I tried Captinsim on the server pc I found that it had systems (like the battery switch) that only respond to mouse clicks  :'(

AVIATor-Olav

Wow, I'm amazed at how much system simulation you've managed to do with the CS software! I use the DF727 in my sim. Lots of switches are configureable with FSUIPC offsets, while many others are assigned using the mouse macro function. It only toggles the switches, but it works just fine for me. My flight and engine instruments are all on LCD's, I wish I had all the steam guages working like you do!! Looks absolutely great! I've aquired a complete engineer panel for my 727, I hope to start work on it soon.

Like the Website ?
Support Cockpitbuilders.com and Click Below to Donate