Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 25
  • *Total: 26

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

Fred Kurasiewicz, Ray Sotkiewicz,Warren Soeldner, Kyle Hathaway-

Thanks to all of you, so far this year we have raised

$670.00 USD


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

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,051
  • 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: 303
  • 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,051
  • 737 -mixed year OEM panel builder.
  • First Name: Peter
  • Home Location: Gothenburg
Re: Teensy LC Hydralic Panel
« Reply #2 on: Today at 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

Join me on Vatsim Tonight
by Trevor Hale
[Today at 06:13:52 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[Today at 03:45:38 PM]
What have you done for your simulator today?
by Joe Lavery
[Today at 10:58:20 AM]
Converting KingAir to Glass
by Trooping
[Today at 10:17:02 AM]
Teensy LC Hydralic Panel
by kurt-olsson
[Today at 08:38:50 AM]
Can you guyse please check this link
by gjha97
[Today at 08:25:00 AM]
B737 Desktop sim project
by KyleH
[October 17, 2018, 09:23:40 PM]
KingAir B200 Builder
by flyinghigh
[October 17, 2018, 07:43:56 PM]
FOR SALE - Pair of IPECO Seats and J-Rails
by fsaviator
[October 16, 2018, 11:55:42 PM]
Edge Blending Blockers?
by FredK
[October 16, 2018, 06:42:58 PM]
More Throttle Quadrant nightmares.
by blueskydriver
[October 16, 2018, 02:14:44 PM]
Korry 318 push to test logic
by kurt-olsson
[October 15, 2018, 01:02:43 PM]
Had to Post (True Story) Funny as Hell though (glad noone was hurt)
by Trevor Hale
[October 15, 2018, 12:01:36 PM]
#Worldflight2018 Less than 20 Days to go!
by Trevor Hale
[October 15, 2018, 10:39:46 AM]
Active Sky 16 Networked to P3D V4 ?
by brianwilliamson
[October 14, 2018, 07:52:08 PM]
Computer Power supply strange 5V and strange behaviour Teensy is connected
by iwik
[October 14, 2018, 01:39:14 PM]
For Sale: Jetmax JetMax-737SKTQ
by Trevor Hale
[October 13, 2018, 08:56:35 PM]
Laser CNC cutting/etching using a 3D printer?
by Joe Lavery
[October 12, 2018, 11:28:59 AM]
For Sale GoFlight Jet Console, 2 Private Pilot Racks all with GoFlight Modules.
by Joe Lavery
[October 12, 2018, 10:57:35 AM]
Project Magenta with Xplane 11
by kevinsayre
[October 12, 2018, 08:14:25 AM]
13.8V ok for 12V use?
by kurt-olsson
[October 11, 2018, 12:40:48 PM]
INTRODUCTION
by twkster
[October 10, 2018, 11:31:27 PM]
SOLD: For sale New FlightsimPM B737 Throttle Quadrant v2.1
by fairchild
[October 10, 2018, 04:13:13 PM]
For sale,Commercial Packege Saitek Modules
by fairchild
[October 10, 2018, 03:05:47 PM]
CR-10, CR-10S, CR-10S4 and CR-10S5 3d Printer Info and Links...
by Trevor Hale
[October 10, 2018, 01:02:44 PM]
Mickey's Flightdeck - A Boeing 737-800 Cockpit on Youtube
by Joe Lavery
[October 10, 2018, 12:28:18 PM]
For Sale: CPFlight MCP 737 EL $400 USD Shipped Lower 48
by Giovan
[October 10, 2018, 05:18:11 AM]