Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 2
  • *Guests: 56
  • *Total: 58

Our Discord

WORLDFLIGHT 2018 - TEAM USA SUPPORTERS (HERO'S)


We would like to thank our HERO'S for Donating to support WORLDFLIGHT Team USA - 2018

-Sam LLorca, Fred Kurasiewicz, Ray Sotkiewicz, Warren Soeldner  -
  -
Kyle Hathaway, John Miller, John Combs, Karen Combs, Mick Cliffe, John Ziegler, Vincent Thomas -
- Roy Stewart, Joe Lavery, Dr. Steve Eisenberg, Les Barwick, Doug Snow, Greg Hembree -
- James Williams, Edwin Burton Jasper Koelewijn, James Twomey, John Skibo, Trevor Hale -

- Jason Garrett, Scott Wegner, Frank Radl, Ryan O'Keefe, David Bullock, Bob Reed, Don Emersoln, Lisa Lopez-Floriano -
- Shawn Hathaway, Jason Lohrenz, James Reilly, William McSwain David Otey, Mike Sherick -


Ruscool Electronics Intercom #1 - Won by GyverX
Ruscool Electronics Intercom #2 - Won by dj_Boelie
Ruscool Electronics Intercom #3 -Ryan O'Keefe
Geetech A10 3D printer - James Twomey

Thanks to all of you, You all made Worldflight 2018 a success..
Because of all you wonderful people we raised a total of:

$4,100.00 USD


Author Topic: Teensy LC Hydralic Panel  (Read 200 times)

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,082
  • 737 -mixed year OEM panel builder.
  • First Name: Peter
  • Home Location: Gothenburg
Teensy LC Hydralic Panel
« on: October 10, 2018, 04:52:42 PM »
Hi!

Here is my sketch for my Haudralic panel for the Zibo 737 and X-Plane 11 using Teensy LC.


const int PIN_5V_BACKLIGHT = 6;
const int PIN_KORRY_PUSH_TO_TEST = 4;

const int PIN_KORRY_LIGHT_ELEC_LOW_PRESSURE_1 = 3;
const int PIN_KORRY_LIGHT_ELEC_LOW_PRESSURE_2 = 23;
const int PIN_KORRY_LIGHT_ELEC_OVERHEAT_1 = 22;
const int PIN_KORRY_LIGHT_ELEC_OVERHEAT_2 = 17;
const int PIN_KORRY_LIGHT_ENG_LOW_PRESSURE_1 = 16;
const int PIN_KORRY_LIGHT_ENG_LOW_PRESSURE_2 = 20;

const int PIN_SWITCH_ENGINE_1 = 15;
const int PIN_SWITCH_ENGINE_2 = 19;
const int PIN_SWITCH_ELEC_1 = 18; //Check these, the ground might be touching
const int PIN_SWITCH_ELEC_2 = 21; //check these, the ground might be touching

FlightSimFloat xPlane_light_elec_low_pressure_1;
FlightSimFloat xPlane_light_elec_low_pressure_2;
FlightSimFloat xPlane_light_eng_low_pressure_1;
FlightSimFloat xPlane_light_eng_low_pressure_2;
FlightSimFloat xPlane_light_el_hyd_ovht_1;
FlightSimFloat xPlane_light_el_hyd_ovht_2;

FlightSimFloat xPlane_engine1_pos;
FlightSimFloat xPlane_engine2_pos;
FlightSimFloat xPlane_elec1_pos;
FlightSimFloat xPlane_elec2_pos; 

FlightSimFloat xPlane_panel_brightness_ratio_manual;

void setup() {
 
  xPlane_engine1_pos = XPlaneRef("laminar/B738/toggle_switch/hydro_pumps1_pos");
  xPlane_engine2_pos = XPlaneRef("laminar/B738/toggle_switch/hydro_pumps2_pos");
  xPlane_elec1_pos = XPlaneRef("laminar/B738/toggle_switch/electric_hydro_pumps1_pos");
  xPlane_elec2_pos = XPlaneRef("laminar/B738/toggle_switch/electric_hydro_pumps2_pos");

  xPlane_light_elec_low_pressure_1 = XPlaneRef("laminar/B738/annunciator/hyd_el_press_a");
  xPlane_light_elec_low_pressure_2 = XPlaneRef("laminar/B738/annunciator/hyd_el_press_b");
  xPlane_light_eng_low_pressure_1 = XPlaneRef("laminar/B738/annunciator/hyd_press_a");
  xPlane_light_eng_low_pressure_2 = XPlaneRef("laminar/B738/annunciator/hyd_press_b");
  xPlane_light_el_hyd_ovht_1 = XPlaneRef("laminar/B738/annunciator/el_hyd_ovht_1");;
  xPlane_light_el_hyd_ovht_2 = XPlaneRef("laminar/B738/annunciator/el_hyd_ovht_2");;

  xPlane_panel_brightness_ratio_manual = XPlaneRef("sim/cockpit2/electrical/panel_brightness_ratio_manual[2]");
   
  pinMode(PIN_5V_BACKLIGHT,OUTPUT);
  pinMode(PIN_KORRY_PUSH_TO_TEST,OUTPUT);
 
  pinMode(PIN_KORRY_LIGHT_ELEC_LOW_PRESSURE_1,OUTPUT);
  pinMode(PIN_KORRY_LIGHT_ELEC_OVERHEAT_1,OUTPUT);
  pinMode(PIN_KORRY_LIGHT_ENG_LOW_PRESSURE_2,OUTPUT);
  pinMode(PIN_KORRY_LIGHT_ELEC_OVERHEAT_2,OUTPUT);
  pinMode(PIN_KORRY_LIGHT_ENG_LOW_PRESSURE_1,OUTPUT);
  pinMode(PIN_KORRY_LIGHT_ELEC_LOW_PRESSURE_2,OUTPUT);
 
  pinMode(PIN_SWITCH_ENGINE_1,INPUT_PULLUP);
  pinMode(PIN_SWITCH_ENGINE_2,INPUT_PULLUP);
  pinMode(PIN_SWITCH_ELEC_1,INPUT_PULLUP);
  pinMode(PIN_SWITCH_ELEC_2,INPUT_PULLUP);
}

void loop() {
  FlightSim.update();   

  analogWrite(PIN_5V_BACKLIGHT,mapfloat(xPlane_panel_brightness_ratio_manual, 0,1,0,255));
  analogWrite(PIN_KORRY_PUSH_TO_TEST,255);

  analogWrite(PIN_KORRY_LIGHT_ELEC_OVERHEAT_1,mapfloat(xPlane_light_el_hyd_ovht_1,0,1,0,255));
  analogWrite(PIN_KORRY_LIGHT_ELEC_OVERHEAT_2,mapfloat(xPlane_light_el_hyd_ovht_2,0,1,0,255));

  analogWrite(PIN_KORRY_LIGHT_ELEC_LOW_PRESSURE_1, mapfloat(xPlane_light_elec_low_pressure_1,0,1,0,255));
  analogWrite(PIN_KORRY_LIGHT_ELEC_LOW_PRESSURE_2, mapfloat(xPlane_light_elec_low_pressure_2,0,1,0,255));
 
  analogWrite(PIN_KORRY_LIGHT_ENG_LOW_PRESSURE_1, mapfloat(xPlane_light_eng_low_pressure_1,0,1,0,255));
  analogWrite(PIN_KORRY_LIGHT_ENG_LOW_PRESSURE_2, mapfloat(xPlane_light_eng_low_pressure_2,0,1,0,255));

  //Fix why these dont align up after restarting teensy, strange!

  if (digitalRead(PIN_SWITCH_ELEC_1) == HIGH && xPlane_elec1_pos != 1) {
    xPlane_elec1_pos = 1;
  }
  if (digitalRead(PIN_SWITCH_ELEC_1) == LOW && xPlane_elec1_pos != 0) {
    xPlane_elec1_pos = 0;
  }
  if (digitalRead(PIN_SWITCH_ELEC_2) == HIGH && xPlane_elec2_pos != 1) {
    xPlane_elec2_pos = 1;
  }
  if (digitalRead(PIN_SWITCH_ELEC_2) == LOW && xPlane_elec2_pos != 0) {
    xPlane_elec2_pos = 0;
  }
  if (digitalRead(PIN_SWITCH_ENGINE_1) == HIGH && xPlane_engine1_pos != 1) {
    xPlane_engine1_pos = 1;
  }
  if (digitalRead(PIN_SWITCH_ENGINE_1) == LOW && xPlane_engine1_pos != 0) {
    xPlane_engine1_pos = 0;
  }
  if (digitalRead(PIN_SWITCH_ENGINE_2) == LOW && xPlane_engine2_pos != 1) {
    xPlane_engine2_pos = 1;
  }
  if (digitalRead(PIN_SWITCH_ENGINE_2) == HIGH && xPlane_engine2_pos != 0) {
    xPlane_engine2_pos = 0;
  }

  //put a small delay here otherwise the processing is so fast. Lots of read/write that dont have to be so fast.
  delay(20);
}

float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

Offline archen

  • Forum GURU
  • *
  • Posts: 309
  • Aviation Enthusiast
    • Anders Simparts
  • First Name: Anders
  • Home Location: Falun
Teensy LC Hydralic Panel
« Reply #1 on: October 14, 2018, 05:17:53 AM »
Hey Peter,
Looking at your code it looks like you control the brightness of the annunciator with a dataref related to some kind of lightning control knob in the Zibo aircraft. Is that correctly understood?

Are you limited to use the analog pins of the teensy? Are all the annunciators connected through a ULN2803A?

BR.
Anders

Skickat från min SM-G955F via Tapatalk

------------
Anders Simparts
http://www.anderssimparts.com
https://www.facebook.com/ArchenSimparts
Selling "Hard-to-get" simparts like authentic Engine starters, Autobrake, IRS mode selectors and N1&SPD Ref Switches.
------------

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,082
  • 737 -mixed year OEM panel builder.
  • First Name: Peter
  • Home Location: Gothenburg
Re: Teensy LC Hydralic Panel
« Reply #2 on: October 18, 2018, 08:38:50 AM »
Yes, its controlled by the dataref of the backlight.
Advantages with this is that you dont have to link backlight and the know by hardware / cables.
Just torn the know and read the values from the Logic in X-Plane. Great.

You prob know this now,

I am limited when it comes to the large panels, but with our PCB i plan to use double PCB and 4 ULN2803A. Then the pins and ULN2803A should be enough. =)

 

