Jump to content

DCS-BIOS Discussion Thread


FSFIan

Recommended Posts

Hi.

Just checked the DCS-BIOS\lib\A10C.lua file (0.5.1) and a found the "defineElectricallyHeldSwitch" function (commented out).

 

local defineElectricallyHeldSwitch = BIOS.util.defineElectricallyHeldSwitch

--local function defineElectricallyHeldSwitch(msg, device_id, pos_command, neg_command, arg_number, category, description)
-- document { identifier = msg, category = category, description = description, control_type = "electrically_held_switch", value_type = "enum", value_enum = {"0", "1"}, can_set = false, actions = {"PUSH", "RELEASE", "OFF"} }
-- --moduleBeingDefined.lowFrequencyMap[msg] = function(dev0) return string.format("%.0f", dev0:get_argument_value(arg_number)) end
-- moduleBeingDefined.inputProcessors[msg] = function(action)
--  if action == "PUSH" then GetDevice(device_id):performClickableAction(pos_command, 1) end
--  if action == "RELEASE" then GetDevice(device_id):performClickableAction(neg_command, 0) end
--  if action == "OFF" then GetDevice(device_id):performClickableAction(pos_command, 0) end
-- end
--end

defineElectricallyHeldSwitch("LASTE_EAC", 38, 3026, 3027, 129, "LASTE Panel", "EAC On/Off")
defineElectricallyHeldSwitch("SASP_YAW_SAS_L", 38, 3003, 3004, 185, "SAS Panel", "Yaw SAS Left OFF - ENGAGE")
defineElectricallyHeldSwitch("SASP_YAW_SAS_R", 38, 3005, 3006, 186, "SAS Panel", "Yaw SAS Right OFF - ENGAGE")
defineElectricallyHeldSwitch("SASP_PITCH_SAS_L", 38, 3007, 3008, 187, "SAS Panel", "Pitch SAS Left OFF - ENGAGE")
defineElectricallyHeldSwitch("SASP_PITCH_SAS_R", 38, 3009, 3010, 188, "SAS Panel", "Pitch SAS Right OFF - ENGAGE")
defineElectricallyHeldSwitch("ANTI_SKID_SWITCH", 38, 3028, 3029, 654, "Landing Gear and Flap Control Panel", "Anti-Skid Switch")
defineElectricallyHeldSwitch("LCP_ANTICOLLISION", 49, 3010, 3011, 289, "Light System Control Panel", "Anticollision Lights")

Is this function operational or could be made to be ?

 

I guess it's work in progress or that issues are found but can't hurt asking. Any chanse getting these to work properly in the pit would be great.

 

Sorry for being a numbhead here but if I read the function correctly, it set the clickabledata value for the cockpit switch itself. How is the output pin controlled that 'power' the coil of the MagSwitch itself ?

 

All the best and thanks for a great application

Cheers

Gus

- - - -

Link to comment
Share on other sites

The function is still there, it's in Util.lua now. Electrically held switches are implemented, but there is no separate output that tells you when to power the coil -- from the Export.lua viewpoint, the state of an electrically held switch looks like any other toggle switch. It just happens to be changed by the sim on its own from time to time.

 

Most users will use normal toggle switches for these and can treat them like any other toggle switch (DcsBios::Switch2Pos).

 

If you actually have an electrically held switch, you can monitor the switch state (check the control reference in Advanced view for the IntegerBuffer code examples). You'll have to figure out the exact logic yourself -- I have never done it because I don't have such a switch to test with.

 

It might be sufficient to have a normal DcsBios::Switch2Pos monitoring the toggle switch and just turn the coil on whenever the switch in the virtual cockpit is in the on position.

 

No matter what you do, there will be some edge cases that won't behave like the real thing. For example, when you push and hold the physical switch, the switch in the virtual cockpit will always be in the ON position and your coil will engage. Export.lua cannot tell the difference between the coil being on or off while the switch is being held in the on position, because the only info we get is the switch position (which is the only thing the rendering engine cares about).

Link to comment
Share on other sites

Ian;3058484']

If you actually have an electrically held switch, you can monitor the switch state (check the control reference in Advanced view for the IntegerBuffer code examples). You'll have to figure out the exact logic yourself -- I have never done it because I don't have such a switch to test with.

It might be sufficient to have a normal DcsBios::Switch2Pos monitoring the toggle switch and just turn the coil on whenever the switch in the virtual cockpit is in the on position.

...

What about the SAS-LED function

DcsBios::LED saspPitchSasR(0x1108, 0x2000, PIN);

 

I never tried this - caused by low priority and still unsolved mechanical problems. But I primary planned to use this to drive the coil (instead of a LED).


Edited by Tekkx

Manual for my version of RS485-Hardware, contact: tekkx@dresi.de

