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

April 29, 2024, 06:21:18 AM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
482 Guests, 0 Users
Members
  • Total Members: 4,154
  • Latest: xyligo
Stats
  • Total Posts: 59,641
  • Total Topics: 7,853
  • Online today: 499
  • Online ever: 582
  • (January 22, 2020, 08:44:01 AM)
Users Online
Users: 0
Guests: 482
Total: 482

COUNTDOWN TO WF2022


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

Scott (and Rob's...) Chicago 737-300 Build

Started by XOrionFE, December 26, 2015, 02:18:32 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Ed

Quote from: XOrionFE on January 20, 2018, 07:20:43 PM
New video...

Enjoying a little XEnviro weather flying a circuit at KSEA.....all running smooth and looking phenomenal.

https://youtu.be/QTs4n1mpq34

733....slowly but surely coming along...

Scott

Great Video Scott. Very smooth. Huge wow factor !
P3D5.3HF2, 3 x W10 PC's, FSUIPC 6.19 ,WideFS, Prosim737 V3 ,ASP3D, Vpilot, GSXL2, Pro-ATC/X, RAAS Pro, AIG Traffic, ,PFPX, TopCat, SimSounds,  http://www.737ngxca.com/

XOrionFE

Decided to fire up my back two displays again networked on XP.    Installed XEnviro on them and working great.   not always perfect because the clouds are not synced perfectly across networked visuals but good enough for me......and Immersion well.....IMHO beats the hell out of projectors.   But beauty is in the eye of the beholder.   You have to be in it and see it believe me.   All are welcome to visit.

https://youtu.be/Tm7waOeZB0s

https://youtu.be/h9iNzqmg8kY


Bob Reed


XOrionFE

All MIP Korries, Master Caution, Fire Warning, and Six Packs interfaced and working...check. (Lights test looks like XMAS!)

Pressurization panel interfaced and working...check



Steenos

Quote from: XOrionFE on March 02, 2018, 04:15:26 PM
All MIP Korries, Master Caution, Fire Warning, and Six Packs interfaced and working...check. (Lights test looks like XMAS!)

Pressurization panel interfaced and working...check

Looks awesome Scott!

XOrionFE

Worked on my Windshield/Pitot Heat panel this weekend.   Have to finish my Teensy sketch and will be working by tomorrow night.   Here are some pictures of interfacing the real panel and how it wires into a Teensy using Rob's breakout board with some ULN2803s and a Teensy LC.

Scott

jackpilot

You Guys are real 73-Nuts !!!!   :D

Keep on !


Jack

blueskydriver

#132
Hey Rob and Scott,

My curiosity into using Teensy cards is getting stronger every time you guys post something new, and now seeing the PCB's that Rob has developed is making things that much easier. So, Rob are you planning on selling these in a kit and/or as P&P in the future?

Next, Rob I know you did the B727 in the past, but could it be done using Teensy's along with your PCB (and other needed items)? Also, what language/software (interface) are you using to set everything up? In other words, I know zilch about the methodology involved with the setups Scott and you are doing; however, I surely could learn, but mainly for the 72 as well as the 73.

Likely, you're wondering where I am going with this line of questioning...well; if do not sell my 72 I might decide to keep it and get it working. After all the time and effort just acquiring it, plus seeing it sitting here next to me everyday just looking pretty makes it a whole lot harder to part with her. Actually, sitting here in the hanger everyday is just as bad, if only I had you guys closer I could just imagine what we could do.

Heck, any other members living closer would be a blessing, but that is not in the foreseeable future, not unless I convince Bob and his wife to move near me...come on Bob...just keep saying Tomah, WI, Tomah, WI...lol! Everyone else you're welcome to come visit or move to Tomah, WI and join me. I really do need a partner or two, as my past ones developed medical issues; one with survivable Prostate Cancer and the other passed away due to Colon Cancer.

Uh, no I am not bad luck or anything...lol...but then again who else just had surgery?
Makes you wonder... :huh:...hahahaha...but then again, can you say;

"Things that make you go hmmmm?!"

https://www.youtube.com/watch?v=XF2ayWcJfxo

Did you enjoy the retro?

John

   
| FSX | FDS-MIP OVRHD SYS CARDS FC1| PM | PMDG 737-700 | UTX | GEX | UT7 | ASE | REX2 | AES | TSR | IS | TOPCAT | AvilaSoft EFB | OC CARDS & OVRHD GAUGES| SIMKITS | SW 3D Lights | FS2CREW2010 | FSXPassengers | Flight1 AE | MATROX TH2GO-D | NTHUSIM | 3-Mits EW230Ust Proj |

XOrionFE

John,
The 727 could EASILY be done using Teensy interfacing the same as we are doing here.  In fact, I could quite easily switch mine back to a 737-200 if I chose with a few panel changes.   For a 727 you would want to use X-Plane and the incredible awesome FlyJSim 727 aircraft addon.  Jack (the main developer of FlyJSim) is updating the 727 to version 3 as we speak just like he just did for his incredible 732.   He exposes all of the systems via datarefs and my guess is the 727 would be near if not 100 percent interfaceable the same as Rob and I have done ours.   See Jack continue developement of the new version on his Twitch channel.   My guess is it will be completed within the next month or two but you could use the existing version until then just fine.   It would be really something for you or someone to build that 727.    Rob and I would be hapoy to help with coding questions and such.   May even be able to take a trip there at some point.   You have to come pay a visit to me in April when I am back from Spring vacation.

As for the coding, it is simple C# Arduino ccoding but Teensy's offer a unique flightsim library and plug in for XPlane and very powerful performance for a very low cost.   What is also cool about Teensys and Arduino is that the code (sketch) is self contained on the Interface once you load it and a simple plugin in XPlane allows the communication.    You can unplug one of these or reload it on the fly and do not have to restart the sim.   You can do this in flight!   Makes testing really slick and easy.

I will post my Sketch for the Windshield Heat panel later today or tonight when I finish it and you can see how simple.

Build that 727 John!  If I had the space I would buy it from you in a heart beat and build it myself!

Scott

kurt-olsson

That panel interface is looking awesome. What awg you using for 5v,28v and ground? What is your connector called and what tool to press it?

727737Nut

Quote from: kurt-olsson on March 05, 2018, 05:46:12 AM
That panel interface is looking awesome. What awg you using for 5v,28v and ground? What is your connector called and what tool to press it?

Kurt,
The wire AWG is all dependent on the circuit load and as the case with most simbuilders, we go way overboard.  LOL     For real Korry's, they draw 70 - 80mA per bulb so roughly 150mA per Korry.  So from the Korry to Teensy board 26ga would be plenty, same for the switch signal inputs.   Now for the wire to feed the 28v and GND to the module as a whole lets use this panel Scott built as an example.  17 Korry's so that 17x 150mA = 2550mA or 2.5A   So to feed that panel you would only need 18ga  wire.  Now for the entire overhead while on a Lights test, you would calculate total load and use the appropriate sized wire for that load.  NOTE! when calculating wire size you must know the distance of the run to and from the power supply. So if your 28V power supply is sitting 20ft away form the supply terminal strips in the overhead, you would need to use 40ft as total run distance and lets say 10A  So you would need a 12ga feed wire from your power supply to the overhead.   Make sense?   As for connectors, Scot uses Amp brand connectors, I used automotive style connectors I got from amazon.  Doesn't matter what you use as long as you get a properly rated connector for the amp draw.   These are overkill that we use but easier to handle with average hands and more robust than smaller connectors.

One day we can discuss how I only have 3 wires  to mine as well but in my case the Ground is also DC and AC gnd as all my backlighting is 0-5Vac.   ;)      Scotts 3 wires are 28Vdc, 0-5Vdc, and GND   Mine are 28Vdc, 0-5Vac, and GND plus one usb connection.   It has proven to be a very nice, robust, and most of all convenient to remove for updates/repairs/maint.

