rocketeer Posted November 29, 2010 Share Posted November 29, 2010 Look at post #48 to 70. http://forums.eagle.ru/showthread.php?t=45071&page=2 After reading this I had a good idea of how SOIC and LUA works, even though I have not bought the OC cards yet. This is for a simple switch. Once you can get this going, then it's just a bit more work to figure out pots, encoders, rotary switches etc. My A10C cockpit thread Link to comment Share on other sites More sharing options...
Jocman Posted December 1, 2010 Author Share Posted December 1, 2010 Thanks Rocketeer. I'll have a look to that, hoping to find some ideas. I'll keep informed. Cheers Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Jocman Posted December 3, 2010 Author Share Posted December 3, 2010 Ok guys.... I DID IT!!!!! :thumbup: :thumbup: My first OC card switch in perfectly working on BS!!!! Now it's time to start programming. Thanks Rocketeer for the hint, and thanks Oakes for his tutorial. I'll keep you informed during my "journey" Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Jocman Posted December 3, 2010 Author Share Posted December 3, 2010 First problem....:( I'm programming a switch with cover. I wouldn't like to wast 1 input just to set the cover, so I decided to try only with the script for the switch. result: if I toggle the switch, the first time it opens the cover, then I've to toggle it off then on again to make the switch on. Then I tried to assign in SIOC 2nd variable to the cover, but putting as OC input the same as the switch (in my case the input is 0): [1] = {TwoPositionSwitch, 2, 1, 1} [2] = {TwoPositionSwitch, 2, 2, 1} As you can see, in LUA I changed only the second value I tested it, but it doesn't work (nothing happens) How can I tell SIOC / LUA to toggle both (cover and switch) when I toggle only my "real" switch? Thanks all Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Jocman Posted December 3, 2010 Author Share Posted December 3, 2010 Ok, I found and error, I forgot the "," at the end of the line BTW, even putting the ",", it doesn't work. So the problem remain: How to make SIOC / LUA perform 2 actions with a single input (switch + cover using only 1 "2 positions" switch). Second...... how to manage "3 positions" or "X positions" switches???? I can't find anywhere something about those issues. Initially I was thinking about to use the function "Rotary Switches", but I don't think it can work. Any idea? Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Feed Posted December 3, 2010 Share Posted December 3, 2010 Jocman I'm certainly no expert, but within SIOC could you not link the single variable of the switch itself to two *other* variables that would then each operate the cover & switch via Lua? I have to imagine there's an easy way, and this is probably an amateur way around. Link to comment Share on other sites More sharing options...
y2kiah Posted December 3, 2010 Share Posted December 3, 2010 You can solve this problem without SIOC. The simplest method I can see to do it would be to write a function similar to TwoPositionSwitch but call it something like TwoPositionCoverAndSwitch. That function would toggle the cover along with the switch, and take two control id's as arguments instead of just 1, the first for the switch and the second for the cover. So this code: [1] = {TwoPositionSwitch, 2, 1, 1} [2] = {TwoPositionSwitch, 2, 2, 1} would become something like: [1] = {TwoPositionCoverAndSwitch, 2, 1, 2, 1} and in the ExportSupport.lua script you would add the following: function TwoPositionCoverAndSwitch(pValue, pDevice, pNumber, pCoverNumber, pOnValue, pInvert) if pInvert then if pValue == 1 then pValue = 0 else pValue = 1 end end local device = GetDevice(pDevice) if pValue == 1 then -- flipping it on, open the cover first device:performClickableAction(pCoverNumber + 3000, pValue * pOnValue) device:performClickableAction(pNumber + 3000, pValue * pOnValue) else -- flipping it off, close the cover last device:performClickableAction(pNumber + 3000, pValue * pOnValue) device:performClickableAction(pCoverNumber + 3000, pValue * pOnValue) end end Oakes' script that I am referencing supports up to 8 arguments by default after the function name in the "command" table (between the {}) of which we are only using 4. This can be extended of course, but 8 should be enough for anything. please keep in mind I have not tested the code as-is Link to comment Share on other sites More sharing options...
Jocman Posted December 4, 2010 Author Share Posted December 4, 2010 Thanks y2kiah. Unfortunately, I tried to test your suggestion, but it seems that BS doesn't see anymore my inputs. :( I don't understand what's happening: I run SIOC (by testing in SIOC the switches are working), but when I run BS, the cockpit switches don't move. But I didn't make any change to anything. Yesterday (when everything was working) I simply shut off the PC. today it seems as I did no work yesterday. What can I check??? EDIT: I made a test by deleting in ExportSupport.lua the definition for the cover+switch just added. Everything works now.... I don't understand why. I should write in such specific way the new code? I simply added the new string at the bottom of ExportSupport.Lua. Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
y2kiah Posted December 4, 2010 Share Posted December 4, 2010 hmm this is a shot in the dark but I can't see what else it might be, and I vaguely recall having an issue with the word "device" as a variable name some time in the past... though it could just be my imagination. Try this... function TwoPositionCoverAndSwitch(pValue, pDevice, pNumber, pCoverNumber, pOnValue, pInvert) if pInvert then if pValue == 1 then pValue = 0 else pValue = 1 end end local dev = GetDevice(pDevice) if pValue == 1 then -- flipping it on, open the cover first dev:performClickableAction(pCoverNumber + 3000, pValue * pOnValue) dev:performClickableAction(pNumber + 3000, pValue * pOnValue) else -- flipping it off, close the cover last dev:performClickableAction(pNumber + 3000, pValue * pOnValue) dev:performClickableAction(pCoverNumber + 3000, pValue * pOnValue) end end Link to comment Share on other sites More sharing options...
Jocman Posted December 4, 2010 Author Share Posted December 4, 2010 Update. Currently I'm totally blocked, as after a pause of 1 hour (gone gym, leaving the PC on with the cards connected), when I'm back I realized I was continuosly listening to the Win' sound "USB disconnected" alert...... And it happens every 10 seconds..... If I check the SIOC software, I can see that the card is connected / disconnected / connected / disconnected.... and so on. If I fisically disconnect the USB, the sound stops. What the hell is happening????? My OC card is screwed???? (hope not....) or there's something wrong with the PC's USB drivers ? (I don0t think, because all the pther external devices work fine.... Help....... Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Scudslaker Posted December 5, 2010 Share Posted December 5, 2010 you soldered the oc card your own? look for some hot spots on the usb connecter, maybe you have some bad soldering or mechanical force on the connector..so pls check the pcb for alternating currents!) TM HOTAS WH :joystick:, Saitek Pro Pedals, Track IR 4, 2xJoyWarrier, 1x KeyWarrior, i52500k @4600MHz, ASUS P8Z68-V Pro, NV 670GT, SSD+ WD BC+ WD Raptor, 32HD:pilotfly:[sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Jocman Posted December 5, 2010 Author Share Posted December 5, 2010 hmm this is a shot in the dark but I can't see what else it might be, and I vaguely recall having an issue with the word "device" as a variable name some time in the past... though it could just be my imagination. Try this... function TwoPositionCoverAndSwitch(pValue, pDevice, pNumber, pCoverNumber, pOnValue, pInvert) if pInvert then if pValue == 1 then pValue = 0 else pValue = 1 end end local dev = GetDevice(pDevice) if pValue == 1 then -- flipping it on, open the cover first dev:performClickableAction(pCoverNumber + 3000, pValue * pOnValue) dev:performClickableAction(pNumber + 3000, pValue * pOnValue) else -- flipping it off, close the cover last dev:performClickableAction(pNumber + 3000, pValue * pOnValue) dev:performClickableAction(pCoverNumber + 3000, pValue * pOnValue) end end IT WORKS!!!! Great help, y2kiah! Thanks a lot!! you soldered the oc card your own? look for some hot spots on the usb connecter, maybe you have some bad soldering or mechanical force on the connector..so pls check the pcb for alternating currents!) Scudslaker, I got the cards "ready to plug". Anyway, this morning our logistic section reported about a failure in the power line (maybe less voltage...) yesterday; today the power line is fine again. So I decided to test again the cards: they work perfectly. I'm just wondering: I'm using a laptop, with its own battery pack, connected to the power line. even if the power line has a failure, the battery doesn't provide a linear power???? Anyway, the important thing is that I can keep wotking on BS. Thanks all!!! Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Jocman Posted December 5, 2010 Author Share Posted December 5, 2010 I’m trying to program a 3 pos switch, following Oakes’s hints.He says to use the SimpleRotary function, treating a 3 pos switch like a rotary, then suggest to have a look to the following SIOC code Var 0506, name BurstLenShort, Link IOCARD_SW, Input 8 { IF &BurstLenShort = 1 { &BurstLen = 1 } IF &BurstLenShort = 0 { &BurstLen = 2 } } Var 0507, name BurstLenLong, Link IOCARD_SW, Input 6 { IF &BurstLenLong = 1 { &BurstLen = 3 } IF &BurstLenLong = 0 { &BurstLen = 2 } } Var 0510, name BurstLen, Value 1 I adapted the code to the switch I’m going to set (is the Inv Auto Man switch in the electric panel). This is the code I wrote: Var 0010, name InvAuto1, Link IOCARD_SW, Input 6 // Electric System { IF &InvAuto1 = 1 { &InvAuto = 1 } IF &InvAuto1 = 0 { &InvAuto = 2 } } Var 0011, name InvAuto2, Link IOCARD_SW, Input 7 // Electric System { IF &InvAuto2 = 1 { &InvAuto = 3 } IF &InvAuto2 = 0 { &InvAuto = 2 } } Var 0012, name InvAuto, Value 0 (I put 0, as I think the default position should be in the middle, otherwise how to choose this value????) This is how I think it works: it use a reference var (in this case 12), to change its value (1-2-3); this (1-2 or 3), as I understood, is the value sent to export.lua. This is true? But now, how the set sioc.lua??? I wrote this code in sioc.lua [10] = {SimpleRotary, 2, 10}, [11] = {SimpleRotary, 2, 11} But of course, it doesn’t work…. I think I shoul refer to var 12, but i don't think I can write something like: [12] = {SimpleRotary, 2, 10}, [12] = {SimpleRotary, 2, 11} repeating the [12] twice.... This is another big obstacle to pass, as if it will be so difficult to program a 3 pos switch, I can’t imagine what about a x pos rotary switch (to not talk about the rotary encoders….). Someone could explane in an easy way the phylosophy of this function? (I'm a sunday's coder......) Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Oakes Posted December 6, 2010 Share Posted December 6, 2010 (edited) Hi Mate This is how the parameters are connected [12] = {SimpleRotary, 2, 10} => function SimpleRotary([color=Red]pValue[/color], [color=Blue]pDevice[/color], [color=Lime]pNumber[/color]) GetDevice([color=Blue]pDevice[/color]):performClickableAction([color=Lime]pNumber[/color] + 3000,([color=Red]pValue[/color] - 1)/10) end Note: pValue is not equal to 12, pValue is equal to the value of SIOC parameter nbr 12 (in this case 1, 2 or 3 depending on the switch position). In other words we have written some code with the following meaning: "Please Mr Lua, whenever the value of SIOC variable nbr 12 changes I would like you to take this new value, subtract 1 and then divide the result with 10 and then send it to the button nbr 10 on the device with device-id of 2" So, you have a 3 position switch and a SIOC variable that will be either 1, 2 or 3 depending on the position of the switch. When ever you change this variable, the LUA code will send an appropriate value to the DCS:BS. In this case DCS:BS wants to have 0, 0.1 and 0.2 for the 3 positions of the switch. (hence the (pValue -1) /10) => SIOC variable nbr 12 = 1 => (1-1)/10 = 0 => SIOC variable nbr 12 = 2 => (2-1)/10 = 0.1 => SIOC variable nbr 12 = 1 => (3-1)/10 = 0.2 btw, which switch are you trying to set, button number 10 on device nbr 2? or button nbr 11 on device nbr 2 (this one doesnt exist btw). Why using 0, 0.1 and 0.2? If we assume that you want to set button number 10 on on device nbr 2 this is the code (from clickabledata.lua), intresting bit in purple: elements["CONVERTER-PTR"] = {class = {class_type.TUMB, class_type.TUMB}, hint = LOCALIZE("DC/AC inverter"), device = devices.ELEC_INTERFACE, action = {device_commands.Button_10, device_commands.Button_11}, arg = {270, 270}, [color=Magenta]arg_value = {-direction*0.1, direction*0.1}, arg_lim = {{0.0, 0.2}, {0.0, 0.2}}[/color], use_OBB = true, updatable = true}The direction bit tells us how much we need to add/remove to move 1 position up or down (0.1 in this case) for the switch and the arg_lim tells us the limits (0.0 to 0.2) => 0, 0.1 and 0.2 are acceptable values for this switch. This principle works for most of the multiposition switches in the cockpit (as far as I know anyway). A 4 position rotary is really not anything different than a 3 position microswitch etc....just write some SIOC code that assigns 1,2,3,4 to a SIOC variable depending on the position and feed this variable to LUA and it should work. If it doesn't check the clickabledata.lua to see if the particular switch is different in some way. btw, here is a compilation file for devices.lua and clickabledata.lua:http://forums.eagle.ru/showpost.php?p=764486&postcount=30 This is the code for the Datalink Master mode rotary, a 4 position rotary: elements["DTLK-MASTER-MODES-PTR"] = {class = {class_type.TUMB, class_type.TUMB}, hint = LOCALIZE("Datalink Master mode"), device = devices.DATALINK, action = {device_commands.Button_15, device_commands.Button_15}, arg = {329, 329}, arg_value = [color=Magenta]{-direction*0.1, direction*0.1}, arg_lim = {{0.0, 0.3}, {0.0, 0.3}}[/color]}and its corresponding SIOCConfig line [595] = {SimpleRotary, 25, 15}, 595 = 1 ,2 3, or 4 depending on the position of the rotary => DCS:BS gets 0, 0.1, 0.2 or 0.3 which is OK according to clickabledata.lua /Oakes /Oakes Edited December 6, 2010 by Oakes Link to comment Share on other sites More sharing options...
Jocman Posted December 6, 2010 Author Share Posted December 6, 2010 Hi Oakes. Thanks for your explanation. btw, which switch are you trying to set, button number 10 on device nbr 2? or button nbr 11 on device nbr 2 (this one doesnt exist btw). Well, I talk about 10 and 11 because in Clickabledata.lua I found: elements["CONVERTER-PTR"] = {class = {class_type.TUMB, class_type.TUMB}, hint = LOCALIZE("DC/AC inverter"), device = devices.ELEC_INTERFACE, action = {device_commands.Button_10, device_commands.Button_11}, arg = {270, 270}, arg_value = {-direction*0.1, direction*0.1}, arg_lim = {{0.0, 0.2}, {0.0, 0.2}}, use_OBB = true, updatable = true} So, it reports 2 device_commands.button value BTW, I tried again but it doesn't work. So, I tried a lucky shot: I changed the reference var value to 2, for this reason: if the switch is 1-2-3, it means that the middle position will be 2. Now, I don't know if this was a right tough, but now it works fine.... But if it is right, how to think concerning a x position switch (linear or rotary)? There will be no "middle position", so wich value put there? Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Jocman Posted December 7, 2010 Author Share Posted December 7, 2010 Hi guys. I'm going on with the programming of SIOC. Currently I'm working on the right side panel (electric, fuel, etc...) having the following trouble: - VHF1 and VHF2: I'm using the following code: [23] = {TwoPositionSwitch, 49, 5, 1}, [24] = {TwoPositionSwitch, 48, 11, 1}, But the 2 switches don't work; I double checked the parameters, but nothing to do. - EJECT SEAT SYS: I would like to use just 1 input (2 pos switch) to make the cover flip on, then all 3 switches ON. By following the suggestion of y2kiah, I wrote in ExportSupport.lua the following code: function TwoPositionEjectionSystem(pValue, pDevice, pNumber1, pNumber2, pNumber3, pCover, pOnValue, pInvert) if pInvert then if pValue == 1 then pValue = 0 else pValue = 1 end end local dev = GetDevice(pDevice) if pValue == 1 then -- Flip on then switch 3 switches on dev:performClickableAction(pCover + 3000, pValue * pOnValue) dev:performClickableAction(pNumber1 + 3000, pValue * pOnValue) dev:performClickableAction(pNumber2 + 3000, pValue * pOnValue) dev:performClickableAction(pNumber3 + 3000, pValue * pOnValue) else -- Switch 3 switches off then flip off dev:performClickableAction(pNumber3 + 3000, pValue * pOnValue) dev:performClickableAction(pNumber2 + 3000, pValue * pOnValue) dev:performClickableAction(pNumber1 + 3000, pValue * pOnValue) dev:performClickableAction(pCover + 3000, pValue * pOnValue) end end then in SIOC.lua: [28] = {TwoPositionEjectionSystem, 6, 1, 2, 3, 4, 1} When I test it, I got something like: switch on: flip on, turn the swithches on then flip off if I switch off the on again, i get the cover flip on then the switches on (but I expect the get this result the first time, not the second). then trying again and again i get the with the switch off, the cover and the 3 switches are on...... What's wrong? Last question: while analyzing the clickabledata.lua, i've seen (alway concerning the right side panel) the following code: elements["CONTROL-OIL-PTR"] = {class = {class_type.BTN}, hint = LOCALIZE("Fuel quantity indicator self test button"), device = devices.FUELSYS_INTERFACE, action = {device_commands.Button_14}, stop_action = {device_commands.Button_14}, arg = {616}, arg_value = {1.0}, arg_lim = {{0, 1}}, use_release_message = {true}} It should be a push button. But there's no such a push button in the panel, at least with this function.... and is not the only one (check also line 81 and 104). Where are those push buttons??? Thanks Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Jocman Posted December 11, 2010 Author Share Posted December 11, 2010 First X-positions rotary switch programmed (PVI's Nav Master Switch): it works great. Always gratefull to Oakes for his outstanding job. Someway I fixed the problems concerning the "fake" BTNs on right panel: just created a "ghost" var to match to each "suspected" input, then tested in BS until find it in the cockpit. Concerning my problem with the Ejection System 3 + cover switches: any suggestion? And (this is to Oakes): any news about the rotary encoder script? Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Oakes Posted December 17, 2010 Share Posted December 17, 2010 Rotary encoder: Haven't had the time for those yet, have some ideas though... Should we collaborate a little to get it to work? Which rotary would you like to start with? Can you give me the clickabledata.lua and device number for the rotary? Have you connected a rotary to the mastercard etc..? Does it work in SIOC? /Oakes Link to comment Share on other sites More sharing options...
RightStuff Posted December 17, 2010 Share Posted December 17, 2010 Have you connected a rotary to the mastercard etc..? Does it work in SIOC? So far I have noch practical experience with OC / SIOC, but I think this website will be worth taking a look: http://www.lekseecon.nl/howto.html#rotaryencode Link to comment Share on other sites More sharing options...
Jocman Posted December 19, 2010 Author Share Posted December 19, 2010 Rotary encoder: Haven't had the time for those yet, have some ideas though... Should we collaborate a little to get it to work? Which rotary would you like to start with? Can you give me the clickabledata.lua and device number for the rotary? Have you connected a rotary to the mastercard etc..? Does it work in SIOC? /Oakes Hi Mate. Of course, it will be a pleasure to cooperate. About the rotary encoder, as is the first I encountered on my way (I started programming the panels from the right side) I was thinking to start with the NAV Brightness: elements["PVI-BRIGHTNESS-PTR"] = {class = {class_type.LEV}, hint = LOCALIZE("NAV Brightness"), device = devices.PVI, action = {device_commands.Button_29}, arg = {327}, arg_value = {0.001}, arg_lim = {{0.0, 1.0}}, gain = {0.1}, use_OBB = false} Well, probably in the real Ka50 I think is a pot, but in the sim I think it works as a rotary encoder. If to you is fine, we can try with this.ù Actually I didn't connect an encoder to the card, so never tried in SIOC. To be honest, I'm having some...problem with the cards: I finished all the inputs (72) on the first master, so I would like to start with the 2nd master. But I can't figure out how to set the SIOC.ini with more masters. The command master=0,4,1,20 means that I'm using 1 device (0), this device is an USB exp (4), with 1 master connected (1) un the USB ID 20. This is correct? if is so, why if I put: master=0,4,4,20 and I connect a 2nd master on J3 (I can't right now connect to J2 - I don't have the cable, and more here in Kabul I've only 1 USB exp + 1 master), nothing works anymore? (LED on USB exp always on, if I check with controlador I get a lot of input working at the same time, etc etc). I programmed a variable [85] to link to the new master input, I numbered this input once again as "1" (is the 1st input of the second master), but doesn't work..... Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Oakes Posted December 19, 2010 Share Posted December 19, 2010 Hi mate I think you need to put master=1,4,4,20 for the second master card, but I'm not sure, I've only used 1 master card so far. These might help: http://www.lekseecon.nl/sioc.html#mainwindow http://www.lekseecon.nl/howto.html#device /Oakes Link to comment Share on other sites More sharing options...
Jocman Posted December 20, 2010 Author Share Posted December 20, 2010 Hi mate I think you need to put master=1,4,4,20 for the second master card, but I'm not sure, I've only used 1 master card so far. These might help: http://www.lekseecon.nl/sioc.html#mainwindow http://www.lekseecon.nl/howto.html#device /Oakes Well, mate, I tried already with the code you suggest, but it doesn't work. Changing the first number means that I'm using another USB exp. The only way to tell SIOC I'm using more master on the same USB exp is to change the 3rd number. But it doesn't work again. At least not in the way I'm working (using only 1 USB exp + 1 master). I just suppose that I MUST connect physically the master cards in the right order (J1,J2,J3,J4) otherwhise it wouldn't work. I cannot do it right now, but in the next week I'll back home for some holydays, hoping to get 3 master cards more, So I'll try with all the cards, hooping to not have any problem with the inputs' number (as they restart each for master). I asked also directly OC, but I got such a non-sense answer (like: "what time is it'" and they told me "today is raining".....). Or my english is really a sh..t, or I don't know..... Up to back home, I'll try maybe to program another SSI file only to check how the encoders work, or to thest some output. But If you wanna keep working together, let me know. Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Oakes Posted December 21, 2010 Share Posted December 21, 2010 (edited) Yep, you are correct, device is referring to the USBExp card, sorry for misleading you. I'm installing all my OC cards etc in a new rack box so I cant try this out myself right now, need a couple of more days. However, all is not lost, from the manual for the USBExp card: "INPUTS The inputs on the Master card are formed in groups of 9 + GND, this means that we have a total of 36 inputs on each input connector (J3 and J4), that is, for each Master card connected to the USBExpansion, we have 72 inputs, that multiplied by 4 cards on each USBExpansion, this means we have a total of 288 digital inputs, numbered as on the following table: [TABLE]Master card number|J3 inputs|J4 inputs 1|0 – 35|36 – 71 2|72 – 107|108 – 143 3|144 – 179|180 – 215 4|216 – 251|252 – 287[/TABLE]" Without trying this out myself I think that you only need one master line in the sioc.ini file (for the USBExp card) and then you refer to the inputs for the nbr 3 mastercard (meaning connected to J3 on the USBExp) as inputs 144 to 215. Secondly, from reading your earlier posts the above info might not be new to you (i.e use only one master line etc) but I'm not quite sure so I posted it anyway. I have a sneaky suspicion that are correct, masters need to be connected in series, otherwise, the unconnected parallel ports are electrically floating => lots of inputs on the port => USBExp led is on constantly => controlador goes nuts...etc /Oakes Edited December 21, 2010 by Oakes Link to comment Share on other sites More sharing options...
Jocman Posted December 23, 2010 Author Share Posted December 23, 2010 Yep, you are correct, device is referring to the USBExp card, sorry for misleading you. I'm installing all my OC cards etc in a new rack box so I cant try this out myself right now, need a couple of more days. However, all is not lost, from the manual for the USBExp card: "INPUTS The inputs on the Master card are formed in groups of 9 + GND, this means that we have a total of 36 inputs on each input connector (J3 and J4), that is, for each Master card connected to the USBExpansion, we have 72 inputs, that multiplied by 4 cards on each USBExpansion, this means we have a total of 288 digital inputs, numbered as on the following table: [TABLE]Master card number|J3 inputs|J4 inputs 1|0 – 35|36 – 71 2|72 – 107|108 – 143 3|144 – 179|180 – 215 4|216 – 251|252 – 287[/TABLE]" Without trying this out myself I think that you only need one master line in the sioc.ini file (for the USBExp card) and then you refer to the inputs for the nbr 3 mastercard (meaning connected to J3 on the USBExp) as inputs 144 to 215. Secondly, from reading your earlier posts the above info might not be new to you (i.e use only one master line etc) but I'm not quite sure so I posted it anyway. I have a sneaky suspicion that are correct, masters need to be connected in series, otherwise, the unconnected parallel ports are electrically floating => lots of inputs on the port => USBExp led is on constantly => controlador goes nuts...etc /Oakes Well, mate, thank you for the hint about the inputs (in 4 days i'll be at home, and i'll try with 4 masters connected). Today I tried once again with only 1 master on J1, starting a new .ssi file, just to check how the encoders works. Well, it's nice, they work very fine, at least using SIOC for the test. The problem now is to let LUA to understand the meaning of the rotation... In SIOC, following the tutorial, I set an encoder setting a limit between 0 and 359 degrees (simulating an heading selector). Having a look to clickabledata.lua, I found (i.e.) the HSI command heading selector. I think the solution should be in the values: arg_value = {0.001}, arg_lim = {{0, 1}} wich means (I hope) that the command has a range between 0 - 1 with increments of 3 decimals. Considering the code you wrote for the rotary switches, it should mean that by rotating the knob I can choose a value between 0 and 999, and maybe in SIOC I can limit this value between 0 and 359 (?) How many bulls..t did I write???? Jocman Jocman "For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci) Prev. Projects: https://forums.eagle.ru/showthread.php?t=50071 Link to comment Share on other sites More sharing options...
Oakes Posted December 23, 2010 Share Posted December 23, 2010 Hi Jocman Well, the value send to DCS:BS should be between 0 and 1, the smallest increment is 0.001 => if we divide 1 with 359 and multiply with the incoming sioc value (which is 0 to 359) and round this value to 3 decimals we should be home. Sioc value is 0 => (1/359) * 0 = 0 Sioc value is 179 => (1/359) * 179 = 0.498 Sioc value is 359 => (1/359) * 359 = 1 This will give us 1 degree for each click of the encoder. Is that good enough resolution? Probably for a HSI but maybe not for the Abris cursor. function Encoder(pValue, pDevice, pNumber, pMax, pDivide) GetDevice(pDevice):performClickableAction(pNumber + 3000,round( ((pMax /pDivide) * pValue),3)) end and [123] = {Encoder, [color=Red]25, 1[/color], 1, 359}, Want more resolution? Make the sioc var go from 0 to 719 instead and [123] = {Encoder, [color=Red]25, 1[/color], 1, 719}, This is all untested (I'm at work:)) but give it a try. Red values need to match the device and button number. /Oakes Link to comment Share on other sites More sharing options...
Recommended Posts