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

May 13, 2024, 08:42:19 AM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
528 Guests, 1 User
Members
Stats
  • Total Posts: 59,641
  • Total Topics: 7,853
  • Online today: 547
  • Online ever: 831
  • (May 03, 2024, 12:39:25 PM)
Users Online
Users: 1
Guests: 528
Total: 529

COUNTDOWN TO WF2022


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

SIOC programmer needed..

Started by Jay, November 03, 2015, 03:35:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jay

Hi everybody

I have probably chosen wrong topic name, looking for help with my "Simple FFB Yoke"  as from 190 visitors only one person replied..  strange :( 
Anyway I would be very grateful if anyone can help with the code for this project. I can even pay for your time and inconvenience because I really need to have this stage sorted out and move onto mechanical build.
Unfortunately for me there is too much unknown about SIOC coding and I don't have enough time or even intentions to become a programmer because this is only "one off" projects though. 
The application can simply be described as "Airspeed indicator/gauge, driven by OC DCmotors Card"
More detailed description here:

http://www.cockpitbuilders.com/community/index.php?topic=5296.0

Thanks for reading, Jay

Trevor Hale

Hi Jay.

Well this is an interesting post. I think I should maybe help you a little with the way people respond on the board.  If there is someone that needs help with something generally they would describe exactly what they are trying to do and post a little about what they have tried so far and than everyone can try to post a few ideas about what you can maybe try to fix the issue.

For instance.

If I was starting to build a flight simulator and I wanted help getting started, I wouldn't say.

- can someone help me build a 737. 

I would say.

- I would like to start building a 737 and I am going to start with the main instrument panel. Could someone help me find some dimensions or drawings of what you have accomplished.

And you would likely get a better response.

In your case, perhaps you would like someone to provide you with some basic SIOC links to lessons, or maybe someone would post their code so you could look at it and try to figure out how the code works.

If you use the search function on the board and type "SIOC" I guarantee you will see lots of code that may already do what you want it to do.

Perhaps let us know what card you are using. Or maybe let us know how you want the card to work and what function it will provide.

Their aren't many people using SIOC here but I know there is a large SIOC user base at Mycockpit.org if you don't get the result you are looking for here.

I hope this helps you out.

Best regards.

Trev
Trevor Hale

Owner
http://www.cockpitbuilders.com

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

VATSIM:

727737Nut

Jay,
I replied to you via PM, but i will put this out there for anyone else as well. Here is a great link to all the examples of what is capable with SIOC. Below the links is a code for autothrottles that will help you understand what is needed.  You need to have a basic understanding of how it works so that any changes or tweaks that may be needed you will be able to do on your own.  What you are building is not a clear cut program design. Many parameters will have to be considered to reach your design goal.  Response time, feedback error and control Hysteresis etc;  It all comes to play with how you build the mechanical's.  The software can be adjusted to match what you build.
Rob

http://www.opencockpits.com/catalog/info/information.php?info_id=44&cPath=

Quote// *****************************************************************************
// * Config_SIOC ver 3.7B1   -     By Manolo VĂ©lez    -    www.opencockpits.com
// *****************************************************************************
// * FileName : autothrottle.txt
// * Date : 11/05/2010
// * Author: Unknown (if you knows he, please write to info@opencockpits.com)
// *****************************************************************************



Var 1000, Value 0     // Initialisation

Var 0000, name lever2_motor     // Motor control

Var 0001, name lever1_motor, Value 1     // starts program

Var 0002, name elevator_motor     // Motor control

Var 0003, name ENGINENUMBERS, Link FSUIPC_INOUT, Offset $0AEC, Length 2

Var 0049, name motor_stopped1, Value 1     // Lever1

Var 0050, name motor_stopped2, Value 1     // Lever2

Var 0051, name motor_stopped3, Value 1     // Elevator

Var 0022, name AutoThrottle, Link FSUIPC_IN, Offset $07DC, Length 4     // is A/T active?

Var 0023, name Lever2_to_FS, Link FSUIPC_OUT, Offset $0924, Length 2     // Send value of Lever2 to FS

Var 0024, name Lever1_to_FS, Link FSUIPC_OUT, Offset $088C, Length 2     // Send value of Lever1 to FS

Var 0020, name Trim_to_FS, Link FSUIPC_OUT, Offset $0BC0, Length 2     // Send value of PitchTrim to FS

Var 0021, name AP_ALT_hold, Link FSUIPC_IN, Offset $07D0, Length 4     // AutoPilot ALT hold

Var 0029, name AP_APP, Link FSUIPC_IN, Offset $07FC, Length 4     // AutoPilot Glideslope hold

Var 0030, name TOGA, Link FSUIPC_IN, Offset $080C, Length 4     // is TO/GA switch active?

Var 0025, name lever2_diff     // difference where the Lever2 is and where

Var 0026, name lever1_diff     // difference where the Lever1 is and where

Var 0027, name corr_Trim_pos     // Where ElevTrim should be corrected for P

Var 0028, name trim_diff     // difference where the Trim is and where i

Var 0100, name Lever1_upper, Value 135     // Upper potentiometer value of Lever1

Var 0101, name Lever2_upper, Value 130     // Upper potentiometer value of Lever2

Var 0102, name Lever1_idle, Value 30     // Idle potentiometer value of Lever1

Var 0103, name Lever2_idle, Value 31     // Idle potentiometer value of Lever2

Var 0104, name Lever1_lower, Value 8     // Lower potentiometer value of Lever1

Var 0105, name Lever2_lower, Value 11     // Lower potentiometer value of Lever2

Var 0106, name Lever1_factor     // Distance FS / PointPot

Var 0107, name Lever2_factor     // Apply Distance_Pot to Distance FS

Var 0108, name Pot1_factor     // Distance Pot / PointPot

Var 0109, name Pot2_factor     // Apply Distance_Pot to Distance Lever

Var 0013, name Lever1_target, Link FSUIPC_IN, Offset $088C, Length 2     // Where Lever1 should be
{
  L0 = &Lever1_upper - &Lever1_idle     // Upper Potentiomer Value - Idle Potentiom
  L1 = 12800 / L0     // Distance Pot = 128 * 100 becouse no deci
  &Pot1_factor = L1   
  L0 = &Lever1_Pot - &Lever1_idle     // Corrected value from Pot to FS
  L1 = L0 * &Pot1_factor     // apply length lever to pot
  L1 = L1 / 100     // same as above, becouse of no decimal val
  L2 = &Lever1_target / 128     // value from FSUIPC must be adjusted to po
  &lever1_diff = L1 - L2     // where the lever is and where it should b
  IF &AutoThrottle = 1     // A/T is on
  {
    CALL &Motor_Lever1     // subroutine for motor1 motion
  }
  IF &TOGA = 1     // TO/GA switch is on
  {
    CALL &Motor_Lever1     // subroutine for motor1 motion
  }
}

Var 0012, name Lever2_target, Link FSUIPC_IN, Offset $0924, Length 2     // Where Lever2 should be
{
  L0 = &Lever2_upper - &Lever2_idle     // Upper Potentiomer Value - Idle Potentiom
  L1 = 12800 / L0     // Distance Pot = 128
  &Pot2_factor = L1   
  L0 = &Lever2_Pot - &Lever2_idle     // Corrected value from Pot to FS
  L1 = L0 * &Pot2_factor
  L1 = L1 / 100
  L2 = &Lever2_target / 128
  &lever2_diff = L1 - L2
  IF &AutoThrottle = 1     // A/T is on
  {
    CALL &Motor_Lever2     // subroutine for motor2 motion
  }
  IF &TOGA = 1     // TO/GA switch is on
  {
    CALL &Motor_Lever2     // subroutine for motor2 motion
  }
}

Var 0018, name Trim_target, Link FSUIPC_IN, Offset $0BC0, Length 2     // Where Elevator Trim should be
{
  IF &Trim_target > 33000
  {
    L0 = 81918 - &Trim_target     // Trim down (49153 .. 65535)
    L1 = L0 / 128     // 65535 + 16383 = 81918
    L1 = TRUNC L1
  }
  ELSE
  {
    L0 = 16383 - &Trim_target     // Trim up (0 .. 16383)
    L1 = L0 / 128
    L1 = TRUNC L1
  }
  &corr_Trim_pos = L1   
  &trim_diff = &corr_Trim_pos - &Trim_Pot
  IF &AP_ALT_hold = 1     // ALT hold is on
  {
    CALL &Motor_Elevator     // Elevator trim motor motion
  }
  IF &AP_APP = 1     // APP hold is on
  {
    CALL &Motor_Elevator     // Elevator trim motor motion
  }
}

Var 0006, name Lever1_Pot, Link USB_ANALOGIC, Input 1, PosL 0, PosC 127, PosR 254     // Lever1 Pot position
{
  L0 = &Lever1_upper - &Lever1_idle     // Upper Potentiomer Value - Idle Potentiom
  L1 = 16383 / L0     // Distance FS = 16383
  L1 = TRUNC L1
  &Lever1_factor = L1   
  L0 = &Lever1_Pot - &Lever1_idle     // Corrected value from Pot to FS
  L1 = L0 * &Lever1_factor
  L1 = TRUNC L1
  IF &AutoThrottle = 0     // A/T is OFF
  {
    IF &TOGA = 0     // TOGA not aktiv
    {
      &lever1_motor = 0         // motor stops
    }
    IF &ENGINENUMBERS = 2
    {
      &Lever1_to_FS = L1         // Send Lever1 Position to FS
    }
    IF &ENGINENUMBERS = 4
    {
      &Lever1_to_FS = L1         // Send Lever1 Position to FS
      &Lever2_to_FS = L1         // Send Lever2 Position to FS
    }
  }
}

Var 0007, name Lever2_Pot, Link USB_ANALOGIC, Input 2, PosL 0, PosC 127, PosR 254     // Lever2 Pot position
{
  L0 = &Lever2_upper - &Lever2_idle     // Upper Potentiomer Value - Idle Potentiom
  L1 = 16383 / L0     // Distance FS = 16383
  L1 = TRUNC L1
  &Lever2_factor = L1   
  L0 = &Lever2_Pot - &Lever2_idle     // Corrected value from Pot to FS
  L1 = L0 * &Lever2_factor
  L1 = TRUNC L1
  IF &AutoThrottle = 0     // A/T is OFF
  {
    IF &TOGA = 0     // TOGA not aktiv
    {
      &lever2_motor = 0         // motor stops
    }
    IF &ENGINENUMBERS = 2
    {
      &Lever2_to_FS = L1         // Send Lever2 Position to FS
    }
  }
}

Var 0008, name Trim_Pot, Link USB_ANALOGIC, Input 3, PosL 0, PosC 127, PosR 254     // Trim Potentiometer position
{
  L0 = &Trim_Pot * 128
  L1 = 16383 - L0
  IF &AP_ALT_hold = 0     // ALT hold is off
  {
    IF &AP_APP = 0     // APPR mode is off
    {
      &Trim_to_FS = L1   
      &elevator_motor = 0         // motor stops
    }
  }
}

Var 0014, name dead_area1, Value 7     // % error

Var 0015, name break_dist1, Value 13     // points for aproximation break

Var 0016, name current_break1, Value 0     // Speed for motor when whithin break_dista

Var 0017, name current_run1, Value 40     // Speed for motor when running

Var 0048, name current_start1, Value 40     // Speed for motor when starting

Var 0034, name dead_area2, Value 7     // % error

Var 0035, name break_dist2, Value 15     // points for aproximation break

Var 0036, name current_break2, Value 0     // Speed for follow objective

Var 0037, name current_run2, Value 42

Var 0052, name current_start2, Value 42

Var 0044, name margen3, Value 6     // % error

Var 0045, name aprox3, Value 30     // points for aproximation break

Var 0046, name velr3, Value 80     // Speed for motor when small difference

Var 0047, name vell3, Value 90     // Speed for motor when big difference

Var 0120, name Motor_Lever1, Link SUBRUTINE     // USB_DC controls motor for Lever1
{
  L0 = &lever1_diff   
  L1 = 0   
  IF L0 < 0
  {
    L1 = 129   
  }
  L0 = ABS L0
  L2 = &current_run1 + L1
  IF L0 <= &break_dist1
  {
    IF L1 = 0
    {
      L2 = &current_break1 + 129
    }
    ELSE
    {
      L2 = &current_break1   
    }
    IF &motor_stopped1 = 1
    {
      L2 = &current_start1 + L1
      &lever1_motor = L2   
      &motor_stopped1 = 0   
      L2 = &current_run1 + L1
    }
  }
  L0 = ABS L0
  IF L0 <= &dead_area1
  {
    L2 = 0   
    &motor_stopped1 = 1   
  }
  IF &AutoThrottle = 0     // A/T is off
  {
    IF &TOGA = 0     // TOGA not aktiv
    {
      L2 = 0   
      &motor_stopped1 = 1   
    }
  }
  &lever1_motor = L2   
  L0 = &lever2_diff   
  L1 = 129   
  IF L0 < 0
  {
    L1 = 0   
  }
  L0 = ABS L0
  L2 = &current_run2 + L1
  IF L0 <= &break_dist2
  {
    IF L1 = 0
    {
      L2 = &current_break2 + 129
    }
    ELSE
    {
      L2 = &current_break2   
    }
    L2 = &current_break2 + L1
    IF &motor_stopped2 = 1
    {
      L2 = &current_start2 + L1
      &lever2_motor = L2   
      &motor_stopped2 = 0   
      L2 = &current_run2 + L1
    }
  }
  L0 = ABS L0
  IF L0 <= &dead_area2
  {
    L2 = 0   
    &motor_stopped2 = 1   
  }
  IF &AutoThrottle = 0     // A/T is off
  {
    IF &TOGA = 0     // TOGA not aktiv
    {
      L2 = 0   
      &motor_stopped2 = 1   
    }
  }
  &lever2_motor = L2   
}

Var 0125, name Motor_Lever2, Link SUBRUTINE     // USB_DC controls motor for Lever2

Var 0130, name Motor_Elevator, Link SUBRUTINE     // USB_DC controls motor for Elevator
{
  L0 = &trim_diff   
  L1 = 0   
  IF L0 < 0
  {
    L1 = 128   
  }
  L0 = ABS L0
  L2 = &velr3 + L1
  IF L0 <= &aprox3
  {
    L2 = &vell3 + L1
  }
  L0 = ABS L0
  IF L0 <= &margen3
  {
    L2 = 0   
  }
  IF &AP_ALT_hold = 0     // ALT hold is off
  {
    IF &AP_APP = 0     // APPR mode is off
    {
      L2 = 0   
    }
  }
  &elevator_motor = L2   
}
737 Junkie

Jay

Quote from: Trevor Hale on November 04, 2015, 03:56:14 AM
Hi Jay.

Well this is an interesting post. I think I should maybe help you a little with the way people respond on the board.  If there is someone that needs help with something generally they would describe exactly what they are trying to do and post a little about what they have tried so far and than everyone can try to post a few ideas about what you can maybe try to fix the issue.

Hi Trevor

I'm sorry for confusion I thought that the provided link to my other post explains a lot. I do have the same post at MyCocpit websites as well as OpenCockpits but sadly there is similar response as here. You know even my Miss complains about my "ability" explaining things in a most complicated ways  ;D
To be honest I gathered all possible tutorials and examples available in English and keep on reading through them for the past two weeks over and over again. Unfortunately there is still huge gap between what I think is the closest example I could find and what I need from my code.
As I was realising that I can't put this together on my own I started this topic with the intentions to "hire" someone just to write a basic form of the code, bridging the huge gap for me. I thought I could pick up from there and modify the code or add some lines to suit my needs.
Talking of needs, let me try again and explain how it should work.

I've got OC DCmotors card (ver 1.0), one 12V DC motor with gearbox and one potmeter.
I fixed the motor and potmeter onto small testing platform and connected them with two pulleys and a belt. Now when the motor turns it rotates the potmeter. The ratios are not important at the moment because I can alter the code or the hardware when I cross the "gap".

Regarding the SIOC code, here is what I would like it to do for now:
- extract IAS value from FS.
- effective range will be lets say 0 to 160 knots
- ignore changes smaller than 10 knots
- move the motor in appropriate direction and constant speed until the potmeter reaches desired value e.g. (0 knots = pot_value 0, 80 knots = pot_value  128 etc.)
- when IAS above 160knots = motor stops at pot_value 255


I don't know how difficult this task is but any input is very welcome and well appreciated.
Many thanks  Jay

   


FredK

Hi Jay

What you want to do is really very straightforward.  Look at Var0013 and Var0120 in the code that Rob has posted.  If you study the logic flow there you should be able to model your code after what is contained in those two variables.

FredK
Boeing 737NG-800, Prepar3D v4.5, Sim-Avionics 1.964, SimSync multi-channel (curved screen), Optoma 1080GTDarbee projectors (3), Fly Elise warping, FSGRW weather, FDS OH panels and CDUs, SimParts MIP, FDS SysBoards (OH), CPFlight MCPPro and pedestal panels, FI Gauges, PFC controls, converted motorized TQ (SIOC), Weber seats

Jay

#5
Thanks FredK

I think I'm gonna need more clues :o  I started to "extract" certain bits from Rob's example and even I can tell that I'm horribly wrong here.. What do you think, does it make any sense?

//

Var 0, Value 0   // Initialisation

Var 0100, name IAS_upper, Value 255   // Upper potentiometer value

Var 0101, name IAS_lower, Value 0     // Lower potentiometer value

Var 0102, name IAS_factor             // Distance FS / PointPot

Var 0103, name Pot1_factor            // Distance Pot / PointPot


Var 0001, name IAS_target, Link FSUIPC_IN Offset $02BC, length 4   // IAS value from FS
{
L0 = DIV &IAS ,128


Var 0002, name Motor_1, Link USB_DCMOTOR, Output 1

Var 0003, name Pot_1_value, Link USB_ANALOGIC Input 1, PosL 0, PosC128, PosR 255

727737Nut

Jay,
I am not sure how to make it change only on 10Knots difference.  I am sure it is possible but I don't know.  Changes by 1 are easy. 
Rob
737 Junkie

FredK

Hi Jay

Hmmm......

I can write the code for you, but it will have to wait until early December when I am back at home.  I am traveling in a very remote part of the world right now with very sketchy electronic communications.  I do not even have access to a proper computer program to do the text drafting, let alone testing compilation continuity using the SIOC module...using email would be tedious under the circumstances.

So my my suggestion is to keep experimenting with some basic script.  But rest assured I will supply you a solution if you have not figured it out by early December......no compensation required.

Fred K

Boeing 737NG-800, Prepar3D v4.5, Sim-Avionics 1.964, SimSync multi-channel (curved screen), Optoma 1080GTDarbee projectors (3), Fly Elise warping, FSGRW weather, FDS OH panels and CDUs, SimParts MIP, FDS SysBoards (OH), CPFlight MCPPro and pedestal panels, FI Gauges, PFC controls, converted motorized TQ (SIOC), Weber seats

Jay

Quote from: FredK on November 06, 2015, 08:25:42 AM
Hi Jay

Hmmm......

I can write the code for you, but it will have to wait until early December when I am back at home.  I am traveling in a very remote part of the world right now with very sketchy electronic communications.  I do not even have access to a proper computer program to do the text drafting, let alone testing compilation continuity using the SIOC module...using email would be tedious under the circumstances.

So my my suggestion is to keep experimenting with some basic script.  But rest assured I will supply you a solution if you have not figured it out by early December......no compensation required.

Fred K

Thanks Fred,  that's very much appreciated. However when you get back from your travels I'll be heading to very remote part of the world too ;)
Backpacking through SE Asia for three months, that's why I'm so "pushy" about this project though 8)
Anyway regardless of the timing I'll be very grateful if you could help, when you get back of course.

Enjoy the rest of your travels, Jay

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