Jump to content

DCS-BIOS Discussion Thread


FSFIan

Recommended Posts

Well the good news is got it running - and pretty sure the root cause was I had been using the Arduino IDE and Serial Port monitor for testing a Led Matrix, which only had the port running at 9600. The ironic way I discovered it - was came out this morning to check things and much to my dismay the Genuine Mega wasn't working, so it was time to backtrack. After powering everything down and powering up and not running the Arduino IDE with other code that used the serial port, things worked fine on the Genuine Mega, so then tried the Mega with the CH340 and it also worked. PHEW

 

AH.

The only time I've run a different serial speed was on the second UART of a Mega for my A-10 altimeter tests.

 

For debugging, I usually attach an I2C 20x4 LCD to display results of tests, rather than run through the USB/serial monitor.

This may be why I've never run into the issue you had.

I guess my electronics engineer instinct was not to mess with the serial port that was running the connection.

Link to comment
Share on other sites

CSA is a surface-mounted chip (smd - not very easy for home soldering). CPA is standard package with through-hole soldering or for putting in a socket. CPE is with extra electrostatic protection - a bit more expensive but actually helpful if you cannot shield all your circuits properly. Just dont buy cheap packs from china - my first batch of 50 chips for 9$ completely went to smoke. I bought new ones for about 2€ a piece - and none have failed me since.

 

The "C" is the temperature range they're rated for:

"C" (Commercial) 0 to +70 C

"E" (Extended/Industrial) -40 to +85 C

"M" (Military) -55 to +125 C

 

The "M"s are usually ceramic, so MJA

 

The second character is the package:

"P" Plastic DIP - through-hole pins

"S" SO-8 - surface mount

"J" CERDIP - Ceramic with through-hole pins.

Link to comment
Share on other sites

Any significant difference between the Arduino Nano and the Arduino Nano Every?

 

This says

An Improved Arduino Nano

If you used Arduino Nano in your projects in the past, the Nano Every is a pin-equivalent substitute. Your code will still work, and you will NOT need to re-wire those motors you planned in your original design. The main differences are: a better processor, and a micro-USB connector. The board comes in two options: with or without headers, allowing you to embed the Nano Every inside any kind of inventions, including wearables. The board comes with tessellated connectors and no components on the B-side. These features allow you to solder the board directly onto your own design, minimizing the height of your whole prototype. Oh, and did we mention the improved price? Thanks to a revised manufacturing process, the Arduino Nano Every costs a fraction of the original Nano … what are you waiting for? Upgrade now!

 

https://store.arduino.cc/arduino-nano-every

Link to comment
Share on other sites

The main differences I have found (other than the USB connector) are that some of the PWM capable pins are different and all the digital pins on the nano-every can have interrupts, where the standard nano only has interrupts on pins 2 and 3.

Link to comment
Share on other sites

The main differences I have found (other than the USB connector) are that some of the PWM capable pins are different and all the digital pins on the nano-every can have interrupts, where the standard nano only has interrupts on pins 2 and 3.

That's handy - especially if you're running more than one rotary encoder.

I wonder if that's what the "Every" refers to?

 

Ok, thanks. So it sounds like the "every" version of the Nsno is a good choice for me.

If, as the spiel said, it's cheaper than the old Nano, I'd imagine it won't be long before the old one is retired, and all you'll get is the new one.

 

I'll probably switch myself - trying to track down a mini USB lead can be a pain, but I have plenty of micros laying about from old phones.

 

Though the clone old Nanos are about half the price of the Every.


Edited by No1sonuk
Link to comment
Share on other sites

Hi, I'm trying to remap A-10C sim outputs to F/A18C Panel displays. I have the following lua loaded to do so:

 

local function remapOutputInteger(a, b)
   hub.setPanelInteger(b, hub.getSimInteger(a))
end

hub.registerOutputCallback(function()
   local aircraftName = getSimString("MetadataStart/_ACFT_NAME")
   if aircraftName == "A-10C" then
       remapOutputInteger("A-10C/FLAPS_SWITCH", "FA-18C_hornet/FLAP_SW")
       remapOutputInteger("A-10C/GEAR_LEVER", "FA-18C_hornet/GEAR_LEVER")
       remapOutputInteger("A-10C/MASTER_CAUTION", "FA-18C_hornet/MASTER_CAUTION_LT")
   end
end)

 

 

However, it does not seem to work. Are you able to provide any assistance here?

Link to comment
Share on other sites

Hi Everybody, I have similar trouble with DCS-BIOS hub scripts, for sure I'm doing something wrong.