Rob
737 Junkie

XOrionFE

#136
Quote from: kurt-olsson on March 05, 2018, 05:46:12 AM
That panel interface is looking awesome. What awg you using for 5v,28v and ground? What is your connector called and what tool to press it?
Thanks Rob, and for a little further on mine...

The wires going to the Teensy are 22 awg (24-26 would be fine as well but i like 22 for added measure and ease of using various connectors).  Gray wire is for ground signal on korrys back through ULN2803 chips (defined as outputs on the Teensy.    White wires are input wires going from switches to the Teensy.     Red wire (with white strip or white heat shrink) is noted as 5vdc backlighting power which is variable with dimmers.   Purple in my cockpit is 28vdc.   The thicker Red, Purple, and Black wires going into the Molex connector is 16 awg.   I use 16 awg as feeders into all panels.   those feeders go to my Blue Ocean Busses and all feeders have appropriate fuses.     The blue ocean busses connect back to my rack and to the appropriate power supplies via 12 awg wire and on regular aircraft style breakers.   

The molex connectors are by Waldom and are the .093 size for 16 gauge wires.  .062 for smaller 22-24 awg wire. You can buy the crimper from them as well as a tool used to extract pins once installed.  I get them from Digikey.

https://www.digikey.com/product-detail/en/molex-connector-corporation/76650-0058/WM8355-ND/2115919

kurt-olsson

Thanks! Will have a good strategy and proper tools before i start my interface-fest! :)

fsaviator

It would be nice to see some of this information captured in it's own space with part #s.....  My bookmark list is getting kind of large.  So is the pile of parts, chips, PCBs and all for me to tackle teensy.  I need to retire.  This work thing is interfering with my simming
Warren "FSAviator"
http://www.B737NG-Sim.com  |  https://www.facebook.com/fsaviator/
P3D45/ Prosim737 2/ ACE Dual-linked Yokes/ RevSim Proline TQ and Dual-linked Rudders/ CPFlight MCP PRO3 and EFIS'; MIP737ICS_FULL and SIDE737; Forward and Aft Overheads; Pedestal/ FDS MIP

XOrionFE

Here is the Teensy sketch for my Window/Heat panel:

Scott



------Begin-----
#include <Arduino.h>
#include <Bounce.h>

//IXEGWindowHeat Panels using TeensyLC

