Connecting an arduino to Prosim737 - A Boeing 737-800 Homecockpit #33

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome back to Mike's flight deck today we will show you how we can create a small test setup that connects a hardware like this which viren Arduino to person what am I doing here [Music] as I already said in my last livestream person is supporting it's a channel with a license of their 7378 so I can show you the steps you have to go when you want to integrate such a system to your hardware and I hope I can reduce the fear of getting in touch with our software before we dive into the installation and settings in person lets us cut the question why should I need the dedicated simulation cert I already have prepared and the PMDG m37 installed so why should I invest money into another system one point could be the performance you can often read the discussion that the PMDG needs a lot of system resources and this is because the add-on has to calculate the simulation of the boring system logic as well as the presentation of the virtual cockpit and all the possibilities you have with it the only task of the simulation suit in a simulation of the system logic and in most cases it does a job without the need of the presentation of crude panels because you have them in reality in your cockpit you can also let it run on a different computer so that your main computer can concentrate on the presentation of the scenery another part is a presentation of different displays and the PMDG you have to undock the displace the e-cars or PFD for example to show it on a different monitor which is connected to your PC but with a suit in most cases the display is a separate application that can be started on a different PC that can communicate with your main computer so again you can transfer workload from your main PC and now let's have a look into the components of prosím 77 the suit is divided into several modules prosím system mentions the simulation of the aircraft systems and acts as a hub for all the other modules program mCP simulates the auto flight system and the Efus functionality and comes with a graphical panel that you can show in your carpet or use for testing purposes prosím display generates all the graphical elements like the primary flight display or navigation display which you can show on different monitors in your carpet these can also be monitors that are connected to other computers in your network as long as the display module is running on that computer the graphic can be shown the CDU module controls the flight management system and gives you the possibility to show a complete CDU on a monitor to control jus with a touchscreen or only the display signal which can be shown on many devices of third-party developers frozen panel shows all the different cockpit panels that can be used instead of real panel hardware or just for testing purposes with pros and sounds you have access to a library of sounds you can play during special cockpit events or integrate your own cockpit zones you don't need to use one of the simulator planes for your carpet because the software comes with its own flight model and you have access to a full instructor station which is accessible via a web interface you will be able to connect Hardware of many manufacturers by a different ways whether you connect your hardware via USB and a silk script or via ethernet and now join me when I will take my first steps into the setup that will transfer the signals of my hardware from an Adreno via ethernet via an i/o CP server to person I want to give you an overview what will technically go on now I will connect the switch and led to my artery new with a connected Ethernet shield this will communicate via ethernet with the open cockpit iocp server which will forward all signals to person so what is an IRC p server it is a program that gives the client the possibility to get informed about the value changes of variables from other clients and also to inform other clients about various of their own variables let's make an example for the electrolyte in the pros mmm CP I the variable number 14 my irineu were registered this variable number on the iris apiece server so that he will receive informations about changes now every time when the state of the variable changes the mCP module will send a new value to the iocp server and because the server knows that the Arduino is interested in it he will forward the new value to the Arduino the advantages that the Arduino isn't informed about the state of every variable in the cockpit but only about those that are necessary for his work so we're not now about theory let's go to work first of all we will test the communication between the iris appeaser ver and pro software and for this we'll have to download some software and you can find the IRC P server on the open cockpit side under downloads and there in the eoq category and there you will find the silk package which you can download and install the pro sim software can be downloaded from their website also under downloads download person 737 and then you can choose from an Asha file or an installer you can download and use the software where the only limitation is embed it only runs 30 minutes and then you have to restart the software after installing the software I will start my IRC P server which is open cockpit silk and the server is started automatically when the software is running and you can see it is hosted under the IP address of my computer which is also the localhost when I'm connecting on this machine and the part is 80 92 these values will need when we start prosím now and you start with the prosím temperature 7 system module in the system module we'll configure our started IRA CP server under config and configuration and then go to the drivers tab here you can find all the entries for all other third-party and developers and here we also have a field IRC P server and there I will enter my IP address I think I also can write localhost and the port when we say ok person will have to restart now we will start the mCP module and to control if everything can communicate with each other you can right-click on the mCP module and under status you can see in the server connection is ok and that is all we need now for this test what I want to control in this test in the autotrol switch and later the autothrottle indicator and we will start with a switch and will assign a variable for this switch now and this you can do in the system module under config configuration and combined config and there you can see the different parts of the cockpit and your panels you can access and we are in need for that sraddha land MCP category this is again and divided into several categories and we all need the switches category and searching for the autotrol switch you can find the switch here under the name MCP a TR m-- armed there are two states of the switch arm and off but you will only need to communicate with one of the states because when the switch isn't armed it is logically off so I will only concentrate on the arm state here and shoot the iocp server and now I will have to assign a number for this variable let's name this 15 you can choose any number you want I think there are some numbers that are reserved for other parts of the panels but I think this you will find out by the way you now can see and that there is another client connected to the IRC P server which is the mCP panel now we need a way to control and traffic and the communication between the server and the connected clients and this you can do with the IRC P console there are some variables already signed and we don't need them and to get rid of them we close in the console and say empty script now everything is clean here now we want to simulate our first command that can come from any connected client to the ISP server for example the Arduino we will turn on the login here and now let's send for the variable number 15 the value of 1 and send it and look at the switch here it's going on and when we send 0 it's going off that's it you can also assign names to this variable for example MSP autothrottle and say accept and now for the variable M of 15 this name is assigned here and you can save this file when you want to have it for later import or later tests so that already concludes the first test of sending variables from the IRC server to prosím and now let's make a simulation that we listen to one variable and this will be the indicator of the auto trot alarm so for this purpose I will go back to the system module again to the configuration combined configuration and to the throttle MCP category and this time to the indicator category and there we already have the mCP Auto trottle indicator and we also say I recipe and assign a number let's say 14 and here you can already see in our logging that the value of zero is sent for the state of the indicator here and you can see it is off so the state of zero is right and now if we assign a value of 1 for the variable number 15 which means we switch the autothrottle switch to armed then you can see one for variable 15 ascent and we get an answer from the mCP panel which means that for the variable number 14 the state is 1 which means the light is on now and you can see the light is on and with this information for the variable number 14 we can make something in the program on our Arduino that will react on this on state and set corresponding hardware light on and this is what we have to do now and will now face the programming part for the Arduino now let me describe the hardware component I will be using from this project I am using an Arduino Uno and a breadboard to hold all the components I will mount Ethernet shield on top of the arena and connect this wire and even a cable with my switch and this is connected with my computer the R we know will be connected via USB with my PC for uploading the scripts and testing some serial communication I will connect LED light to ground and via a resistor to pin 2 and the switch will be also connected to ground and pin 3 and this is all what you need for this first setup to start programming with AR you know you need the corresponding IDE which is a software package that makes your computer possible to program for the Arduino and communicate with it and upload the sketches which are your programed scripts to the Arduino and you can find it on their website under software and downloads and here you can download the actual IDE for your system what you will get is a package with all the classes that you need to program the software and also this little editor here where you can add your scripts and upload them to the connected Arduino but I'm preferring a little bit more powerful editor here and this is also free to use and the Atmos studio which you can download actual in the version seven from the website here and install it and in combination with another plugin which is called Arduino for visual studio you can write your scripts very fast and easy and with the support of the software in Atma studio you should ensure that the right Arduino IDE is selected here and the Arduino you have connected to your PC and also the part where it is connected to if this is alright and then we can start a new arena project there's already a basic code structure made by the program and I'm now going through the programming steps very detailed so if you are already familiar with Arduino programming then this might be a little bit boring for you but I want to reach as many of you as I can here with this project first of all we'll have to add some libraries which we'll be using later and this will be the SPI and the Ethernet library now we'll define some global variables and first of all the MAC address I've covered this MAC address from my clipboard because I didn't want to type it in here this MAC address is for identifying your Arduino in your network and you will need the IP address of the IRC P server then we will need an Ethernet client which we will use to communicate with the network and all the characters that we read from this Ethernet connection we will store in a character just named see all these characters will later be written into an answer string and as you know will receive variable numbers and values that will be stored also in separate variables first of all the number and the value the state of RS which will be stored in a separate variable and we define the two pins of the Arduino we'll be using and this will be the pin for the switch which is on pin 3 and the LED pin which is pin 2 at the name says in the setup and function we will set up everything which will be need when our are renew starts the first time or is resetted we define our switch pin as an input switch with a pin mode command and we will define this as an input with an intent pull-up resistor and this is to prevent the switch from being disturbed by any electric noise or something like this so you will have a clean signal when it is connected there and our LED pin we define as an output pin to control some values in our serial monitor we'll start a serial connection and this is the connection wire and the USB cable and the output will later be in our serial monitor and now we already start the Ethernet connection and give the command the MAC address now our first serial output will be connecting so that we can see in the connection is starting now we make the connection to the IRC P server and this we have to do in an if state so that we can react if anything goes wrong with our client object we try to connect to the IRC P server which we have defined up here and with a port you can enter the port number here or you can define it as a variable up here if the connection was successful then we will make an output on our serial monitor and then register and our needed variable at the IRC P server as we will do again with a client variable and this is the first Co special command when you want to register variables then you stop this with the iron dot initiative command and with this double point separated you can register as many variables as you want to if you want to register more then you can say 14 and 16 and 17 and so on but now for the test we are only a need for a number 14 which is the indicator of the out of trouble switch if something went wrong then we make again an output the last thing we have to do is to initial set our switch state and this we do with a digital read from the switch pin and this concludes all we have to do in the setup and function the loop function is called many times a second while the Arduino is powered on and here we will check from time to time if we are still connected to the IRC P server this we can do with a client object so if the client is still connected then everything is okay but if it is not connected then we have to reconnect to in the server and first of all we will stop the client then just to be sure and wait a second and then we can start a new connection and this is the first time we can modify our code because we have to do everything we have done here from Ethernet begin and every time you can reuse code here then do it in a special function so your code will be more flexible and easier to maintenance so I will make a connect function and copy all this code here into it and in our set up function we were called to this function so you see this is much more readable here so after the delay we again call this function now we come to read in our first characters and this will do in a while command so while there is anything available at the client we will read everything we can get into our C char and append this to our ancestry so let's make our first test if there is anything that we can received at the moment and this we will test only if the answer string isn't empty and if there is something in the ancestry then we will print this out after we have printed the string we will empty it again and now we already can test this code we have written here so we compile and upload it to the Arduino and then start the serial monitor so we have received already something you can see the connecting and connected so we are connected to the IRC P server and after we have sent our on initio command the server has answered with on vevo and already send out the first state of the indicator with 1 which means the LED is on let's see if this is right and there it is it is a green LED now if we switch this off you can see we receive 0 because the LED is off so let's try now if we can send commands with our switch to the mCP module we will need a function that will check the state of the switch and then send the corresponding command to the mCP module this will be a set through which function and we will check the switch state if the switch state is low which means the switch is on because we have and when you remember the pull-up resistor here and this means when there is a low signal on the port then the switch is on so when the switch is on then the client sends a command and this is also iocp or open-cockpit seok's special it will send armed RESP for response 15 is on and otherwise resent and off signal but we are working here with a switch state variable and we have to update this variable from time to time and this we will do in an update function which we call update switch and then this function will check if the switch state is a different state then and current state on the pin so we read the signal at the pin and if this is another one than the one we have stored already then the switch has been changed and so we have to update the switch state and restore is a new switch state and after the new value restored then we set the switches again so this update switch function has to be called time to time so we will set this here in our loop function but we don't only want the switches to be changed when we switch them we want to be the mCP module in the right switch state already when we start up our Arduino and so we'll have to initialize the switch state so in that the function looks what is the state of our switches and set this already at the beginning to the mCP module and this will do here in our processing of the string answer and we will check if the string answer contains the arm vivo response if the index of an Revo isn't -1 then there must be an on vevo in the answer string and this will only be at the first answer of our IRC P server so we can use this point as the initialization of our switches and so we can he call the sets which function to send the first date of our switches to the server so let's test the program now we are connected again and we have an off signal for the indicator that's right so let's test the code for the first time we are connected and have received the off signal and this is write the indicators of and now let's use as rich for first time you can see the switch has gone to arm and the indicator is on and switch this off and the switch goes off we can now send commands via the switch to the server and we can receive the state of the indicator now the last thing we have to do is to show this indicator state with the LED on our breadboard so we will have to go through the string and search for this 14 equals 0 of 14 equals 1 science and these we have to bring to a command to the LED before we work with a string we will remove any garbage signs from the beginning or the end of it and this we can do with a trim command after that we'll get a rid of everything we don't need in this answer string for example this hole on rest pot here in front of the 14 and this we will do in a special trim function so I will call this trim answer and with this function I will remove everything in front and including this first double point here so we will use the remove command and you can see here in the help we will need a starting index and the number of signs we want to remove the starting index will be the beginning of the string and how long will we remove this well until we find this RESP double point so we were search for this in the string you know this command already from our initialization so it will search in the string for the respite of point sign and then it will go one two three four five characters forward to remove this also so after this command there should be only left 14 equal zero and we would call this command here at this point before we can test this we will add another serial I would put here right after the trim command and we will write the string answer again so we can see how this has changed and here we can see before the trimming the string was vivo an RESP 14 equal zero and after this it is 14 equal zero and when I switch my switch here then you can see it will be reduced to this answer here now we will have to get the separate values from this remaining string the 14 and 0 for example and this we will do with another special function which we will call extract next value so this function will return an integer value which will be the value of the variable or the value itself and I won't give the limiter into this function and this will be the equal sign or this double point here so as I said it will return a value and now we have to get something into this value and we will do this from the answer string and we will cut out a substring from it and you can see again the substring command uses beginning index and the end index the beginning index will be the beginning of the string because it already begins with a variable number which we want to have and which will be the end index well this will be the index of the equal sign so we have to search for it you know this command already we are searching for the index of the delimiter which will be our equal sign and the string we read with a substring command we will convert to an integer after we have the substring we will remove the variable number and the equal sign from the string and you know this command already from the beginning up to the equal sign additional one to remove the equal sign as well now we can use this extract next value function and we will do this here and we should only do this if we have anything left in the answer string so again we were asking if the string isn't empty now we will read the values which will be the number of the variable x value and our delimiter will be the equal sign in the first run and the value we will extract until the double point so let's print these two variables out for testing and test this code so here we have it we received an RESP 14 equals 0 and this was made to 14 equals 0 and the two variables 14 and the value of 0 and when we switch the switch then we get 14 equals 1 and the corresponding values you can see here we get two zeros and I think this must be some errors in the initialization here and to get rid of this output and don't run into any troubles while we set the indicator we will set the indicator only when the variable number isn't 0 so with this we will do here if the variant number isn't there oh then we will call another function which will set our indicators and this function we will do now we'll call this set indicators and we will look to our variable number and if the variable number is 14 which is the number of our auto total indicator then we will do a digital right on our LED pin and set this pin to the variable value which will be 1 or 0 which means on or off so here in this which case you can add more and more variables and other indicators you want to check and every time the variable number is set then the set indicators will be called and the next variable will be set so now we have to call the set indicators function here only if the variable number is not 0 so let's test this code we'll open our serial monitor and the MCP we have received a zero which means the indicator light is off and you can see this to add the LED here now let's get on the switch and the LEDs on and also the LED on our breadboard and off again so everything is programmed now and we are ready for the last ultimate test I have disconnected the are arena from the PC and use the USB cable just to provide power by this USB power supply here so the Arduino is disconnected physically from the PC and I will set switch state which will differ from the state in the person MCP module so we can test if this Hardware will be connected to running simulator system if our set indicator and initialize switch functions will work so the Arduino is still disconnected you can see the electron switch on the pro team MCP module is off our set this switch here to on so that it differs from the state that is set in the person module now I will provide power to it and the LED goes on and also the LED in the mCP module and we're already connected and now when I switch it off the LED physically and in the module goes off and on again and so everything worked as it should be well what a coding session I hope you could follow me along and if not you can play back the video and watch the parts again you have missed remember this is just an example code and it can be modified in many ways I think we'll do this in an upcoming video you can add a header file for example so that you don't have to deal with this mysterious numbers like 14 for the autotrol indicator there will be many more we have to discover like a 7 segment displays rotary encoders we will add port expanders so that we can increase the number of pots we have available on our Arduino but this all would take place in an upcoming video so I want to say thank you to Hannah Cole from frozen for making me available a license for this software and if you haven't done already then subscribed to my channel to stay informed about any upcoming new video from me so I hope we'll see you soon back on the flight deck [Music]
Info
Channel: Michael Schulz
Views: 8,605
Rating: undefined out of 5
Keywords: Prosim737, mickey's flightdeck, mickeys flightdeck, 737-800, b737, boeing, flight simulator, home cockpit, homecockpit, homemade cockpit, michael schulz, boeing 737 cockpit, boeing 737-800, home cockpit 737, home cockpit build, 737 home cockpit, Arduino, IOCP server, SIOC, Prosim
Id: c2S8oXmdJpk
Channel Id: undefined
Length: 41min 42sec (2502 seconds)
Published: Sun Apr 07 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.