Please do not PM me with DCS-BIOS-related questions. If the answer might also be useful to someone else, it belongs in a public thread where it can be discovered by everyone using the search function. Thank You.

Link to comment
Share on other sites

That's what I meant by "monitor the switch state and use that to drive the coil". I wanted to point out that

  • this is information about the switch position, not about whether the coil is on or off
  • the switch being in the ON position does not always mean that the coil is energized (for example when the switch is being held in the ON position against the spring force that wants to push it back, and the computer has decided not to engage the coil because it thinks the switch should be off)
  • ...so anything we build based on this limited information can only be an approximation to the real thing (although probably one that's close enough)

Link to comment
Share on other sites

Sorry for the noobish question but since we're talking about the SAS switches, is there a way to let them work like a normal switch2pos instead of an electrically held switch?

 

My panel is quite simple and I could never emulate that kind of switch, and for some reason sometimes one of the 4 SAS switches does not work and I have to switch it off and on again.

 

A simple switch2pos would resolve that but I don't know how to "convert" it, if it is even possible... Thanks for any input!

Link to comment
Share on other sites

Ian;3058689']I wanted to point out that

  • this is information about the switch position, not about whether the coil is on or off
  • the switch being in the ON position does not always mean that the coil is energized
    ...

I never looked that deep in that matter. My fault.

Now I see a problem there (Just for my Magnetic Hold Switches. They won't work as intended).

 

Cloudie: The easiest way is just to use simple toggle switches. You'll have to bring them manually in that position conform to the real state.

For not becoming confused would be an (ON)-OFF-(ON) momentary type useful and bring a LED near to that switch which reports you the intended position inside the computer. Maybe there are even switches with built-in LEDs available.

I'd start this way:

DcsBios::ActionButton saspPitchSasRPush("SASP_PITCH_SAS_R", "PUSH", SwitchPIN1); // check out if this works as intended
// DcsBios::ActionButton saspPitchSasRRelease("SASP_PITCH_SAS_R", "RELEASE", PIN);
DcsBios::ActionButton saspPitchSasROff("SASP_PITCH_SAS_R", "OFF", SwitchPIN2);
DcsBios::LED saspPitchSasR(0x1108, 0x2000, LedPIN);

 

As Ian already told: It's only an approximation to the real thing. I have to Ian's honor to add: An approximation close to Zero (or at Zero?) :)

 

Edit one hour later: I'm at work right now and don't know what version I am running at home. Now I am a little confused and took a look into the Control reference 1.5.1

const byte saspPitchSasRPins[2] = {PIN_0, PIN_1};
DcsBios::SwitchMultiPos saspPitchSasR("SASP_PITCH_SAS_R", saspPitchSasRPins, 2);

This looks promising.

 

If desired, we could (should) discuss this Magnetic-Hold-matter in an other Thread?


Edited by Tekkx

Manual for my version of RS485-Hardware, contact: tekkx@dresi.de

Please do not PM me with DCS-BIOS-related questions. If the answer might also be useful to someone else, it belongs in a public thread where it can be discovered by everyone using the search function. Thank You.

Link to comment
Share on other sites

Cloudie: The easiest way is just to use simple toggle switches. You'll have to bring them manually in that position conform to the real state.

Thanks, I tried that yesterday but I didn't get them to work.

 

Anyways, nevermind, I checked the control-reference now and noticed that it's already a switch2pos, eg. DcsBios::Switch2Pos saspPitchSasL("SASP_PITCH_SAS_L", PIN);

There's not that "PUSH" argument and it's not an actionbutton anymore. Maybe I had an outdated version.

I'll change my code and update my DCS-BIOS folders tonight, cheers

Link to comment
Share on other sites

...

Maybe I had an outdated version

...

I'm now back from work (Baby is sick at home) and my confusion is perfect now.

I can't reproduce where I have ...SwitchMultiPos... from.

 

Now comes the revenge for downloading every new version into the same directory :doh:

As I told before: I didn't touch SAS-Panel for months now.

 

Looks like I am outdated. So it's worth a closer look (later).

Manual for my version of RS485-Hardware, contact: tekkx@dresi.de

Please do not PM me with DCS-BIOS-related questions. If the answer might also be useful to someone else, it belongs in a public thread where it can be discovered by everyone using the search function. Thank You.

Link to comment
Share on other sites

I'm back at home too, I downloaded the latest version (5.1), updated my Arduino project with the switch2pos version but... like when I tried manually yesterday, the switch does nothing in the sim :(

If I pause and look at the terminal I can see the switch is working:

< 2017/02/22 23:06:43.668689  length=17 from=168 to=184
SASP_YAW_SAS_L 0
< 2017/02/22 23:06:44.271015  length=17 from=185 to=201
SASP_YAW_SAS_L 1

But in the sim nothing happens unfortunately. Any ideas? Ian?

Link to comment
Share on other sites

But in the sim nothing happens unfortunately. Any ideas? Ian?

 

Seems to work fine here. Are you by chance trying this in a situation where the switch refuses to engage when you click it in the virtual cockpit as well, such as in a cold and dark pit? Try the "Free Flight - Runway Start" mission and see if it works there.

 

If it does not work in a hot start situation, let me know the version numbers of DCS, DCS-BIOS and the Arduino library (I am assuming that other switches work so we can rule out a general communication problem).

Link to comment
Share on other sites

Ian;3059923']Seems to work fine here. Are you by chance trying this in a situation where the switch refuses to engage when you click it in the virtual cockpit as well, such as in a cold and dark pit? Try the "Free Flight - Runway Start" mission and see if it works there.

 

If it does not work in a hot start situation, let me know the version numbers of DCS, DCS-BIOS and the Arduino library (I am assuming that other switches work so we can rule out a general communication problem).

 

Thanks for your reply, I double checked everything you mentioned and remembered that when I updated I didn't copy the DCS-BIOS folder into the Script folder in Saved Games (everything else was working because I still had the 0.5.0 folder). Sure enough, now even the four SAS switches are working properly!

 

And with that my first panel is finally complete! Thanks a lot Ian for all the work you put into this project, without DCS-BIOS I doubt I could have reached the same results. Cheers!

Link to comment
Share on other sites

Hello Ian,

 

I am busy doing the library for the Gazelle. For the moment it works :D

 

But here is my problem. There are three kinds of the Gazelle 342M, 342L and 342Mistral. The interactive control reference confirm that 3 name.

 

All the Gazelle have the same clickabledata.lua and in 90% the same switch. Only the weapon panel change.

 

For exemple in the electric panel the 3 gazelle have the same fonction.

Is it possible to say to DCS BIOS to look in 1 library for the 3 gazelle?

 

I hope I am clear :D Not easy to explain with my bad english

 

Thanks for your help and your great tool DCS BIOS.

  • Like 1
Link to comment
Share on other sites

You can make one module that has everything that is shared between all models. That module would pass a list of several aircraft names to BIOS.protocol.setExportModuleAircrafts, e.g.

 

BIOS.protocol.setExportModuleAircrafts({"342M", "342L", "342Mistral"})

 

For each of the different weapon panels, make another DCS-BIOS module that only applies to that aircraft and that has a base address that does not collide with anything in the "common" module.

 

DCS-BIOS supports activating several "export modules" for one aircraft module. This functionality is already used to activate the MetadataStart, CommonData and MetadataEnd modules in all aircraft.

Link to comment
Share on other sites

Thanks.

 

If i anderstand, for the general module:

 

In the lib folder a SA342.lua

BIOS.protocol.beginModule("SA342", 0x2000)
BIOS.protocol.setExportModuleAircrafts({"SA342M", "SA342L", "SA342Mistral"})

 

By module

In the Lib folder a SA342M.lua, SA342L.lua and SA342Mistral.lua

 

BIOS.protocol.beginModule("SA342M", 0x1234)
BIOS.protocol.setExportModuleAircrafts({"SA342M"})

 

BIOS.protocol.beginModule("SA342L", 0x2340)
BIOS.protocol.setExportModuleAircrafts({"SA342L"})

 

Have I to declare the SA342 to aircraftlist, BIOS.lua?

 

Thanks


Edited by Ruahatu
Link to comment
Share on other sites

Hello,

 

I'm back and sorry to bother you with my question :cry:.

 

Always busy on the Gazelle and i don't anderstand how i have to code the diferent radio display and weapon display.

 

Can someone help me and tell me what file it needs.

 

I have also problem with this switch

elements["PE_ZOOM"] = default_button_tumb(_("SA342 Zoom"), devices.PE,device_commands.Button_4, device_commands.Button_3, arg_int.PE_ZOOM,2) -- 9 -- 365 arg number

 

I do not find the right function in Util.lua

 

Thanks


Edited by Ruahatu
Link to comment
Share on other sites

Is there a function debounce in DCS-BIOS for buttons?

 

 

Not that I'm aware of. Here's the code of I used to debounce my CMSC panel. Note the delay function. This may need to be increased depending on your Arduino setup. This was with a Nano which is fairly slow.

 

#define DCSBIOS_IRQ_SERIAL
#include "DcsBios.h"

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

DcsBios::Switch2Pos cmscJmr("CMSC_JMR", 2);
DcsBios::Switch2Pos cmscMws("CMSC_MWS", 3);
DcsBios::Switch2Pos cmscPri("CMSC_PRI", 4);
DcsBios::Switch2Pos cmscSep("CMSC_SEP", 5);
DcsBios::LED cmscPrio(0x1012, 0x0200, 6);
DcsBios::LED cmscLaunch(0x1012, 0x0100, 7);
DcsBios::LED cmscUnkn(0x1012, 0x0400, 8);

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

Link to comment
Share on other sites

Hello,

 

I'm back and sorry to bother you with my question :cry:.

 

Always busy on the Gazelle and i don't anderstand how i have to code the diferent radio display and weapon display.

 

Can someone help me and tell me what file it needs.

 

I have also problem with this switch

elements["PE_ZOOM"] = default_button_tumb(_("SA342 Zoom"), devices.PE,device_commands.Button_4, device_commands.Button_3, arg_int.PE_ZOOM,2) -- 9 -- 365 arg number

 

I do not find the right function in Util.lua

 

Thanks

 

Nobody for some help :helpsmilie:

Link to comment
Share on other sites

Anyone using the u8g2 library in dcsbios?

I can write to the nhd 256X56 ssd1322 display using dwrString function but dwrString doesnt work in the dcsbois function.

The u8g2 print function doesnt work at all.

Can someone explain how the dcs function works? It looks like the character newValue pointer is pointing at the 8 member <stringBuffer>array? So I should be able to dereference this pointer in the u8g2 dwrStr function and iterate through the <stringBuffer> array? Or should I point the dwrString function string pointer at the *newValue pointer?

Also why doesnt u8g2.print(newValue); work?

/* use '#define DCSBIOS_DEFAULT_SERIAL' instead if your Arduino board
*  does not feature an ATMega328 or ATMega2650 controller.
*/
#define DCSBIOS_IRQ_SERIAL
#include <Arduino.h>
#include <U8g2lib.h>
#include <U8x8lib.h>
#include "DcsBios.h"
#include <SPI.h>

/*8**************************************************************************************
*   U8G2_R0 = zero rotation, clock = SCK,data = MOSI,
*   cs = chip select,dc = data command, reset = reset line
*   MOSI  = 51;
*   MISO  = 50;
*   SCK   = 52;
****************************************************************************************/

const int RESET = 44;
const int myCS =  43;
const int myDC =  42;

//object insantiated
U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI myu8g2(U8G2_R0,52,51,myCS,myDC,RESET);

//this doesnt work

void onCmscTxtJmrChange(char* newValue) {
    /* code goes here */
     myu8g2.firstPage();
 do {
   myu8g2.setFont(u8g2_font_ncenB14_tr);
   myu8g2.drawStr(0,15,newValue);
 } while ( myu8g2.nextPage() );
 
 /* This doesnt work
 myu8g2.setFont(u8g2_font_ncenB14_tr);
   myu8g2.setCursor(0, 15);
   myu8g2.print(newValue);*/
    }
DcsBios::StringBuffer<8> cmscTxtJmrBuffer(0x1096, onCmscTxtJmrChange);


void setup() {
   pinMode(RESET, OUTPUT);
   pinMode(MOSI,  OUTPUT);
   pinMode(MISO,  OUTPUT);
   pinMode(SCK,   OUTPUT);
   pinMode(myCS,  OUTPUT);
   pinMode(myDC,  OUTPUT);
   
//this doesnt work
   myu8g2.begin();
   myu8g2.clear();
   myu8g2.setFontMode(0);
   myu8g2.setDrawColor(1);
   myu8g2.setFont(u8g2_font_7x13B_tf);
   myu8g2.setCursor(0, 15);
   myu8g2.print("hello");
          
           
//This works displays correctly on oled nhd display
   myu8g2.firstPage();
 do {
   myu8g2.setFont(u8g2_font_ncenB14_tr);
   myu8g2.drawStr(0,15,"Hello World!");
 } while ( myu8g2.nextPage() );
 delay(2000);
          
DcsBios::setup();

}

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



Link to comment
Share on other sites

Solved kinda

 

Looks like there was nothing wrong with the software or hardware it was the starting sequence for DCS. If you start DCS up first go in the cockpit then start up connect serial port software you will see the data flowing in the command window but no data will be sent to the display.

You have to start the serial connect software first then the game and it will work.I dont know how many times I've been burned by this.duh...

Link to comment
Share on other sites

If you start DCS up first go in the cockpit then start up connect serial port software you will see the data flowing in the command window but no data will be sent to the display.

 

If you connect your panel after you are already sitting in the aircraft, you have to either wait about 10 seconds or cause the display contents to change to see it on your panel.

 

DCS-BIOS only sends data when it has changed. Each update also includes a small bit of data that did not change, so everything gets re-sent once about every 10 seconds.

Link to comment
Share on other sites

  • 2 weeks later...

Hi, i'm currently looking for an altenetive solution for hooking up my panels to DCS, so DCS -BIOS looks very promissing.

 

How many arduino boards can i conncet and operate wit DCS-BIOS?

What would be the best board to use?

 

Yoreh.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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