// output pins
const uint8_t WIN_OVHT_LEFT_SIDE_LT_PIN = 0;
const uint8_t WIN_OFF_LEFT_SIDE_LT_PIN = 1;
const uint8_t WIN_OVHT_LEFT_FWD_LT_PIN = 2;
const uint8_t WIN_OFF_LEFT_FWD_LT_PIN = 3;
const uint8_t WIN_OVHT_RIGHT_FWD_LT_PIN = 4;
const uint8_t WIN_OFF_RIGHT_FWD_LT_PIN = 5;
const uint8_t WIN_OVHT_RIGHT_SIDE_LT_PIN = 6;
const uint8_t WIN_OFF_RIGHT_SIDE_LT_PIN = 7;
const uint8_t CAPT1_AUX_LT_PIN = 8;
const uint8_t FO_2_STAT_LT_PIN = 9;
const uint8_t LEFT_ELEV_PITOT_LT_PIN = 10;
const uint8_t LEFT_ALPHA_VANE_LT_PIN = 11;
const uint8_t TEMP_PROBE_LT_PIN = 12;
const uint8_t FO_2_AUX_LT_PIN = 13;
const uint8_t CAPT_STAT1_LT_PIN = 14;
const uint8_t RIGHT_ELEV_PITOT_LT_PIN =15;
//const uint8_t RIGHT_ALPHA_VANE_LT_PIN  *Note that the Right Alpha Vane Korry is on a separate Teensy*
const uint8_t WINHEAT_LEFT_SIDE_SW_PIN = 16;
const uint8_t WINHEAT_LEFT_FWD_SW_PIN = 17;
const uint8_t WINHEAT_RIGHT_SIDE_SW_PIN = 21;
const uint8_t WINHEAT_RIGHT_FWD_SW_PIN = 20;
const uint8_t PITOT_A_SW_PIN = 22;
const uint8_t PITOT_B_SW_PIN = 23;
const uint8_t WINHEAT_TEST_SW_PIN = 18;
const uint8_t WIN_PWR_TEST_SW_PIN = 19;

const int BOUNCE_TIME = 15;// Switch debouncing time (used for all switches)

const float LIGHT_THRESHOLD = 0.2; // threshold to use for light on or off

//define dataRef vars

FlightSimFloat winovhtleftsideannXref;
FlightSimFloat winoffleftsideannXref;
FlightSimFloat winovhtleftfwdannXref;
FlightSimFloat winofflleftfwdannXref;
FlightSimFloat winovhtrightfwdannXref;
FlightSimFloat winoffrfightfwdannXref;
FlightSimFloat winovhtrightsideannXref;
FlightSimFloat winoffrrightsideannXref;
FlightSimFloat capt1auxannXref;
FlightSimFloat fo2statannXref;
FlightSimFloat leftelevpitotannXref;
FlightSimFloat leftalphavaneannXref;
FlightSimFloat tempprobeannXref;
FlightSimFloat fo2auxannXref;
FlightSimFloat captstat1annXref;
FlightSimFloat rightelevpitotannXref;
FlightSimInteger winheatleftsideactXref;
FlightSimInteger winheatleftfwdactXref;
FlightSimInteger winheatrightsideactXref;
FlightSimInteger winheatrightfwdactXref;
FlightSimInteger pitotaactXref;
FlightSimInteger pitotbactXref;
FlightSimInteger winheattestactXref;

//Bounce Switches
Bounce winheatleftsideSw = Bounce (WINHEAT_LEFT_SIDE_SW_PIN, 5);
Bounce winheatleftfwdSw = Bounce (WINHEAT_LEFT_FWD_SW_PIN, 5);
Bounce winheatrightsideSw = Bounce (WINHEAT_RIGHT_SIDE_SW_PIN, 5);
Bounce winheatrightfwdSw = Bounce (WINHEAT_RIGHT_FWD_SW_PIN, 5);
Bounce pitotaSw = Bounce (PITOT_A_SW_PIN, 5);
Bounce pitotbSw = Bounce (PITOT_B_SW_PIN, 5);
Bounce winheattestSw = Bounce (WINHEAT_TEST_SW_PIN, 5);
Bounce winpwrtestSw = Bounce (WIN_PWR_TEST_SW_PIN, 5);

elapsedMillis sinceUpdate;

