Jump to content

DCS-BIOS Discussion Thread


FSFIan

Recommended Posts

At the moment, the code changes the dial to "0" but nothing else moves when I turn the dial. I am going to try changing it to an 8 pin port like A, just to get it working, in case D is just not friendly to my use (!). If I can prove it works at least, then I can worry about changing to more exotic ports, or add more Arduino boards....

 

I also need to check my Pin values. I think I initially put them in back to front. I will make some test settings to check the correct pin values.

 

Hi Molevitch,

 

 

I think we need to find a pinout for the Mega you are using. The one I am looking at (http://osoyoo.com/wp-content/uploads/2017/08/arduino_mega_2560_pinout.png) I can actually only find PORTD D0-3 (pins 21-18 ) & D7 (pin 38 ).

 

Secondly you have a small issue in the comparrision part;

 

// Check and adjust 2nd dial
   if (DCS_valueDial_2 == inputDial_2()) {
    if ( inputDial_2() == 0){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "0");
 }
    if ( inputDial_2() == 1){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "10");
 }
    if ( inputDial_2() == 2){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "20");
 }
    if ( inputDial_2() == 3){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "30");
 }
    if ( inputDial_2() == 4){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "40");
 }
    if ( inputDial_2() == 5){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "50");
 }
    if ( inputDial_2() == 6){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "60");
 }
    if ( inputDial_2() == 7){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "70");
 }
    if ( inputDial_2() == 8){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "80");
 }
    if ( inputDial_2() == 9){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "90");
 }
}

Isn't correct. What you are doing is saying "If DCS value and the hardware dial are EQUAL (==) then adjust and send new messages"

 

What you should be saying is "If DCS value is NOT EQUAL (!=) to hardware dials then adjust and send new message";

 

// Check and adjust 2nd dial
   if (DCS_valueDial_2 != inputDial_2()) {

 

Notice == is exchanged with !=.

 

Checking the inputs are easily done with a small multimeter. Doesn't have to cost a fortune, just need to be able to measure VDC. Place the black probe in GND on the Arduino and the measure the voltage on each input with the red probe. If nothing is activated then all the pins on a port should 5VDC

 

 

Cheers

Solo

Link to comment
Share on other sites

Work in Progress, ARK-9 taming.

 

Hi Molevitch,

 

 

I think we need to find a pinout for the Mega you are using. The one I am looking at (http://osoyoo.com/wp-content/uploads/2017/08/arduino_mega_2560_pinout.png) I can actually only find PORTD D0-3 (pins 21-18 ) & D7 (pin 38 ).

 

Secondly you have a small issue in the comparrision part;

 

// Check and adjust 2nd dial
   if (DCS_valueDial_2 == inputDial_2()) {
    if ( inputDial_2() == 0){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "0");
 }
    if ( inputDial_2() == 1){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "10");
 }
    if ( inputDial_2() == 2){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "20");
 }
    if ( inputDial_2() == 3){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "30");
 }
    if ( inputDial_2() == 4){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "40");
 }
    if ( inputDial_2() == 5){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "50");
 }
    if ( inputDial_2() == 6){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "60");
 }
    if ( inputDial_2() == 7){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "70");
 }
    if ( inputDial_2() == 8){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "80");
 }
    if ( inputDial_2() == 9){
   sendDcsBiosMessage("ARC_MAIN_10KHZ", "90");
 }
}

Isn't correct. What you are doing is saying "If DCS value and the hardware dial are EQUAL (==) then adjust and send new messages"

 

What you should be saying is "If DCS value is NOT EQUAL (!=) to hardware dials then adjust and send new message";

 