Recent Posts

New Paint for N38AK
by Trevor Hale
[Today at 09:02:53 AM]
boeing overhead circuit breaker back light panel wiring
by jackpilot
[Today at 08:44:05 AM]
Problems with Wideview or Wide Traffic with Pre3DV3
by ZK CWD
[November 20, 2018, 08:46:05 PM]
The Progression of a build [Phase One]
by GyverX
[November 20, 2018, 05:03:33 PM]
For sale! B737 home cockpit - mostly OEM parts!
by Flightdeck57
[November 20, 2018, 01:30:16 PM]
B737 MIP and Overhead gauges
by csp
[November 20, 2018, 10:25:31 AM]
737-800 Arduino X-Plane Build
by kurt-olsson
[November 20, 2018, 08:46:30 AM]
What have you done for your simulator today?
by navymustang
[November 19, 2018, 06:14:09 PM]
Boeing 737-800 NG Wet Compass -1:1 Replica (P3D, Xplane, FSX)
by Reensel
[November 19, 2018, 04:04:32 PM]
Goflight 166 radios and power issue
by Steenos
[November 19, 2018, 12:44:19 PM]
Join me on Vatsim Tonight
by Trevor Hale
[November 18, 2018, 02:00:41 PM]
Mickey's Flightdeck - A Boeing 737-800 Cockpit on Youtube
by Extraterra
[November 18, 2018, 07:54:30 AM]
WARNING do not trade with Flyengravity
by fairchild
[November 17, 2018, 12:35:28 PM]
95% finished Diamond DA62 build
by Bob Reed
[November 17, 2018, 09:19:13 AM]
P3dV4 install to F:
by Ed
[November 17, 2018, 06:54:54 AM]
6 Years already
by blueskydriver
[November 16, 2018, 03:02:47 PM]
For Sale Saitek modules, Commercial Package, Rrice Reduce
by fairchild
[November 16, 2018, 01:10:09 PM]
CockpitSimParts 737 MIP & FWD OVH
by Bob Reed
[November 16, 2018, 10:09:42 AM]
Updating Navigraph FMC Data - Project Magenta / ProSim
by Bob Reed
[November 16, 2018, 09:39:55 AM]
New supplier for your sim
by Fcoq
[November 15, 2018, 07:34:05 PM]
Honeywell 737 ISDU Unit - Pinout for Canon Plugs
by mickc
[November 15, 2018, 06:12:59 PM]
Notice to those who won the intercoms from Ruscool during Worldflight 2018
by RayS
[November 14, 2018, 06:28:58 PM]
B737 Desktop sim project
by archen
[November 14, 2018, 03:48:11 PM]
Keep losing both engines and all power. Help
by mdavenport
[November 13, 2018, 04:15:35 PM]
For Sale-Real Cockpit Gauges...
by blueskydriver
[November 12, 2018, 09:16:00 PM]
For Sale GoFlight Jet Console, 2 Private Pilot Racks all with GoFlight Modules.
by blueskydriver
[November 12, 2018, 09:09:08 PM]
Rudder trim
by Mach7
[November 12, 2018, 07:54:17 AM]
WorldFlight - CockpitBuilders DAL209 Progress
by Trevor Hale
[November 11, 2018, 11:32:12 AM]
WorldFlight - CockpitBuilders UAL1120 Progress
by dougsnow
[November 11, 2018, 11:08:19 AM]
CP Flight Selcal - How does it work
by ZK CWD
[November 10, 2018, 11:51:31 PM]