// setup runs once
void setup() {
  Serial.begin(38400);

  //IXEG Datarefs
  winovhtleftsideannXref = XPlaneRef("ixeg/733/antiice/ai_winovht_l_side_ann");
  winoffleftsideannXref = XPlaneRef("ixeg/733/antiice/ai_winoff_l_side_ann");
  winovhtleftfwdannXref = XPlaneRef("ixeg/733/antiice/ai_winovht_l_fwd_ann");
  winofflleftfwdannXref = XPlaneRef("ixeg/733/antiice/ai_winoff_l_fwd_ann");
  winovhtrightfwdannXref = XPlaneRef("ixeg/733/antiice/ai_winovht_r_fwd_ann");
  winoffrfightfwdannXref = XPlaneRef("ixeg/733/antiice/ai_winoff_r_fwd_ann");
  winovhtrightsideannXref = XPlaneRef("ixeg/733/antiice/ai_winovht_r_side_ann");
  winoffrrightsideannXref = XPlaneRef("ixeg/733/antiice/ai_winoff_r_side_ann");
  capt1auxannXref = XPlaneRef("ixeg/733/antiice/ai_capt_1_aux_ann");
  fo2statannXref = XPlaneRef("ixeg/733/antiice/ai_fo_2_stat_ann");
  leftelevpitotannXref  = XPlaneRef("ixeg/733/antiice/ai_l_elev_pitot_ann");
  leftalphavaneannXref = XPlaneRef("ixeg/733/antiice/ai_l_alpha_vane_ann");
  tempprobeannXref = XPlaneRef("ixeg/733/antiice/ai_temp_probe_ann");
  fo2auxannXref = XPlaneRef("ixeg/733/antiice/ai_fo_2_aux_ann");
  captstat1annXref = XPlaneRef("ixeg/733/antiice/ai_capt_stat_1_ann");
  rightelevpitotannXref = XPlaneRef("ixeg/733/antiice/ai_r_elev_pitot_ann");
  winheatleftsideactXref = XPlaneRef("ixeg/733/antiice/ai_winheat_l_side_act");
  winheatleftfwdactXref = XPlaneRef("ixeg/733/antiice/ai_winheat_l_fwd_act");
  winheatrightsideactXref = XPlaneRef("ixeg/733/antiice/ai_winheat_r_side_act");
  winheatrightfwdactXref = XPlaneRef("ixeg/733/antiice/ai_winheat_r_fwd_act");
  pitotaactXref = XPlaneRef("ixeg/733/antiice/ai_pitot_a_act");
  pitotbactXref = XPlaneRef("ixeg/733/antiice/ai_pitot_b_act");
  winheattestactXref = XPlaneRef("ixeg/733/antiice/ai_winheat_test_act"); //Overheat position = -1.00, Pwr Test = 1 , Off = 0


//define Teensy pin types 
pinMode (WIN_OVHT_LEFT_SIDE_LT_PIN, OUTPUT);
pinMode (WIN_OFF_LEFT_SIDE_LT_PIN, OUTPUT);
pinMode (WIN_OVHT_LEFT_FWD_LT_PIN, OUTPUT);
pinMode (WIN_OFF_LEFT_FWD_LT_PIN, OUTPUT);
pinMode (WIN_OVHT_RIGHT_FWD_LT_PIN, OUTPUT);
pinMode (WIN_OFF_RIGHT_FWD_LT_PIN, OUTPUT);
pinMode (WIN_OVHT_RIGHT_SIDE_LT_PIN, OUTPUT);
pinMode (WIN_OFF_RIGHT_SIDE_LT_PIN, OUTPUT);
pinMode (CAPT1_AUX_LT_PIN, OUTPUT);
pinMode (FO_2_STAT_LT_PIN, OUTPUT);
pinMode (LEFT_ELEV_PITOT_LT_PIN, OUTPUT);
pinMode (LEFT_ALPHA_VANE_LT_PIN, OUTPUT);
pinMode (TEMP_PROBE_LT_PIN, OUTPUT);
pinMode (FO_2_AUX_LT_PIN, OUTPUT);
pinMode (CAPT_STAT1_LT_PIN, OUTPUT);
pinMode (RIGHT_ELEV_PITOT_LT_PIN, OUTPUT);
pinMode (WINHEAT_LEFT_SIDE_SW_PIN, INPUT_PULLUP);
pinMode (WINHEAT_LEFT_FWD_SW_PIN, INPUT_PULLUP);
pinMode (WINHEAT_RIGHT_SIDE_SW_PIN, INPUT_PULLUP);
pinMode (WINHEAT_RIGHT_FWD_SW_PIN, INPUT_PULLUP);
pinMode (PITOT_A_SW_PIN, INPUT_PULLUP);
pinMode (PITOT_B_SW_PIN, INPUT_PULLUP);
pinMode (WINHEAT_TEST_SW_PIN, INPUT_PULLUP);
pinMode (WIN_PWR_TEST_SW_PIN, INPUT_PULLUP);

}

//Function Definitions

//This function used for lighting korrys
void setAnnunciator(float value, const uint8_t outputPin) {
  digitalWrite(outputPin, value > LIGHT_THRESHOLD ? HIGH : LOW);
}

//This function used for a single toggle switch
void updateFunction(Bounce *bounce, FlightSimInteger *dataRef, bool resync) {
  if (bounce->update() || resync) {
    if (!bounce->read()) {
      *dataRef = 1;
    } else {
      *dataRef = 0;
    }
  }
}

//This function used for a 3 position Toggle switch
void updateFunctionDoubleSwitch(Bounce *bounce1, Bounce *bounce2, FlightSimInteger *dataRef, int val1, int val2, int valNone, bool resync) {
  // Check if switches have been changed.
  // We can't use "if (bounce1->update() || bounce2->update())..." here, because that way, if bounce1->update() returned true,
  // bounce2->update() wouldn't even be called, meaning that the switch wouldn't be debounced.
  // Another way to do this would be "if (bounce1->update() | bounce2->update())..." (using an ARITHMETIC or - single vertical
  // bar), but that is error prone.
  bool bounce1Updated = bounce1->update();
  bool bounce2Updated = bounce2->update();
  if (bounce1Updated || bounce2Updated || resync) {
    if (!bounce1->read()) {
      *dataRef = val1;
    } else if (!bounce2->read()) {
      *dataRef = val2;
    } else {
      *dataRef = valNone;
    }
  } 
}