// Check and adjust 2nd dial
   if (DCS_valueDial_2 != inputDial_2()) {

 

Notice == is exchanged with !=.

 

Checking the inputs are easily done with a small multimeter. Doesn't have to cost a fortune, just need to be able to measure VDC. Place the black probe in GND on the Arduino and the measure the voltage on each input with the red probe. If nothing is activated then all the pins on a port should 5VDC

 

 

Cheers

Solo

 

Hi Solo,

 

It was my mistake to "correct" the != to ==. I thought it was a typo.... (me not being a coder!).

 

I have retyped it as !=.

 

I have also looked at PortD again. My Mega is just like anybody elses, but I incorrectly typed "pins 21-1" when it should be "21-18, plus that other one pin 7..." That is where I get confused now. I have four wires connected to 21, 209, 19 and 18. I have tested them and their vdc equate to my switch codes. So do I still write

 

DDRD = B00000000;

 

or do I write

 

DDRD = B00000;

or even

DDRD = B0000;

and match all the rest accordingly for Port D and other ports which do not use 8 pins?

 

Good news is, something is happening now when I turn the dial. It does reset, 0 to "0" and it also does something with 9 to "90". But the others stay at 0 as I click through them towards 90.

 

I will rewrite the code to work Dial 2 with PortA, as that is a regular 8-pin Port and test that.

 

With your help, I am definitely getting somewhere! (Actually, you have done most of the work!)

 

Thanks again,

 

Mole

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

Anyone good at writing LUA code?

 

I have a problem with the Hornet emergency/parking brake handle rotation.

You would expect it to return a value of 0 or 1 based on all the other 2 position "switches" in the aircraft, but it actually returns 1 for Emergency and 2 for Parking.

It also has two command parameters, which is more like a rocker than a 2 position switch.

 

This does not fit into any of the existing switch/control definition so I am trying to write one specifically for it. I based it on the Rocker template, and have this so far. But it doesn't work ...

 

edit: fixed it. Guess I can add lua to my list of know languages ;)

 

function defineEmergencyParkingBrake(msg, device_id, emergency_command, park_command, arg_number, category, description)
local alloc = moduleBeingDefined.memoryMap:allocateInt{ maxValue = 1 }
moduleBeingDefined.exportHooks[#moduleBeingDefined.exportHooks+1] = function(dev0)
	if dev0:get_argument_value(arg_number) < 0.5 then
		alloc:setValue(0)
	else
		alloc:setValue(1)
	end
end

document {
	identifier = msg,
	category = category,
	description = description,
	control_type = "emergency_parking_brake",
	inputs = {
		{ interface = "set_state", max_value = 1, description = "set the switch position -- 0 = emergency, 1 = parking" }
	},
	outputs = {
		{ ["type"] = "integer",
		  suffix = "",
		  address = alloc.address,
		  mask = alloc.mask,
		  shift_by = alloc.shiftBy,
		  max_value = 1,
		  description = "switch position -- 0 = emergency, 1 = parking"
		}
	}
}
moduleBeingDefined.inputProcessors[msg] = function(toState)
	local dev = GetDevice(device_id)
	local fromState = GetDevice(0):get_argument_value(arg_number)
	if fromState > 0.5 then fromState = 1 end
	if fromState == 0 and toState == "1" then
		dev:performClickableAction(park_command, 0) 
		dev:performClickableAction(park_command, 1) 
		dev:performClickableAction(park_command, 0) 
	elseif fromState == 1 and toState == "0" then
		dev:performClickableAction(emergency_command, 0) 
		dev:performClickableAction(emergency_command, 1) 
		dev:performClickableAction(emergency_command, 0) 
	end
end
end


Edited by Bullant

Intel i7 13700K @ 5.3 GHz / ASUS TUF Gaming Z490-Plus / 64 Gb G.Skill DDR4-3600 / RTX 4090 / 2TB Kingston KC3000 NVME / Win 10 x64 Pro / Pimax Crystal / WINWING F/A-18 HOTAS

A-10C, AJS-37, AV-8B, F-4E, F-5E, F-14, F-15E, F-16, F/A-18C, F-86F, FC3, Christen Eagle 2, FW190D-9, Mosquito, P-47D, P-51D, Spitfire, AH-64D, KA-50, UH-1H

Combined Arms, WWII Asset Pack, China Assets Pack, Super Carrier, Falklands Assets

Nevada, Normandy, Persian Gulf, The Channel, Syria, Mariana Islands, South Atlantic, Sinai

Link to comment
Share on other sites

I have had a vision where I have seen what hell will be: (no doubt, I will end there some day)

 

There will be (among other useless things of course) an internet full of nothing but messages about solved problems.

But nowhere a single line of HOW someone solved something.

 

:devil:

 

PS: This Post will be deleted in 60 minutes from now. ;)

 

