Jump to content

My A-10C preparation


rocketeer

Recommended Posts

  • Replies 680
  • Created
  • Last Reply

Top Posters In This Topic

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

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

AAkG1E8.png

 

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 by Hansolo
Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!!!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...
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 by sharkfin61

sharkfin out!

Support your local AirTransportWing !

Roal Bavarian Airforce all the way

NEW RIGRYZEN 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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...