//End Function Definitions

bool wasEnabled = false;

bool checkResync() {
  // check if flight sim was just enabled
  // this is the case if it WAS NOT enabled before and IS enabled now
  bool newEnabled = FlightSim.isEnabled();
  bool result = (!wasEnabled) && newEnabled;
  wasEnabled = newEnabled;
  return result;
}


// loop runs repetitively, as long as power is on
void loop() {
  FlightSim.update();
  bool resync = checkResync();
 
//***Switches***
updateFunction(&winheatleftsideSw, &winheatleftsideactXref, resync);
updateFunction(&winheatleftfwdSw, &winheatleftfwdactXref, resync);
updateFunction(&winheatrightsideSw, &winheatrightsideactXref, resync);
updateFunction(&winheatrightfwdSw, &winheatrightfwdactXref, resync);
updateFunction(&pitotaSw, &pitotaactXref, resync);
updateFunction(&pitotbSw, &pitotbactXref, resync);
updateFunctionDoubleSwitch(&winheattestSw,  &winpwrtestSw,   &winheattestactXref,     -1, 1, 0, resync);
 
//*****Outputs*****
setAnnunciator(winovhtleftsideannXref, WIN_OVHT_LEFT_SIDE_LT_PIN);
//setAnnunciator(winoffleftsideannXref, WIN_OFF_LEFT_SIDE_LT_PIN); //Note - commented out because the IXEG uses OFF lights instead of ON lights
setAnnunciator(winovhtleftfwdannXref, WIN_OVHT_LEFT_FWD_LT_PIN);
//setAnnunciator(winofflleftfwdannXref, WIN_OFF_LEFT_FWD_LT_PIN);
setAnnunciator(winovhtrightfwdannXref, WIN_OVHT_RIGHT_FWD_LT_PIN);
//setAnnunciator(winoffrfightfwdannXref , WIN_OFF_RIGHT_FWD_LT_PIN);
setAnnunciator(winovhtrightsideannXref, WIN_OVHT_RIGHT_SIDE_LT_PIN);
//setAnnunciator(winoffrrightsideannXref, WIN_OFF_RIGHT_SIDE_LT_PIN);
setAnnunciator(capt1auxannXref, CAPT1_AUX_LT_PIN);
setAnnunciator(fo2statannXref, FO_2_STAT_LT_PIN);
setAnnunciator(leftelevpitotannXref, LEFT_ELEV_PITOT_LT_PIN);
setAnnunciator(leftalphavaneannXref, LEFT_ALPHA_VANE_LT_PIN);
setAnnunciator(tempprobeannXref, TEMP_PROBE_LT_PIN);
setAnnunciator(fo2auxannXref, FO_2_AUX_LT_PIN);
setAnnunciator(captstat1annXref, CAPT_STAT1_LT_PIN);
setAnnunciator(rightelevpitotannXref, RIGHT_ELEV_PITOT_LT_PIN);

//Note - had to add these in and reverse High and Low because IXEG uses OFF lights instead of ON lights
  if (winoffleftsideannXref > LIGHT_THRESHOLD) {
    digitalWrite(WIN_OFF_LEFT_SIDE_LT_PIN, LOW);
  } else {
    digitalWrite(WIN_OFF_LEFT_SIDE_LT_PIN, HIGH);
  }
    if (winofflleftfwdannXref > LIGHT_THRESHOLD) {
    digitalWrite(WIN_OFF_LEFT_FWD_LT_PIN, LOW);
  } else {
    digitalWrite(WIN_OFF_LEFT_FWD_LT_PIN, HIGH);
  }
    if (winoffrfightfwdannXref > LIGHT_THRESHOLD) {
    digitalWrite(WIN_OFF_RIGHT_FWD_LT_PIN, LOW);
  } else {
    digitalWrite(WIN_OFF_RIGHT_FWD_LT_PIN, HIGH);
  }
    if (winoffrrightsideannXref > LIGHT_THRESHOLD) {
    digitalWrite(WIN_OFF_RIGHT_SIDE_LT_PIN, LOW);
  } else {
    digitalWrite(WIN_OFF_RIGHT_SIDE_LT_PIN, HIGH);
  }
 
}

Steenos


727737Nut

Quote from: Steenos on March 05, 2018, 05:02:51 PM
Dang that looks pretty intense to me!

There is a new library out that would cut that sketch in half.  And just for comparison, here is my old sketch that i am using  Haven't updated mine yet to the new library.

#include <Bounce.h>