Ahh, but there will be another Internet (like a parallel universe) with all the lines of How someone solved something, but no information at all about the problem....

 

:helpsmilie:

 

PS: This Post will be moved to that same parallel Internet.... one day.

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

I have had a vision where I have seen what hell will be: (no doubt, I will end there some day)

 

There will be (among other useless things of course) an internet full of nothing but messages about solved problems.

But nowhere a single line of HOW someone solved something.

 

:devil:

 

PS: This Post will be deleted in 60 minutes from now. ;)

 

Ahh, but there will be another Internet (like a parallel universe) with all the lines of How someone solved something, but no information at all about the problem....

 

:helpsmilie:

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

ARK-9/15 Work in Progress

 

With Hansolo's input and code help, my ARK-9/15 has suddenly made progress.

 

I now have Dial 2 almost working. I am using PORTA currently, though I believe I will be able to move it to PORTD as I want to use 6 ports for the 2 dials.

 

Curiously, I can write

if (PINA == B1111) {

for the 4 active pins, and not bother with the inactive ones.

 

(However, I have discovered there is a fifth wire needed!)

 

I now have the dial turning under DCS-BIOS to correct settings, to some extent. The missing pin is for a connection I thought was redundant. It is not. Which is why freqs 10, 20, 30 do not yet work. So I have to add a fifth wire, no problem. From here, I think i will soon have it all working!

 

Mole

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

  • 3 weeks later...

ARK-9 /15

 

I finally got the whole thing working, 6 dials, all switches and knobs, perfect!

 

The ARK-9 is a kind of mirror image of the ARK-15, so I have to remember to reverse things, (until the Mi-24...).

 

Thank you Solo for all your guidance and help!

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

  • 1 month later...

Hi ,

As my last time i use this platform was 2 years ago by making some POC to test arduino for UH—1U pit.

 

Now i like to try something new and create F-14 grip for the upcoming module.

 

My qustion is :

Any way i can use arduino/dcs bios to made some Axis control for pich/roll and trust ?


Edited by assafm25

[sIGPIC][/sIGPIC]

 

IAF Bell205

IAF Anafa

 

-----------------------

DCS World Modules: A-10C, FC3, MiG-21BiS, F-86, P-51, KA-50, UH-1H Huey, Mi-8, M2000K, Gazal, Bf109, Mig-15, Hawk and NTTR

-----------------------

My System - ASUS Maximus HERO iiiv, CoolMaster 120 Sadion Plus, I7 -6700K @4.0, G.Skill ddr4 16GB ram, Gigabyte GTX 1070 G1 , PSU Seasonic X-650W, OCZ 150 500Gb ssd drive X2, Seagate 7200 1T X2.

-------------

Link to comment
Share on other sites

  • 4 weeks later...

Viggen airspeed gauge

 

Hello!

My first post in here, so please bear with me :) I'm planning on building a Viggen simulator. I have been playing around with different switches and stepper motors. Now I have run into trouble though when trying to make an X27.168 stepper motor show the airspeed in the Viggen. I borrowed some code from this forum and tried to tweak it. The motor does its thing in the beginning by finding the left end point. But when I try to run it with DCS and click Fly after loading the game, it moves to the right end position, and then counts "backwards". As if the 0 position is to the right. I hope that you understand what I'm talking about.

 

I think the problem lies in the first part when the stepper is finding the 0 position.

Can someone please help me figure out what i'm doing wrong?

 