For example, if I try to use an F18's UFC switch on the Bf109, I [Add] on DCS-BIOS Dashboard a script mylua.lua like this:

 

hub.registerInputCallback(function(cmd, arg)

local acftName = hub.getSimString("MetadataStart/_ACFT_NAME")

if acftName == ""Bf-109K-4"" then

if cmd == "HUD_ALT_SW" then

hub.sendSimCommand("MK108_R21", arg)

return true

end

end

end)

 

but no joy...

And, if I press [Reload Scripts] i get this msg:

 

loading: C:\mylua.lua

lua error: <string>:73: cannot change the environment of given object

stack traceback:

[G]: in function 'setfenv'

<string>:73: in main chunk

[G]: ?

 

does anybody can help ?

Thank you

Link to comment
Share on other sites

Why aren’t you guys doing different modules within if statements? I’ve done that with displays and mcaution lights for three different modules and it works like a charm.

If I could make it work with 1 module first, then I'll probably be able to do with different modules.

 

Can you post an example, please?

Thanks

Link to comment
Share on other sites

I have NOT tested this. So it probably doesn;t work out of the box. (i'm obviously not a professional coder)

 

The MC lines are from an actual working script. No if/thens needed. I remember testing this and could switch from av8 to fa18 and the mc light and switch would just work. To limit the load on your arduino or teensy you should incorporate ifs to not run unnecessary code.

 

I don't have the module's names here but this is the idea:

 

/* here's how to get the module name and cast it to a string */

String dasAircraft;
FA18 = String("FA18_");
AV8B = String("AV8B");

void onAcftNameChange(char* newValue) {
Serial.println(newValue); // print the name in the serial console
dasAircraft = "newValue";
}
DcsBios::StringBuffer<24> AcftNameBuffer(0x0000, onAcftNameChange);

// use the dasAircraft string to activate part of the code and limit your *duino/teensy's resources with if/then's
//
// for example:


void onUfcOptionDisplay1Change(char* newValue) {
   /* your code here */

if (dasAircraft == FA18) {

String sNewValue(newValue); // catch newValue in string and replace odd characters
char od11 = sNewValue.charAt(0); // grab individual char value at that specific index in the string
char od12 = sNewValue.charAt(1);
char od13 = sNewValue.charAt(2);
char od14 = sNewValue.charAt(3);
alpha4.clear();
alpha4.writeDigitAscii(0, od11,0);
alpha4.writeDigitAscii(1, od12,0);
alpha4.writeDigitAscii(2, od13,0);
alpha4.writeDigitAscii(3, od14,0);
alpha4.writeDisplay();
 }


 if (dasAircraft == AV8B) {
Serial.println("this is not for the av8b"); 
 }

else {
Serial.println("not for an av8b nor fa18"); 
}

}
DcsBios::StringBuffer<4> ufcOptionDisplay1Buffer(0x7432, onUfcOptionDisplay1Change);

 

 

this works:

 



// start AV8BNA
/* Master Caution Reset button on pin 15 */
DcsBios::Switch2Pos mCaution("M_Caution", 15);
/* LED connected to pin 14 is Master Caution Light */
DcsBios::LED mcLight(0x786a, 0x0020, 14);
// end AV8BNA

// start FA18C_
/* Master Caution Reset button on pin 15 */
DcsBios::Switch2Pos masterCautionResetSw("MASTER_CAUTION_RESET_SW", 15);
/*  LED connected to pin 14 is Master Caution Light */
DcsBios::LED masterCautionLt(0x7408, 0x0200, 14);
// end FA18C_

 

btw baco30, the code is a bit bloated because I was fiddling with replacing pieces of the dcs-bios output. But this is what you're looking for. I used the same type of displays ht16k33 with the adafruit library. Just get rid of the if's en thens and start experimenting.

Link to comment
Share on other sites

I have NOT tested this. So it probably doesn;t work out of the box. (i'm obviously not a professional coder)

 

The MC lines are from an actual working script. No if/thens needed. I remember testing this and could switch from av8 to fa18 and the mc light and switch would just work. To limit the load on your arduino or teensy you should incorporate ifs to not run unnecessary code.

 

I don't have the module's names here but this is the idea:

 

(CODE CODE CODE)

 

btw baco30, the code is a bit bloated because I was fiddling with replacing pieces of the dcs-bios output. But this is what you're looking for. I used the same type of displays ht16k33 with the adafruit library. Just get rid of the if's en thens and start experimenting.

 

This is a possible way to do it, but has a couple of problems.

 

1. It bloats the Arduino code. This can cause a problem with smaller-memory boards, and even on larger memory boards if there's a lot of libraries loaded.

 

2. It requires uploading new code to the Arduino every time you add a module. Since it's plugged in anyway, this isn't such a big problem, but could be a problem if you've got several boards plugged in.

 

It's absolutely possible to do it that way - but it's bad practice to hard-code it when you can have that translation layer and treat the aircraft as polymorphic entities.

Link to comment
Share on other sites

It definitely is bloated. And my coding skills don’t do it any good either. You’re absolutely correct. /but/ if your not using your fa18 ufc for your sabre or dora I figure the damage quite minimal.

 

Personally I’m using this just for displays and an AOA indexer. So output mostly. All the buttons, encoders and pots are keyboard and joystick inputs.

 

 

Sent from my iPhone using Tapatalk

Link to comment
Share on other sites

  • 2 weeks later...

Hi there,

 

 

I am trying to learn the basics of DCS-BIOS.

Right now the goal is to display the AOA of the A-10 on LEDs.

The AOA of the A-10 reads a value of about 20k in level flight.

Here is the code:

 

 

define DCSBIOS_IRQ_SERIAL 
#include "DcsBios.h"

int RedLed = 16;

//==================== Main ===================================

void onAoaUnitsChange(unsigned int newAoaValue) {
    if (newAoaValue < 20000){
        digitalWrite(RedLed, LOW);}
    if (newAoaValue > 20000){
        digitalWrite(RedLed, HIGH);}
   }


DcsBios::IntegerBuffer aoaUnitsBuffer(0x1078, 0xffff, 0, onAoaUnitsChange);



// ============================== Essentials ==================
void setup() 
 {
DcsBios::setup();
 }

void loop() 
 {
 DcsBios::loop();
 }

Should be fairly simple, no? It does not light up any LED. What's wrong?

 

 

Thanks,

Olli

Link to comment
Share on other sites

This is what you need to use...

 

#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"

//************** AOA INDEXER **********************
DcsBios::LED aoaIndexerHigh(0x1012, 0x1000, 4);     // Red LED on pin 4
DcsBios::LED aoaIndexerNormal(0x1012, 0x2000, 5); //Green LED on pin 5
DcsBios::LED aoaIndexerLow(0x1012, 0x4000, 6);     // Red LED on Pin 6


//************** AAR INDEXER **********************
DcsBios::LED airRefuelDisconnect(0x1026, 0x0200, 9);
DcsBios::LED airRefuelLatched(0x1026, 0x0100, 8);
DcsBios::LED airRefuelReady(0x1012, 0x8000, 7);  

void setup() {
 DcsBios::setup();
}

void loop() {
 DcsBios::loop();
}

 

Read the DCS BIOS Guide and the control reference docs from the DCS BIOS download.

http://dcs-bios.a10c.de/

Regards

John W

aka WarHog.

 

My Cockpit Build Pictures...



John Wall

 

My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing

 

 

WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram,



AIO Water Cooler, M.2 512GB NVMe,

500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display

VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals

Link to comment
Share on other sites

Thanks.

 

I'm reading the manual along, but I rather learn by example code than by description.

 

I am trying to read onAoaUnitsChange, which can be converted to the AOA in degrees. The goal is to drive the LED at a certain AOA, independent of the indexer.

Link to comment
Share on other sites

I'm just trying to understand what this code does:

 

 

void onAoaUnitsChange(unsigned int newAoaValue) {
   if (newAoaValue < 20000){ // 20000 is the transmitted value for about level flight in the A-10C
     digitalWrite(RedLed, LOW);}
   if (newAoaValue > 20000){
     digitalWrite(RedLed, HIGH);}
   }
DcsBios::IntegerBuffer aoaUnitsBuffer(0x1078, 0xffff, 0, onAoaUnitsChange);

As far as I understand:

 

IntegerBuffer is a function of DCS BIOS. I don't know what aoaUnitsBuffer does.

 

 

The adress 0x1078, 0xffff is read and stored in onAoaUnitsChange.

 

 

onAoaUnitsChange is then called and the stored value is transmitted.

 

 

Within this function, it is called newAoaValue.

 

I can then use newAoaValue to control the LEDs.

 

 

 

 

 

 

Is there any way I can debug this? Like printing the state of the variables

somewhere, so I can check why the code does not do what it should?

 

 

Is there any code repository with examples on how to use BIOS? The

handbook is a bit short on these things.

210967760_2020-08-1716_25_46-Window.png.df0ac241b5077dfbf27717865d19082b.png


Edited by frumpy
Link to comment
Share on other sites

Thanks, that did something! :)

However, there is something strange going on. Some LEDs need the pinMode command, some don't. Also the pins of the Nano seem to be different than the usual Nano layout. I'll investigate when I have more time.

Link to comment
Share on other sites

However, there is something strange going on. Some LEDs need the pinMode command, some don't.

 

If you are talking about ;

int RedLed = 16;

 

versus

 

DcsBios::LED aoaIndexerHigh(0x1012, 0x1000, 4); 

 

Then that shouldn't be too strange.

 

The former is one you have defined yourself. DCS-BIOS has absolutely no knowledge of this whatsoever. As DCS-BIOS have no knowledge about it, it cannot define it to the Arduino IDE. Therefore you need to use the pinMode command, else the Arduino IDE doesn't know what to do about it. It could just have been a variable you wanted to use for something, similar to what I have done here for the frequencies of the AN/ARC-186 radio;

//Variables
int Freq1_DCS = 0;  //Initial value set for 3
int Freq2_DCS = 0;  //Initial value set for 0
int Freq3_DCS = 0;  //Initial value set for 0
int Freq4_DCS = 0;  //Initial value set for .00
int Mode_DCS = 0;   //Initial value set for OFF
int Preset_DCS = 0; //Initial value set for 1

 

 

 

The latter is using DcsBios::LED which is a defined function that already sets the pin as an output, which it will let Arduino IDE know. You can actually see this in the Leds.h file of the DCS-BIOS Library (only partly shown here);

public:
LED(unsigned int address, unsigned int mask, char pin) : Int16Buffer(address), mask(mask), pin(pin) {
pinMode(pin, OUTPUT);

 

 

Cheers

Solo

Link to comment
Share on other sites

This may be an ignorant question, but can anyone give me a quick summary on why the hub version of DCS BIOS was abandoned? I understand that Ian decided to take a break, but the idea of a shim layer in between the export.lua in DCS and the serial port, which is aware of what module is loaded in DCS and can rewrite the incoming/outgoing messages, seems like a no-brainer.

 

 

Like, it wouldn't need to have all the complexity that Ian was building into the hub -- just needs to translate from the data coming in over UDP (I think?) to serial, and potentially transform it a little..

 

Am I missing something obvious here?

Link to comment
Share on other sites

Hi Hansolo,

thanks for taking the time. As of now, this works:

 

 

#define DCSBIOS_IRQ_SERIAL //must go first!
#include "DcsBios.h"

int RedLed = 9; //D9
int YellowLed = 7; // D7
int GreenLed = 8; //D8


//==================== Main ===================================

void onAoaUnitsChange(unsigned int newAoaValue) {
   if (newAoaValue >31000 && newAoaValue < 37000)
     {digitalWrite(GreenLed, HIGH);}
   else {digitalWrite(GreenLed, LOW);}

   if (newAoaValue >37000 && newAoaValue < 43000)
     {digitalWrite(YellowLed, HIGH);}
   else {digitalWrite(YellowLed, LOW);}

   if (newAoaValue >43000 && newAoaValue < 49000)
     {digitalWrite(RedLed, HIGH);}
   else {digitalWrite(RedLed, LOW);}
 }
DcsBios::IntegerBuffer aoaUnitsBuffer(0x1078, 0xffff, 0, onAoaUnitsChange);


// ============================== Essentials ==================
void setup() 
 {
 DcsBios::setup();

 pinMode(RedLed, OUTPUT);  
 pinMode(YellowLed, OUTPUT); 
 pinMode(GreenLed, OUTPUT);
 }

void loop() 
 {
 DcsBios::loop();
  }

 

 

So far, so good! :)

 

The indexer lights will work independently of the built in AOA indexers lights of the A-10, just depending on the AOA.

 

 

However, now I want to implement this to another aircraft, like the C-101.

 

Do you know how I can find out the adress of the AOA of other aircraft?

Link to comment
Share on other sites

Any chance that the DCS Bios install routine could be updated to see non standard installations of DCS??

Ryzen 9 7950X3D - MSI MAG X670E TomaHawk MB, ASUS ROG Ryujin III 360 AIO

64gig Corsair DDR5@6000, Gigabyte GeForce RTX 4090 AORUS

Winwing Super Taurus, Orion2, TO / Combat panels, Collective with Topgun MIP

Winwing Skywalker pedals, NLR Boeing Mil Edition Simpit, Trackir

Link to comment
Share on other sites

  • Recently Browsing   0 members

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