FlightSimFloat WhL1;
FlightSimFloat WhL2;
FlightSimFloat WhR1;
FlightSimFloat WhR2;
FlightSimFloat PitHeatA;
FlightSimFloat PitHeatB;
FlightSimFloat OvhtTest1; //Overheat position = -1.00
FlightSimFloat OvhtTest2; //Pwr Test = 1 , Off = 0
FlightSimFloat LsOvht;
FlightSimFloat LfOvht;
FlightSimFloat RfOvht;
FlightSimFloat RsOvht;
FlightSimFloat LsON;
FlightSimFloat LfON;
FlightSimFloat RfON;
FlightSimFloat RsON;
FlightSimFloat CaptAux1;
FlightSimFloat FoStatic1;
FlightSimFloat LelevPitot;
FlightSimFloat TempProbe;
FlightSimFloat FoStatic2;
FlightSimFloat CaptStatic1;
FlightSimFloat RelevPitot;

Bounce WhL1Sw = Bounce (22, 5);
Bounce WhL2Sw = Bounce (21, 5);
Bounce WhR1Sw = Bounce (23, 5);
Bounce WhR2Sw = Bounce (17, 5);
Bounce PitHeatASw = Bounce (20, 5);
Bounce PitHeatBSw = Bounce (19, 5);
Bounce OvhtTest1Sw = Bounce (16, 5);
Bounce OvhtTest2Sw = Bounce (18, 5); //Power Test


elapsedMillis sinceUpdate;

void setup() {
  pinMode(16, INPUT_PULLUP); //OVHT test SW
  pinMode(17, INPUT_PULLUP); //Rt FWD Heat SW
  pinMode(18, INPUT_PULLUP); //PWR Test SW
  pinMode(19, INPUT_PULLUP); //Pitot B SW
  pinMode(20, INPUT_PULLUP); //Pitot A SW
  pinMode(21, INPUT_PULLUP); //Lt FWD Heat SW
  pinMode(22, INPUT_PULLUP); // Lt Side Heat SW
  pinMode(23, INPUT_PULLUP); // Rt Side Heat SW
  // Outputs to Korry's
  pinMode(0, OUTPUT); //Lt Side Ovht
  pinMode(1, OUTPUT); //Lt Side ON
  pinMode(2, OUTPUT); //Rt Side Ovht
  pinMode(3, OUTPUT); //Rt Fwd Ovht
  pinMode(4, OUTPUT); //Rt Fwd ON
  pinMode(5, OUTPUT); //Rt Side ON
  pinMode(6, OUTPUT); //Lt Fwd Ovht
  pinMode(7, OUTPUT); //Lt Fwd ON
  pinMode(8, OUTPUT); // Unassigned
  pinMode(9, OUTPUT); //Lt Temp Probe
  pinMode(10, OUTPUT); //Capt Static 1
  pinMode(11, OUTPUT); //Lt Elev Pitot
  pinMode(12, OUTPUT); //missing Korry
  pinMode(13, OUTPUT); //Rt Elev Pitot
  pinMode(14, OUTPUT); //FO Static 2
  pinMode(15, OUTPUT); //FO Static 1

  //IXEG Datarefs
  WhL1        = XPlaneRef("ixeg/733/antiice/ai_winheat_l_side_act");
  WhL2        = XPlaneRef("ixeg/733/antiice/ai_winheat_l_fwd_act");
  WhR1        = XPlaneRef("ixeg/733/antiice/ai_winheat_r_side_act");
  WhR2        = XPlaneRef("ixeg/733/antiice/ai_winheat_r_fwd_act");
  PitHeatA    = XPlaneRef("ixeg/733/antiice/ai_pitot_a_act");
  PitHeatB    = XPlaneRef("ixeg/733/antiice/ai_pitot_b_act");
  OvhtTest1   = XPlaneRef("ixeg/733/antiice/ai_winheat_test_act"); //Overheat position = -1.00
  OvhtTest2   = XPlaneRef("ixeg/733/antiice/ai_winheat_test_act"); //Pwr Test = 1 , Off = 0
  LsOvht      = XPlaneRef("ixeg/733/antiice/ai_winovht_l_side_ann");
  LfOvht      = XPlaneRef("ixeg/733/antiice/ai_winovht_r_fwd_ann");
  RfOvht      = XPlaneRef("ixeg/733/antiice/ai_winovht_r_fwd_ann");
  RsOvht      = XPlaneRef("ixeg/733/antiice/ai_winovht_r_side_ann");
  LsON        = XPlaneRef("ixeg/733/antiice/ai_winoff_l_side_ann");
  LfON        = XPlaneRef("ixeg/733/antiice/ai_winoff_l_fwd_ann");
  RfON        = XPlaneRef("ixeg/733/antiice/ai_winoff_r_fwd_ann");
  RsON        = XPlaneRef("ixeg/733/antiice/ai_winoff_r_side_ann");
  CaptAux1    = XPlaneRef("ixeg/733/antiice/ai_capt_1_aux_ann");
  FoStatic1   = XPlaneRef("ixeg/733/antiice/ai_fo_stat_1_ann");
  LelevPitot  = XPlaneRef("ixeg/733/antiice/ai_l_elev_pitot_ann");
  TempProbe   = XPlaneRef("ixeg/733/antiice/ai_temp_probe_ann");
  FoStatic2   = XPlaneRef("ixeg/733/antiice/ai_fo_2_aux_ann");
  CaptStatic1 = XPlaneRef("ixeg/733/antiice/ai_capt_stat_1_ann");
  RelevPitot  = XPlaneRef("ixeg/733/antiice/ai_r_elev_pitot_ann");

}

