rocketeer Posted May 31, 2019 Author Share Posted May 31, 2019 Guys, the dcs bios code in simple or advanced mode for the IFF Dial: ZERO - B - A - (HOLD) is DcsBios::RotaryEncoder iffCode("IFF_CODE", "DEC", "INC", PIN_A, PIN_B); This dial is obviously a rotary switch. I googled and can't find any code for the rotary switch. Does one exist? My A10C cockpit thread Link to comment Share on other sites More sharing options...
rocketeer Posted May 31, 2019 Author Share Posted May 31, 2019 Finally completed. :beer: Powered by 9 Arduino Megas and DCS Bios. Pimax headset with Vive delux audio strap Ejection seat arm handle. Spring loaded. My A10C cockpit thread Link to comment Share on other sites More sharing options...
Deadman Posted May 31, 2019 Share Posted May 31, 2019 Take a look at Hans Solo's thread he all ready has a IFF working https://forums.eagle.ru/showpost.php?p=3660172&postcount=238 https://www.shapeways.com/shops/a-10c-warthog-supplies https://forum.dcs.world/topic/133818-deadmans-cockpit-base-plans/#comment-133824 CNCs and Laser engravers are great but they can't do squat with out a precise set of plans. Link to comment Share on other sites More sharing options...
hansangb Posted May 31, 2019 Share Posted May 31, 2019 good lord....that's a lot of work. Congrats! hsb HW Spec in Spoiler --- i7-10700K Direct-To-Die/OC'ed to 5.1GHz, MSI Z490 MB, 32GB DDR4 3200MHz, EVGA 2080 Ti FTW3, NVMe+SSD, Win 10 x64 Pro, MFG, Warthog, TM MFDs, Komodo Huey set, Rverbe G1 Link to comment Share on other sites More sharing options...
CraigS Posted May 31, 2019 Share Posted May 31, 2019 Hi Shawn, thats brilliant, well done. Also, with the build finished, you'll have all that extra time flying. Thumbs up Sent from my SM-G955F using Tapatalk Link to comment Share on other sites More sharing options...
Hansolo Posted May 31, 2019 Share Posted May 31, 2019 Congratulations and very nice job sir :thumbup: As Deadman mentiones I used my compare code which is also used in my AN/ARC-186's, TACAN, AN/ARC-164. Basically it compares what the status is for the rotary switch and if DCS doesn't indicate the same position, then INC or DEC is send. The side consoles are they Lynx's? Once again congratulations on a complete pit. Now it's time for flying. CHeers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
rocketeer Posted May 31, 2019 Author Share Posted May 31, 2019 Thanks everyone. Hansolo, you have always been helpful to those struggling with dcs bios or the RS485 setup. Appreciate you also sharing your code for the panels. Yes the frame is from Lynx's. They are great. For the Master Mode switch i just use the default two line code and it works without problem. Question about your solution for the IFF Code switch. Normally the dcs bios code for a rotary switch is a 2 line code as a multiposition switch. Somehow this time for the IFF code switch it's not possible to be so. I see your solution is about 30-40 lines for this one switch. I guess it was necessary else you wouldn't make it so long for this one switch. Question: //Code dial inputs DDRC = B00000000; // set PINA (digital 30-37) as inputs PORTC = B11111111; // Sets (digital 30-37) with internal pull up tm.startTimer(200, setIFF); what is this internal pull up thing? is there some resistor that i need to add or just a software declaration here? My A10C cockpit thread Link to comment Share on other sites More sharing options...
rocketeer Posted May 31, 2019 Author Share Posted May 31, 2019 Second question. The solution by Quick, edit the A10c lua file: find: define3PosTumb("IFF_OUT_AUDIO_LIGHT", 43, 3009, 301, "IFF", "IFF Out: LIGHT - OFF - AUDIO") replace: defineTumb("IFF_OUT_AUDIO_LIGHT", 43, 3009, 301, 1,{-1, 1}, nil, true,"IFF", "IFF Out: LIGHT - OFF - AUDIO") Did it work for you? In the sim, using the mouse, this toggle will flip up, down, center at about 45 degrees. Using dcs bios, flipping the physical toggle will also move the toggle in the sim up and down like 5 degrees, the movement is hardly noticeable. I edited the lua file and replaced the suggested code and it still moves a little bit only. Does the suggested code change work or am I missing a step? All other toggles in the IFF panel flip up and down to a much bigger degree as always. My A10C cockpit thread Link to comment Share on other sites More sharing options...
Hansolo Posted June 1, 2019 Share Posted June 1, 2019 I see your solution is about 30-40 lines for this one switch. I guess it was necessary else you wouldn't make it so long for this one switch. Question: //Code dial inputs DDRC = B00000000; // set PINA (digital 30-37) as inputs PORTC = B11111111; // Sets (digital 30-37) with internal pull up tm.startTimer(200, setIFF); what is this internal pull up thing? is there some resistor that i need to add or just a software declaration here? It's necessary with the real panel only. Thing is that the original rotary doesn't have one pin active when when in A position, one pin active when in B position and so on. It's a matrix of active inputs where I found enough useful to be able to determine which position the switch was in. Since you don't have that problem it should be relatively easy to change out the long code that termines which position the switch is in with a lot shorter one. The internal pull up is something which is done via the software setting the inputs high as default. DCS-BIOS IMHO does the same which is why we use GND on switches to the input to low which is then determined as an activation of that input. Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
Hansolo Posted June 1, 2019 Share Posted June 1, 2019 (edited) Second question. The solution by Quick, edit the A10c lua file: find: define3PosTumb("IFF_OUT_AUDIO_LIGHT", 43, 3009, 301, "IFF", "IFF Out: LIGHT - OFF - AUDIO") replace: defineTumb("IFF_OUT_AUDIO_LIGHT", 43, 3009, 301, 1,{-1, 1}, nil, true,"IFF", "IFF Out: LIGHT - OFF - AUDIO") Did it work for you? In the sim, using the mouse, this toggle will flip up, down, center at about 45 degrees. Using dcs bios, flipping the physical toggle will also move the toggle in the sim up and down like 5 degrees, the movement is hardly noticeable. I edited the lua file and replaced the suggested code and it still moves a little bit only. Does the suggested code change work or am I missing a step? All other toggles in the IFF panel flip up and down to a much bigger degree as always. Yes it is working for me. I did the corrections in this folder; ...Saved GamesDCS.openbetaScriptsDCS-BIOSlib This is a test I just did; Looking at the code I am wondering if a small change to the CODE dial would work; Change defineFixedStepTumb("IFF_CODE", 43, 3007, 199, 0.1, {0.0, 0.3}, {1, -1}, nil, "IFF", "IFF Code: ZERO - B - A - (HOLD)") Into defineTumb("IFF_CODE", 43, 3007, 199, 0.1, {0.0, 0.3}, nil, true, "IFF", "IFF Code: ZERO - B - A - (HOLD)") Might be worth a try? Cheers Hans Edited June 1, 2019 by Hansolo 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
rocketeer Posted June 2, 2019 Author Share Posted June 2, 2019 This is embarassing. I changed the A10C.lua file under my downloads\dcs bios folder! Because that's my idea where lua files are located. :music_whistling: Looking at your screenshot, then I realized that I should change the lua file under Saved Games subfolder. :doh: Now the IFF Audio Light Toggle switch works! It flips up and down in big swings like the other toggles. Thanks so much! :thumbup::thumbup::thumbup: My A10C cockpit thread Link to comment Share on other sites More sharing options...
Hansolo Posted June 2, 2019 Share Posted June 2, 2019 Perfect sir. Glad you got it working. Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
rocketeer Posted June 2, 2019 Author Share Posted June 2, 2019 Hansolo, thanks for being patient and so helpful. :notworthy: Now as for the IFF Code Dial, i believe after we change the A10C.lua file with this line: defineTumb("IFF_CODE", 43, 3007, 199, 0.1, {0.0, 0.3}, nil, true, "IFF", "IFF Code: ZERO - B - A - (HOLD)") we are to still use your long code and not the default 2 lines dcs bios code? I have stripped away the long code for all other switches and left only the relevant code for the IFF Dial below. Did I get it right? Timer tm; int Code_dial_ingame = 1; // hold value from DCS //IFF Code: ZERO - B - A - (HOLD) void onIffCodeChange(unsigned int newValue_Code) { Code_dial_ingame = newValue_Code; } DcsBios::IntegerBuffer iffCodeBuffer(0x111a, 0xc000, 14, onIffCodeChange); void setup() { DcsBios::setup(); //Code dial inputs DDRC = B00000000; // set PINA (digital 30-37) as inputs PORTC = B11111111; // Sets (digital 30-37) with internal pull up tm.startTimer(200, setIFF); } int inputCode_dial() { int valueCode_dial; if (PINC == B11111111) { valueCode_dial = 0; //ZERO } if (PINC == B01111111) { valueCode_dial = 1; //B } if (PINC == B10111111) { valueCode_dial = 2; //A } if (PINC == B11011111) { valueCode_dial = 3; //HOLD } return valueCode_dial; } void loop() { DcsBios::loop(); tm.runTimers(); } void setIFF(int timer){ if (Code_dial_ingame < inputCode_dial()) { sendDcsBiosMessage("IFF_CODE", "INC"); } if (Code_dial_ingame > inputCode_dial()) { sendDcsBiosMessage("IFF_CODE", "DEC"); } } At the end, we are still using a rotary encoder, to rotate clockwise/anti-clockwise correct? Because I see the message for INC or DEC. Normally we would use a rotary switch, which will mean defining a multipos switch and stating how many pins. But there are only 4 positions on the IFF Code Dial, but you stated: // set PINA (digital 30-37) as inputs for DDRC and PORTC, whatever these two are? That is 8 inputs each. double of what i expected. Can you elaborate why and what for? Physically, how should I wire the switch? Am I still using a rotary encoder, that normally has only 3 legs? A rotary switch if used would be 4 legs plus the ground. Your code is too advanced for me. :wacko: This PINC, not sure what it is for. But it is B + a 8 digit number that changes by 1 or 0. and that determines the position of the dial. My A10C cockpit thread Link to comment Share on other sites More sharing options...
Hansolo Posted June 2, 2019 Share Posted June 2, 2019 Question is if you want to use the rotary encoder or a rotary switch? If it is the former then you don’t need to do anything. You just leave your code as it was using; DcsBios::RotaryEncoder iffCode("IFF_CODE", "DEC", "INC", PIN_A, PIN_B); If you want to use a rotary switch then this is what you do; The modification of the A10C.lua didn’t work. I did a quick test and it’s a little more tricky than that so you forget about; defineTumb("IFF_CODE", 43, 3007, 199, 0.1, {0.0, 0.3}, nil, true, "IFF", "IFF Code: ZERO - B - A - (HOLD)") Please revert your A10C.lua to; defineFixedStepTumb("IFF_CODE", 43, 3007, 199, 0.1, {0.0, 0.3}, {1, -1}, nil, "IFF", "IFF Code: ZERO - B - A - (HOLD)") What you do instead is load following code; /* Tell DCS-BIOS to use a serial connection and use interrupt-driven communication. The main program will be interrupted to prioritize processing incoming data. This should work on any Arduino that has an ATMega328 controller (Uno, Pro Mini, many others). */ #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #include <timer.h> Timer tm; int Code_dial_ingame = 1; // hold value from DCS //Define the inputs for rotary switch const int code_zero = 5; const int code_B = 6; const int code_A = 7; const int code_hold = 8; //IFF Code: ZERO - B - A - (HOLD) void onIffCodeChange(unsigned int newValue_Code) { Code_dial_ingame = newValue_Code; } DcsBios::IntegerBuffer iffCodeBuffer(0x111a, 0xc000, 14, onIffCodeChange); void setup() { DcsBios::setup(); pinMode(code_zero, INPUT_PULLUP); pinMode(code_B, INPUT_PULLUP); pinMode(code_A, INPUT_PULLUP); pinMode(code_hold, INPUT_PULLUP); tm.startTimer(200, setIFF); } int inputCode_dial() { int valueCode_dial; if (digitalRead(code_zero) == LOW) { valueCode_dial = 0; //ZERO } if (digitalRead(code_B) == LOW) { valueCode_dial = 1; //B } if (digitalRead(code_A) == LOW) { valueCode_dial = 2; //A } if (digitalRead(code_hold) == LOW) { valueCode_dial = 3; //HOLD } return valueCode_dial; } void loop() { DcsBios::loop(); tm.runTimers(); } void setIFF(int timer) { if (Code_dial_ingame < inputCode_dial()) { sendDcsBiosMessage("IFF_CODE", "INC"); } if (Code_dial_ingame > inputCode_dial()) { sendDcsBiosMessage("IFF_CODE", "DEC"); } } This is probably more eatable than my code but does more or less same. It reads the the input from your code dial and sets it’s value (variable valueCode_dial), then compares what ingame position is (variable Code_dial_ingame). If they are not identical then it will INC or DEC at intervals of 200ms. I have checked the code and it works The code you posed in #663 won’t compile at all as it is missing stuff primarily in the beginning. With the above code you don’t have to worry about DRRC, PORTC and similar. They are a vay for quickly checking multiple pins at the same time which comes in handy sometimes using mil-spec rotaries. There is a little more infor here on the subject; https://www.arduino.cc/en/Reference/PortManipulation Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
rocketeer Posted June 3, 2019 Author Share Posted June 3, 2019 Han, thanks so much for always being prompt with reply and solutions. You said to use arduinos with ATMega328 controller. I have Megas and Nanos. The nano has ATMega328P. will that work? I tried your new code. It says fatal error: timer.h: No such file or directory I googled and import a few timer zip files into the library. All contains the timer.h file. Each time I compile it still says no such file. So now I am stuck since it can't compile. Also please let me know if I can use theNano or I need to get a pro mini/uno etc. THANKS!!! My A10C cockpit thread Link to comment Share on other sites More sharing options...
Hansolo Posted June 3, 2019 Share Posted June 3, 2019 Try this; https://www.dropbox.com/s/izmxojksfrm4ros/Timer-master.rar?dl=0 There is am example included if you get it installed correctly Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
rocketeer Posted June 5, 2019 Author Share Posted June 5, 2019 Han, thanks for the file. It works. Well sort of. First I tried on my laptop. Arduino compiled. But in DCS the turning of the knob stops at the two ends, ZERO and HOLD. When in between at A or B, the whole knob rotates CW and CCW continuously! It only stops this crazy self rotating when I hit ZERO or HOLD. Then I tried my new gaming PC. Arduino won't even compile when processor is ATmega328. It does compile when I choose the second option ATmega 328 (old bootloader). Then using Quick's Dcsbios Debug Tool, I could see the turns give out INC or DEC. But in DCS it does not rotate at all. Other toggles and the other dial would turn except this one. So one works partially on my laptop, self rotating in between A and B. The other does not work at all on the PC. And compiles only choosing old bootloader. So strange. I am not using the latest dcs bios version. i'm using dcs-bios-v0.7.1. Since all my other arduino boards and switches work, i'm afraid to change the version and screw up something. My A10C cockpit thread Link to comment Share on other sites More sharing options...
Hansolo Posted June 6, 2019 Share Posted June 6, 2019 Have you done below, i.e. reverted the A10C.lua to it's original code? The modification of the A10C.lua didn’t work. I did a quick test and it’s a little more tricky than that so you forget about; defineTumb("IFF_CODE", 43, 3007, 199, 0.1, {0.0, 0.3}, nil, true, "IFF", "IFF Code: ZERO - B - A - (HOLD)") Please revert your A10C.lua to; defineFixedStepTumb("IFF_CODE", 43, 3007, 199, 0.1, {0.0, 0.3}, {1, -1}, nil, "IFF", "IFF Code: ZERO - B - A - (HOLD)") Because I can't get mine to rotate continuously between A and B. What type of rotary switch are you using? The reason (I think) for only compiling on old bootloader on PC might be because it's a never version on Arduino IDE. I never had the error before and I have been using same Nano's all along. Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
rocketeer Posted June 8, 2019 Author Share Posted June 8, 2019 Han, thanks for your suggestion again. I thought I have reverted back to the old lua but seems like i didn't. Guess i did that for my laptop but forgot to do so for the PC. Anyway, I can't test it right now. Two days ago I installed VoiceAttack. Got that to work and add conditions for various menu. Then installed Viacom free license. Got that to work too. But when I bought the pro license, it seemed to have broken dcs bios. Not sure how. Now all switches don't work. I'd try deleting the saved games sub folders etc. to get dcs bios working first before i can test the IFF. Thanks for your help as always. My A10C cockpit thread Link to comment Share on other sites More sharing options...
rocketeer Posted June 9, 2019 Author Share Posted June 9, 2019 I copied the a10c.lua file from a zip download and put it in the saved games sub folder and replaced existing file. now dcs bios works for all switches! yay. I had to edit this new lua file to fix that toggle again. Now the IFF Code dial and the audio light toggle work. OMG! thanks Han! My A10C cockpit thread Link to comment Share on other sites More sharing options...
Hansolo Posted June 9, 2019 Share Posted June 9, 2019 You're welcome sir ???? Glad you sorted it out Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
rocketeer Posted June 9, 2019 Author Share Posted June 9, 2019 Guys, from the above mission briefing, I know 132 is the AM ATC frequency, 251 is UHF, 40.6 is the FM. Any idea what is the 261 and 4.3 MHz? My A10C cockpit thread Link to comment Share on other sites More sharing options...
rocketeer Posted June 11, 2019 Author Share Posted June 11, 2019 nobody knows what are these frequencies? My A10C cockpit thread Link to comment Share on other sites More sharing options...
rocketeer Posted June 22, 2019 Author Share Posted June 22, 2019 Han, I finally got the NAND chip. Following the diagram provided, i've wired them. 1. Did I wire them correctly? 2. Any other pins on the chip need wiring to the arduino? My A10C cockpit thread Link to comment Share on other sites More sharing options...
sharkfin61 Posted June 22, 2019 Share Posted June 22, 2019 (edited) nobody knows what are these frequencies? 261 MHz is the TWR UHF (AM) freq, 4.300 MHz the HF (AM) freq of Senaki airfield. 251 MHz is the UHF interplane frequency between you and your wingmen. Edited June 22, 2019 by sharkfin61 sharkfin out! Support your local AirTransportWing ! Roal Bavarian Airforce all the way NEW RIG: RYZEN 7 5800X3D~ AORUS GTX 1080Ti ~ AORUS X570S Elite AX ~64 GB Corsair Venegance DDR-4 3600 ~ BeQuiet AIO Silent loop 2 360 watercooled ~ Samsung 890 Pro M.2 (2TB) + 870 EVO (1TB) SSD ~ WIN 10 64-bit ~ AOC 31.5" Gaming 144Hz Display ~ DelanClip@TrackIR 5 ~ TM Warthog no.2 ~Saitek rudder pedals~ 2 TM MFDs on 2nd 27"display ~ Buddyfox A-10 UFC ~ CDU/AAP panel via DCSBios ~ ARC-210 (soldering WIP) Link to comment Share on other sites More sharing options...
Recommended Posts