flyingjayaraj Posted July 28, 2020 Report Posted July 28, 2020 Hello everyone, i am building an MCP for the Quality Wings B-757-200 using Mobi-flight. As of now everything seems to be working fine except the MCP altitude value on the 7-Segment dislay When i rotate the encoder the altitude in the Simulator MCP window , Increases & Decreases but the Altitude display on the 7-Segment does not keep up and get lags behind, and when i rotate it anticlockwise the 7 segment altitude display goes to zero. when ever i hit the FLCH or VS button the altitude is Sync again, its just not stable offset used for the output is - 0x07D4 , 4bytes , Integer, transform - $*3.28084/65536 FSUIPC - 4.975A ,19th may 2020 - Registered version A friend on the mobiflight forum advised me to use the Lua and write a code to read the value and display it on the 7-Segment. but since i have no coding background i am finding it a bit difficult to wrap my head around the script. i did a lot of googling and found some code and modified it, but am not sure if its correct and how to properly use and execute it. The code to read the LVAR - file name is " b75200.lua " first = true while true do if first then initialALTVal = ipc.readLvar("L:alt_sel_num") ipc.writeUD(0x66C0, initialALTVal) first = false else currentALTVal = ipc.readUD(0x66C0) ipc.writeLvar("L:alt_sel_num", currentALTVal) end end The code to execute the script every-time the aircraft is started up - ipcready.lua if ipc.readSTR(0x3D00, 10) == "QualityWings 757-200F QW House Livery RR" then ipc.runlua("Lua:b75200") end Both the files are in the Modules folder along with FSUIPC request you to kindly guide me, in case the code is appropriate, any posts / info on how to utilize the code effectively and execute it. Thanks a lot AJ
Pete Dowson Posted July 28, 2020 Report Posted July 28, 2020 3 hours ago, flyingjayaraj said: When i rotate the encoder the altitude in the Simulator MCP window , Increases & Decreases but the Altitude display on the 7-Segment does not keep up and get lags behind, That's strange. it is almost always the other way round -- the inputs from the encoder pile up whilst the display keeps up easily. Anyway, the normal way of dealing with these things, and one which i've used in several case of encoder+display going back many years, is to update the display locally, directly from the encoder changes, whilst also feeding the latter to the sim, only reading values to display when the encoder changes have paused for a measurable time, like half a second or so. I don't know if that's possible using this "mobiflight", whatever that is (software or hardware?). 3 hours ago, flyingjayaraj said: when i rotate it anticlockwise the 7 segment altitude display goes to zero. Sounds like something is badly wrong there then. 3 hours ago, flyingjayaraj said: when ever i hit the FLCH or VS button the altitude is Sync again, its just not stable Sorry, what do you mean "not stable"? Changing on its own without relation to the encoder or sim value? 3 hours ago, flyingjayaraj said: The code to read the LVAR - file name is " b75200.lua " What LVAR? I thought you just said you were using the offset! If you are reading an L:Var instead then I'm not surprised it is slow. Accessing local Gauge values is very slow by comparison. 3 hours ago, flyingjayaraj said: Both the files are in the Modules folder along with FSUIPC Neither are any good as they are, and you certainly don't need two in any case. But it isn't worth going into any details to help you further until you clarify two things: 1. What has an LVAR got to do with it. what is wrong with the offset? 2. Why is offset 0x66C0 being used? What does that have to do with anything? Pete 1
flyingjayaraj Posted August 3, 2020 Author Report Posted August 3, 2020 Hi Pete, thanks a lot for the reply. apologies for my delayed response. Mobiflight is the software, that i am using to build my home MCP, Sim software - Quality Wings 757 - They dont have a published SDK to check what offsets and event IDs have been used. and being a 757 there are very few pilots who want a build a home sim for the variant, however i did find one pilot and he had the same issues with the 7-segment mcp altitude. I am unable to use the standard offset - 0x07D4 for the Altitude display, as when i rotate the encoder, the altitude changes in the Sim software, but on the 7-segment display it works initially but after a while it tends to not keep up. the encoder is using the event ID and works fine, i have tried different encoder and different pins on the arduino but the same issue persists. All the wiring / power lines and grounding have been double checked I was advised to read the local L:Var by accessing the Guage value - assign this to a free offset in FSUIPC and then use that free offset in Mobiflight software to display the MCP altitude on the 7-Segment. I know accessing the guage value is slow, but as long as i can have a operational MCP altitude display its acceptable. If i have got the process wrong please do advise me, as i am going only by google searches. The L:var is - L:alt_sel_num Free Offset i used in the code - 66C0 Using this i came up with the code by replacing the values - " Anyway, the normal way of dealing with these things, and one which i've used in several case of encoder+display going back many years, is to update the display locally, directly from the encoder changes, whilst also feeding the latter to the sim, only reading values to display when the encoder changes have paused for a measurable time, like half a second or so. " In case you can advise me on how to achieve the above, i shall try updating the display locally if possible. Hope to get this working sooner, AJ "
Pete Dowson Posted August 3, 2020 Report Posted August 3, 2020 2 hours ago, flyingjayaraj said: Mobiflight is the software, that i am using to build my home MCP, As some sort of interface between the Sim and hardware -- any sort of hardware, or does it only support certain makes? 2 hours ago, flyingjayaraj said: Sim software - Quality Wings 757 - They dont have a published SDK to check what offsets and event IDs have been used. No, but then most such aircraft use the built-in Sim systems, unlike say PMDG and FSL, and probably the Aerosoft A320, which implement their own systems making most of the standard Sim offsets redundant. 2 hours ago, flyingjayaraj said: I am unable to use the standard offset - 0x07D4 for the Altitude display, as when i rotate the encoder, the altitude changes in the Sim software, but on the 7-segment display it works initially but after a while it tends to not keep up. the encoder is using the event ID and works fine That's very strange -- it's usually the other way around. The Increment and Decrement Events pile up and are still being actioned in the Sim when you stop turning, which makes it very difficult to stop on the required value. The hardware display should be a lot quicker. What is slowing it down? If you Monitor 07D4 in FSUIPC (right-hand side of the Logging tab), does that value show the same as the panel on screen? If not then the aircraft probably isn't using the Sim's A/P system, in which case one asks why in 07D4 being changed at all? (You can view the changes in real time either by selecting the display option, or "normal log"-- in the latter case using the Monitor log option to see the logging on screen). From what you say it seems to me that the problem is not using 07D4 but the route from the offset being read to when the display is updated is taking too long. If that's the case then using 66C0 or any other offset won't make any difference. So, is it "Mobiflight" managing the display for you? Where does an Arduino come into it? 2 hours ago, flyingjayaraj said: I was advised to read the local L:Var by accessing the Guage value - assign this to a free offset in FSUIPC and then use that free offset in Mobiflight software to display the MCP altitude on the 7-Segment. I know accessing the guage value is slow, but as long as i can have a operational MCP altitude display its acceptable. Was there some reasoning behind this recommendation? From someone who got it working properly? I can understand using an L:Var to obtain a value if it isn't available more directly, as in the standard offset, but if you are only going to use it to slow down transmissions to the digital display hardware which is so slow, then I think it would be better to simply only read the 07D4 value every so many milliseconds, say giving 4 or 5 updates per second, or whatever the hardware can cope with. 2 hours ago, flyingjayaraj said: In case you can advise me on how to achieve the above, i shall try updating the display locally if possible. Well, if updating the display is where the problem is, my solution isn't applicable. My solution applies to the more normal case there the Sim can't keep up with the hardware. Pete
flyingjayaraj Posted August 3, 2020 Author Report Posted August 3, 2020 Hi Pete, Mobi-flight is a software and they also provide the firmware to drive the Arduinos that are required for the home MCP. It isthe Arduinos that drive the 7 segment display, i have attached a snap of the home mcp, it's a very basic one. 🙂 I shall monitor - the Offset via FSUIPC and update you regarding that. In the mobiflight software interface i do get the FSUIPC log , it gives me exactly whats displayed in Simulator MCP Altitude window. "I can understand using an L:Var to obtain a value " - this technique was recommended by another person who had the same issue and sorted it out. I was hoping to try it out and see if its works, incase it gives me better results i would stick it with, else at least i would have learnt something new 🙂
Pete Dowson Posted August 3, 2020 Report Posted August 3, 2020 1 hour ago, flyingjayaraj said: I was hoping to try it out and see if its works Okay, let's look. here's your code to read the LVAR: first = true while true do if first then initialALTVal = ipc.readLvar("L:alt_sel_num") ipc.writeUD(0x66C0, initialALTVal) first = false else currentALTVal = ipc.readUD(0x66C0) ipc.writeLvar("L:alt_sel_num", currentALTVal) end end I can't make a lot of sense of this. You are reading the L:Var just once and setting that value into 66C0. Then you read 66C0 and WRITE to the Lvar as fast as possible (no delays, just a continuous loop not allowing anything else to get a look-in! And the plug-in never terminates and only ever reads the LVar once. Writing to the L:Var was not mentioned in what you are trying to do. I thought you just wanted to read it? You said you updated the value using an encoder and the event to do the updates (you said "the encoder is using the event ID and works fine"). So, I think you need to explain a bit more about how you arrived at this code and what you thought it might do for you. then maybe i can show you how to rewrite it. Then you have: On 7/28/2020 at 7:13 PM, flyingjayaraj said: The code to execute the script every-time the aircraft is started up - ipcready.lua if ipc.readSTR(0x3D00, 10) == "QualityWings 757-200F QW House Livery RR" then ipc.runlua("Lua:b75200") end That can't work on two counts: First you read 10 characters from offset 3D00 and then try to match it to many more than 10. Second, the ipc.runlua function needs the name of the plugin -- just "b75200". The "Lua:" in front of it isn't valid. Anyway, "ipcReady.lua" is only run once per session, when the sim is first "ready to fly". To load and run a plug-in when a specific aircraft is loaded to need to use the [Auto.<profile>] section, with the <profile> name of your Profile for this aircraft. Then, in that section, you just have: 1=Lua b75200 Pete
flyingjayaraj Posted August 3, 2020 Author Report Posted August 3, 2020 Hi pete, Initially i was under the impression that i had to update the values both ways. In my case the the encoder is working fine and i am able to change the MCP altitude, its just issues displaying that value on the 7-segment. so i guess in my case it would be to read the value and write that to a free offset, and there after read the value from that offset my case (0X66c0) But i am not sure about the interval and how to keep it running ☹️ first = true while true do if first then initialALTVal = ipc.readLvar("L:alt_sel_num") ipc.writeUD(0x66C0, initialALTVal) first = false end end And i added to the fsuipc.ini file - In order to automatically run the script. [Auto] 1=Lua b75200 I have also ensured that that its "b75200"
flyingjayaraj Posted August 4, 2020 Author Report Posted August 4, 2020 while true do n=ipc.readLvar("L:alt_sel_num") ipc.writeUD(0x66C0,n) ipc.sleep(100) end When i run this script through lua-edit , i get an error - runtime error at line 1
Pete Dowson Posted August 4, 2020 Report Posted August 4, 2020 2 hours ago, flyingjayaraj said: When i run this script through lua-edit , i get an error - runtime error at line 1 What's "lua-edit"? If there's any error it will be logged in FSUIPC's log file. Look there! Pete
flyingjayaraj Posted August 11, 2020 Author Report Posted August 11, 2020 Hi Pete, i was able to read the values and get the displays going. now i have another roadblock as i have jumped to Captain Sim 757, seems to be a better model and they have a published SDK. Using the same code i was able to display the MCP Altitude on the 7segment - using the L:var. values Now to use the knobs i checked the SDK and its says the following. - ---------------------------------- HOW TO RETURN DATA FOR MOMENTARY ACTION SWITCHES 1. Convert the element's name into an ID number. For example, for the G02_003_BUT. - remove all underscores and the ending to get G02003. - change the first letter to a number according to the table below: C=13 G=17 L=22 O=25 P=26 R=28 So an ID number for the G02_003_BUT is 1702003.2. Set the ID number to the L:klid variable. This will simulate a user's click. FOR KNOBS ( _KNO) 1.Convert the element's name into an ID number. 2. Add the - (minus) for counterclockwise rotation. For example:(L:klid) = 1702003 - clockwise rotation. (L:klid) = -1702003 - counterclockwise rotation FOR ALL OTHER ELEMENTS Set the required value to a variable. E.g. to press the G02_003_BUT: (L:G02_003_BUT) = 1 ---------------------------------------------------------------- I Used the data and i was able to come up with the ID for the MCP Airspeed = 1703010 How would i set the ID number to the L:klid variable to simulate a user's click / knob rotation ???? 😞 i tried (L:klid) = 1703010 , but it does not show up in the fsuipc list. ☹️ CS757CAPTAINIII_MANUAL_PART6.pdf
Pete Dowson Posted August 11, 2020 Report Posted August 11, 2020 3 hours ago, flyingjayaraj said: How would i set the ID number to the L:klid variable to simulate a user's click / knob rotation ???? 😞 i tried (L:klid) = 1703010 , but it does not show up in the fsuipc list. ☹️ You tried "(L:klid) = 1703010" where, exactly? and what do you mean by "the fsuipc list"? I really don't know what you are talking about there. To set an L:var from a Lua plug in you need to use the ipc.writeLvar function. Please do refer to the Lua library documentation. Pete
flyingjayaraj Posted August 16, 2020 Author Report Posted August 16, 2020 Hi Pete, thanks a lot for your reply. apologies for my late response, just got back to my base. I added " (L:klid) = 1703010 " in the macro file that i have running along with the different L:vars, i guess i was wrong. I went through the Lua library Documentation, but am not exactly sure on how to write the code. ipc.writeLvar(“name”, n) ------------------------------------- ipc.writeLvar(L:klid=1703010) ipc.sleep(100) end -------------------------------------- So in case the above code is correct, i would have to write this code in lua, save it in the modules folder. There after use "L:klid=1703010" in the macros file to access it... or would it be only "L:1703010" ?? Or alternatively will 1703010 - Turn out to be an Event ID ? since we are writing data into it ..... hope i am on the right track, been trying to find some sample scripts using "klid" but unfortunately no luck sir Thanks a lot, regards AJ
Pete Dowson Posted August 16, 2020 Report Posted August 16, 2020 1 hour ago, flyingjayaraj said: I went through the Lua library Documentation, but am not exactly sure on how to write the code. ipc.writeLvar(“name”, n) ------------------------------------- ipc.writeLvar(L:klid=1703010) No. Don't you see the " " and the , (comma)? And where does your = come from? Please just follow the documentation: ipc.writeLvar(“name”, n) name is obviously (?) the L:Var name., L:klid. The comma is a comma (,) not an equals (=), and n is your number. So ipc.writeLvar(“L:lid", 1703010) What is the "sleep(100)" for? 1 hour ago, flyingjayaraj said: i would have to write this code in lua, save it in the modules folder. There after use "L:klid=1703010" in the macros file to access it... or would it be only "L:1703010" ?? 😞 Please please read the documentation supplied! When you save the file you give it a short filename, right? In FSUIPC you assign to Lua filename -- it'll appear in the list. Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now