void loop() {
  if (sinceUpdate >= 100) {
    sinceUpdate = 0;
    FlightSim.update();
  }

  // Process Outputs
  if (LsOvht > 0.2) {
    digitalWrite(0, HIGH);
  } else {
    digitalWrite(0, LOW);
  }
  if (LsON < 0.2) {
    digitalWrite(1, HIGH);
  } else {
    digitalWrite(1, LOW);
  }
  if (RsOvht > 0.2) {
    digitalWrite(2, HIGH);
  } else {
    digitalWrite(2, LOW);
  }
  if (RfOvht > 0.2) {
    digitalWrite(3, HIGH);
  } else {
    digitalWrite(3, LOW);
  }
  if (RfON < 0.2) {
    digitalWrite(4, HIGH);
  } else {
    digitalWrite(4, LOW);
  }
  if (RsON < 0.2) {
    digitalWrite(5, HIGH);
  } else {
    digitalWrite(5, LOW);
  }
  if (LfOvht > 0.2) {
    digitalWrite(6, HIGH);
  } else {
    digitalWrite(6, LOW);
  }
  if (LfON < 0.2) {
    digitalWrite(7, HIGH);
  } else {
    digitalWrite(7, LOW);
  }
  if (TempProbe > 0.2) {
    digitalWrite(9, HIGH);
  } else {
    digitalWrite(9, LOW);
  }
  if (CaptAux1 > 0.2) {
    digitalWrite(10, HIGH);
  } else {
    digitalWrite(10, LOW);
  }
  if (LelevPitot > 0.2) {
    digitalWrite(11, HIGH);
  } else {
    digitalWrite(11, LOW);
  }
  if (RelevPitot > 0.2) {
    digitalWrite(13, HIGH);
  } else {
    digitalWrite(13, LOW);
  }
  if (FoStatic2 > 0.2) {
    digitalWrite(14, HIGH);
  } else {
    digitalWrite(14, LOW);
  }
  if (FoStatic1 > 0.2) {
    digitalWrite(15, HIGH);
  } else {
    digitalWrite(15, LOW);
  }

  // Prcess Switch Inputs

  if (OvhtTest1Sw.update()) {
    if (OvhtTest1Sw.fallingEdge()) {
      OvhtTest1 = -1.0;
    } else {
      OvhtTest1 = 0.0;
    }
  }
  if (OvhtTest2Sw.update()) {
    if (OvhtTest2Sw.fallingEdge()) {
      OvhtTest2 = 1.0;
    } else {
      OvhtTest2 = 0.0;
    }
  }
  if (WhR2Sw.update()) {
    if (WhR2Sw.fallingEdge()) {
      WhR2 = 1.0;
    } else {
      WhR2 = 0.0;
    }
  }
  if (PitHeatBSw.update()) {
    if (PitHeatBSw.fallingEdge()) {
      PitHeatB = 1.0;
    } else {
      PitHeatB = 0.0;
    }
  }
  if (PitHeatASw.update()) {
    if (PitHeatASw.fallingEdge()) {
      PitHeatA = 1.0;
    } else {
      PitHeatA = 0.0;
    }
  }
  if (WhL2Sw.update()) {
    if (WhL2Sw.fallingEdge()) {
      WhL2 = 1.0;
    } else {
      WhL2 = 0.0;
    }
  }
  if (WhL1Sw.update()) {
    if (WhL1Sw.fallingEdge()) {
      WhL1 = 1.0;
    } else {
      WhL1 = 0.0;
    }
  }
  if (WhR1Sw.update()) {
    if (WhR1Sw.fallingEdge()) {
      WhR1 = 1.0;
    } else {
      WhR1 = 0.0;
    }
  }
}

737 Junkie

kurt-olsson

As a programmer a tip i have is to use conditional expression and also you can remove the brackets if only oneline within the if statent.


Ex: instead of:

If (a ==1) {
DoSomething(write,LOW)
}
Else
{
DoSomething(write,HIGH)
}

This can be shortened to:

DoSomething(write, a == 1 ? LOW : HIGH);

There are alot of if / else that could be removed i this code. I think i could remove 40% of it with some refactoring.



XOrionFE

Quote from: kurt-olsson on March 05, 2018, 07:51:29 PM
As a programmer a tip i have is to use conditional expression and also you can remove the brackets if only oneline within the if statent.


Ex: instead of:

If (a ==1) {
DoSomething(write,LOW)
}
Else
{
DoSomething(write,HIGH)
}

This can be shortened to:

DoSomething(write, a == 1 ? LOW : HIGH);

There are alot of if / else that could be removed i this code. I think i could remove 40% of it with some refactoring.

Million ways to skin a cat.  This code is not fully optimized.  As you can see, most is function driven but I had to slam the last conditional statements in to get a particular error resolved and tested.    I posted this not so we can discuss programmig technique but so that folks can get an idea of what the effort looks like.   Thank you for the tips.   Lets keep this topic to the overall build updates though.  Perhaps we can eventually have an area on the forum for coding examples and tips 🙂

Scott

Bob Reed