/*
 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 "AccelStepper.h"
#include "DcsBios.h"

struct StepperConfig {
 unsigned int maxSteps;
 unsigned int acceleration;
 unsigned int maxSpeed;
};


class Vid29Stepper : public DcsBios::Int16Buffer {
 private:
   AccelStepper& stepper;
   StepperConfig& stepperConfig;
   unsigned int (*map_function)(unsigned int);
   unsigned char initState;
 public:
   Vid29Stepper(unsigned int address, AccelStepper& stepper, StepperConfig& stepperConfig, unsigned int (*map_function)(unsigned int))
   : Int16Buffer(address), stepper(stepper), stepperConfig(stepperConfig), map_function(map_function), initState(0) {
   }

   virtual void loop() {
     if (initState == 0) { // not initialized yet
       stepper.setMaxSpeed(stepperConfig.maxSpeed);
       stepper.setAcceleration(stepperConfig.acceleration);
       stepper.moveTo(-((long)stepperConfig.maxSteps));
       initState = 1;
     }
     if (initState == 1) { // zeroing
       stepper.run();
       if (stepper.currentPosition() <= -((long)stepperConfig.maxSteps)) {
         stepper.setCurrentPosition(0);
         initState = 2;
         stepper.moveTo(stepperConfig.maxSteps);
       }
     }
     if (initState == 2) { // running normally
       if (hasUpdatedData()) {
         unsigned int newPosition = map_function(getData());
         newPosition = constrain(newPosition, 0, stepperConfig.maxSteps);
         stepper.moveTo(newPosition);
       }
       stepper.run();
     }
   }
};

/* modify below this line */

/* define stepper parameters
  multiple Vid29Stepper instances can share the same StepperConfig object */
struct StepperConfig stepperConfig = {
 650,  // maxSteps
 1000, // maxSpeed
 1000 // acceleration
 };


// define AccelStepper instance
AccelStepper airspeedstepper(AccelStepper::FULL4WIRE, 13, 12, 11, 10);
// define AdafruitStepper class that uses the AccelStepper instance defined in the line above
//           +-- arbitrary name
//           |   +-- Address of stepper data (from control reference)
//           |   |       +-- name of AccelStepper instance
//           v   v       v        v-- StepperConfig struct instance
Vid29Stepper airspeed(0x4676, airspeedstepper, stepperConfig, [](unsigned int newValue) -> unsigned int {
 /* this function needs to map newValue to the correct number of steps */
 return map(newValue*50, 0, 65000, 0, stepperConfig.maxSteps);
}); 


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

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

Link to comment
Share on other sites

NS430 and Bodnar board

 

Thanks Captain. I would like to interface an arduino board with NS430 to be able to use this GPS in a physical cockpit. Let me know if you find something.

 

Hi BaD,

 

I implemented a NS430 interface that works great using a Bodnar board and a button box I built. I use it in VR as it sits where the Garmin sits in the Mi-8, and I have no problem reaching out for it and pushing buttons, turning encoders etc. I also bought 2 of the dual encoders from Bodnar, which was the expensive part of this project, but it absolutely gives the whole thing credibility.

 

It is programmed then through the DCS controller options like a joystick. It is now much more enjoyable to set up the NS430, as it is very tricky and slow using a mouse in cockpit. Other friends report the same frustration and consequently only use the Garmin with preset WPs from the mission editor.

 

With a purpose built box, it is a viable instrument with lots of potential and ease of use. I used the same layout as the real box and it is very satisfying and immersive.

 

Still have a lot to learn about its functions, but at least I can get it to work. You do need a mod which Chic at 229th made to get the encoders working well.

 

Great flying with you on Sunday btw!

 

Yours,

 

Mole

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

Thanks Mole! Yeah, Sunday flight with you guys and the 906th was pretty cool! We'll do that again soon!

 

Yes, the bodnar boards are the base of my KA50 cockpit (it uses 11 of them!), but my objective here is to adapt the GNS430 from Realsimgear to work in DCS and it is based on Arduino board:

 

GNS430_hero.png?v=1530575195

 

Looking awesome, no? :)

 

Arduino boards are not recognized as standard USB HID devices like Bodnar boards so they are not recognized as joysticks inside DCS.

Link to comment
Share on other sites

Thanks Mole! Yeah, Sunday flight with you guys and the 906th was pretty cool! We'll do that again soon!

 

Yes, the bodnar boards are the base of my KA50 cockpit (it uses 11 of them!), but my objective here is to adapt the GNS430 from Realsimgear to work in DCS and it is based on Arduino board:

 

GNS430_hero.png?v=1530575195

 

Looking awesome, no? :)

 

Arduino boards are not recognized as standard USB HID devices like Bodnar boards so they are not recognized as joysticks inside DCS.

 

Hey BaD,

 

Did you already buy that? It looks really great. But you will need to have/write the code for DCS-BIOS to get it working! I am sure that is possible, and can be worked out from similar code in other modules.

 

I recently used an Arduino to build a ARK-9/15 using an authentic ARK-15 from a Russian aviation scrap-dealer. Luckily, the Mi-8 has already been set to DCS-BIOS, but I still had to write some stuff to interpret the output of the dials which have mechanical rotary switches generating 5 digit codes! Got some help with that from Hansolo, without which I doubt I could have done it. And it works now too, clunky detents and stiff switches....

 

I think DCS-BIOS is really impressive and would love to do more with it when I have a need. Good luck with yours too! And I look forward to flying with BSD Boys again soon.

 

Mole

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

I found the way to interact with the NS430!

Once is installed, you can get acces to the switches and buttons adding 256 to the device numbers.

 

For example the "VLOC flip-flop" switch uses the device.GNS430 (=1) and the action is the button13, so usually you get acces doing:

lDevice = GetDevice(1)

lDevice:performClickableAction(3013,1)

but, this dont work, because the MI-8 or L39 devices are actually working in those ranges too.

 

So... you need to add 256 to the device, so you call:

lDevice = GetDevice(257)

lDevice:performClickableAction(3013,1)

And it work !

 

Now....

If you want to use the DCSBios, we need to add the NS340 buttons to the MI-8 or L39 dcsbios file, adding the new entrances using the 256+ system.

Thats not difficult to do.

 

 

 

..


Edited by Capt Zeen
Link to comment
Share on other sites

Wow, this is so exciting Captain! Thanks for checking.

Not difficult for gifted guy like you man but this sounds kinda Chinese to me! :) Of course Mi-8 is the main target but we have 2D NS430 now available is most of the aircraft!

Probably we can do a NS430 dcsbios lib common file, and then just call it from the others airplane files.

I can try it.

Link to comment
Share on other sites

  • 2 weeks later...

hi

im trying to build my own F-5E tiger cockpit interfacing with arduino using dcs bios, i need information about how i can add f-5e to dcs bios and the required file i need for and how i including file inside the dcs bios folder

Link to comment
Share on other sites

There will be a complette bios install if i finished it. (In Coop with jdahlblom ; dcs flightpanels)

 

After the f5 i would Start the harrier or does anybody else it?


Edited by BlackLibrary
Link to comment
Share on other sites

Hi,

 

I've posted this in the F-18 thread but it may not be the correct area so I'm re-posting here in the hopes that someone understands DCS-BIOS much better than me.

 

I'm having issues with DCS BIOS with Andrew's F-18 profile. His function looks good but non of the intercomms work. There's also allot of other controls that don't work. It doesn't sound right so it must be something I have wrong.

 

Is my understanding below correct? Are there any other factors I'm not considering? This for the RWR volume.

 

The device ID was incorrect (41, changed them to 40.)

 

...\Saved Games\DCS.openbeta\Scripts\DCS-BIOS\lib\

FA-18C_hornet.lau:

definePotentiometer("COM_RWR", 40, 3004, 359, {0, 1}, "Communication Panel", "RWR Volume Control Knob")

...\DCS World OpenBeta\Mods\aircraft\FA-18C\Cockpit\Scripts\

devices.lau:

devices["INTERCOM"] = counter()--40 -- Intercommunication Amplifier-Control - AM-7360/A

 

command_defs.lua:

-- intercom

count = start_command

intercom_commands =

{

CommSw = counter(); -- 3001

VOX_Volume = counter(); -- 3002

ICS_Volume = counter(); -- 3003

RWR_Volume = counter(); -- 3004

WPN_Volume = counter();

...

 

clickabledata.lau:

elements["pnt_359"] = default_axis_limited(_("RWR Volume Control Knob"), devices.INTERCOM, intercom_commands.RWR_Volume, 359, 0.0, 0.1, false, false, {0,1})

 

Thanks!

 

cheers

 

John

Link to comment
Share on other sites

  • Recently Browsing   0 members

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