#144
Quote from: XOrionFE on March 06, 2018, 03:35:57 AM
Quote from: kurt-olsson on March 05, 2018, 07:51:29 PM
As a programmer a tip i have is to use conditional expression and also you can remove the brackets if only oneline within the if statent.


Ex: instead of:

If (a ==1) {
DoSomething(write,LOW)
}
Else
{
DoSomething(write,HIGH)
}

This can be shortened to:

DoSomething(write, a == 1 ? LOW : HIGH);

There are alot of if / else that could be removed i this code. I think i could remove 40% of it with some refactoring.

Million ways to skin a cat.  This code is not fully optimized.  As you can see, most is function driven but I had to slam the last conditional statements in to get a particular error resolved and tested.    I posted this not so we can discuss programmig technique but so that folks can get an idea of what the effort looks like.   Thank you for the tips.   Lets keep this topic to the overall build updates though.  Perhaps we can eventually have an area on the forum for coding examples and tips 🙂

Scott

Scott, we do have a Arduino Projects section and a LUA section. Arduino Projects has never had a post.

kurt-olsson

#145
I posted it because it looked daunting to some people and wanted to show that it can be made easier.


Joe Lavery

Sorry Scott, still looks daunting to my old brain. I'm still at the flash the LED stage.  :) :) :)

Joe.
Life isn't about waiting for the storm to pass, it's about learning to dance in the rain

Journalist - writer for  PC Pilot Magazine

paulnd

Quote from: kurt-olsson on March 05, 2018, 07:51:29 PM
As a programmer a tip i have is to use conditional expression and also you can remove the brackets if only oneline within the if statent.


Ex: instead of:

If (a ==1) {
DoSomething(write,LOW)
}
Else
{
DoSomething(write,HIGH)
}

This can be shortened to:

DoSomething(write, a == 1 ? LOW : HIGH);

There are alot of if / else that could be removed i this code. I think i could remove 40% of it with some refactoring.
Hi,

Tips like this are incredibly useful to self taught arduino "programmers" (I use the term very loosely!) like me.

I'll be grateful if you could consider opening a new thread with any other similar tips or links to tips?

Apologies for highjacking this thread.

Regards

Paul

Sent from my Nexus 7 using Tapatalk


KyleH

Quote from: kurt-olsson on March 06, 2018, 04:42:55 AM
I posted it because it looked daunting to some people and wanted to show that it can be made easier.

Just wanted to comment on this.


Just because some code is written shorter, doesn't mean it is any easier to follow. Sometimes properly formatted multiple statements can be the better solution if it makes it easier to understand when you come back to it months or years later. Just because some code takes up a lot of space doesn't make it harder to see what is going on.

The embedded programing (microcontroller firmware) I was doing before I changed jobs, we were putting emphasis on proper style, readability, and understandability, over fancy statements that made the text segment shorter. As some sections of our code had safety critical operations this was important.
The other factor with embedded programing is that we had to be very aware of how the compiler would take a statement and then use it on the microcontroller. I remember one compiler that would actually use less memory in the micro if many if,then,else statements were used over a simpler switch statement. Longer C file but smaller operating code size.
Kyle

Chief Pilot
Worldflight Team USA
http://www.worldflightusa.com

XOrionFE

Been almost a year so thought I would post some pics of the build.
Since last time much more has been completed.

1. Switched out ADIs to Collins style and finished interfacing Flight Director, Glide slope, and fast slow indicators.
2.  Not sure if it was done last time but OEM MCP is 100 percent interfaced and working using Arinc.
3. OEM CDUs are fully operational using Arinc.
4. OEM weather radar and tcas panel fully interfaced and operational using Arinc.
5. OEM Vertical speed indicators with integrated tcas fully interfaced and operational with Arinc.
6. OEM fuel gauges fully interfaced and operational.
7. 2 bay pedestal replaced with 3 bay and wired for power and hubs.
8. OEM Comms, Navs, and Transponder all wired in and fully functional.  Comms and Transponder using Arinc and Navs using custom teensy multiplex interface board we made along with regular teensy programming.
9. Pedestal lights and door lock panels installed and operational.
10. Added OEM ACARs panel which we hope to interface as soon as sim funtionality exists.
11. Added second electronics shelf of stepper to synchro drivers so I can add in signals to run RMIs for VOR and ADF needles as well as to separate FO Altimeter as its own standalone altimeter rather than simply mimicking the Captains.
12.  On X-Plane front I am running the latest release of 11.30 flawlessly and have implemented Activesky for XP weather (which is awesome).   I also upgraded a second pc with a 1080 TI card and so now I am running the full sim on just two PCs with full wraparound visuals.

In short, much accomplished since this time last year.  Special thanks to Rob Archer and Jorg Bleisener who have been instrumental contributors this whole time and withoutbwhom this would not be possible.

Guess it may be coming close to time to finally sell my shiny new NG mip from FDS along with their cdus and my cp flight stuff because I doubt I would ever turn back now.  X-Plane has grown by leaps and bounds in the last year and with addons like ActiveSky as well as the new scenery from Orbx and the power of Teensies for interfacing it is one helluva platform for the OEM builder.

Thats all for now.
Scott

Some current pics


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