Jump to content

DCS-BIOS Discussion Thread


FSFIan

Recommended Posts

DCS BIOS & iCommand

 

Hi Ian,

 

Working on the M2000-C library, i have a question..

 

Many Switches / Push Button in the cockpit (ie MasterCautionReset or Master Arm Switch) are sended by "icommand" and doesn't react to arg command.

the switch "graphically" moves, but nothing appends in regard of the function it's have to do.

 

i have follow the icommand to the command_defs.lua file, and in this example (MasterCaution) the icommand "PlaneResetMasterWarning" is equal to 144.

so i have try to send a 3144 command, but it's doesn't work..

 

do you know if it's possible to send an icommand via DCS BIOS, ans how to do that ?

i mean i have to create a new function, but i don't know where to begin...

 

thanks

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

iCommand stuff is done via LoSetCommand(iCommandID, argument) instead of GetDevice(deviceID):performClickableAction(command, argument).

 

I can't check right now, but I assume the UI layer commands are handled by the same mechanism. To find out, look at the Lua files for the default keyboard bindings.

 

Currently, DCS-BIOS does not support anything that's not in clickabledata.lua, since that's the only file I looked at when I added the A-10C and Huey modules. I plan to expand the scope to "everything that's possible to get to from Lua" in DCS-BIOS 2.0.

  • Like 1
Link to comment
Share on other sites

Ian;2881649']iCommand stuff is done via LoSetCommand(iCommandID, argument) instead of GetDevice(deviceID):performClickableAction(command, argument).

 

I can't check right now, but I assume the UI layer commands are handled by the same mechanism. To find out, look at the Lua files for the default keyboard bindings.

 

Currently, DCS-BIOS does not support anything that's not in clickabledata.lua, since that's the only file I looked at when I added the A-10C and Huey modules. I plan to expand the scope to "everything that's possible to get to from Lua" in DCS-BIOS 2.0.

 

 

You're THE BOSS IAN..

 

LoSetCommand working well !!!

 

ie for the Mirage MasterCaution use LoSetCommand(144, 1) and LoSetCommand(144, 0) to reset the state of the icommand, if not, you have to send 2 times the command to working.

 

Now we have to found how to send it by DCSBIOS...

 

Is this function can working ?

 

local function send_iCommand(iCommandID)
local k = iCommandID
for i = k,k do
LoSetCommand(i, 1)
LoSetCommand(i, 0)
end	

 

if yes how can i send it ? defineString ?

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I'm using this awesome library to create a UHF Panel (The A10C AN ARC 164).

 

First of all, a big thank you to all the contributors of DCS BIOS. without it, my panel would never go airborne. So really big thanks for all your effort.

 

Of course, I also have some problems, and hope to find someone who can help me with it.

 

Problem number one: I'm not using a genuine arduino, but a teensy 3.1, with the arduino dev environment.

 

I set everything up, and the panel works basically. However, after an event (button press, encoder turn) the corresponding message is not only sent once, but over and over again.

 

I traced it down to this code line, which is implemented in all of the input classes in more or less the same manner:

 

if (state == 0)
 if (sendDcsBiosMessage(msg_, "0"))
   lastState_ = state;

 

The sendDcsBiosMessage somehow returns false, thus the event is never reset to inital state and is send over and over again. My Question is, why is that if statement necessary anyway? Why not just:

if (state == 0)
 sendDcsBiosMessage(msg_, "0");
 lastState_ = state;

 

The latter one works perfectly with my teensy.

 

 

 

Best regards

Link to comment
Share on other sites

In RS485 mode, sendDcsBiosMessage can return false if the transmit buffer is full (i.e. when the board wants to transmit a message before the previous one has been fetched by the bus master).

 

Please post your complete sketch.

 

The Teensy 3.1 should work fine in DEFAULT_SERIAL mode. If you are using IRQ_SERIAL or RS485 on the Teensy 3.1, it's not going to work (in fact, I'd be surprised that it compiled at all).

Link to comment
Share on other sites

Hi Ian, thanks for the quick reply.

 

My code is basically only copy and paste from your reference. So atm it looks like this (I know I cant use the standard rotary encoders for uhf, but this is only for a first test.)

 

/*
 Tell DCS-BIOS to use a serial connection and use the default Arduino Serial
 library. This will work on the vast majority of Arduino-compatible boards,
 but you can get corrupted data if you have too many or too slow outputs
 (e.g. when you have multiple character displays), because the receive
 buffer can fill up if the sketch spends too much time updating them.
 
 If you can, use the IRQ Serial connection instead.
*/
#define DCSBIOS_DEFAULT_SERIAL

#include "DcsBios.h"

char PIN_2 = 2;
char PIN_3 = 3;
char PIN_4 = 4;
char PIN_5 = 5;
char PIN_6 = 6;
char PIN_7 = 7;
char PIN_8 = 8;
char PIN_9 = 9;
char PIN_10 = 10;
char PIN_11 = 11;
char PIN_12 = 12;
char PIN_13 = 13;
char PIN_14 = 14;
char PIN_15 = 15;
char PIN_16 = 16;
char PIN_17 = 17;
char PIN_18 = 18;
char PIN_19 = 19;
char PIN_20 = 20;
char PIN_21 = 21;
char PIN_22 = 22;
char PIN_23 = 23;

//http://dcs-bios.a10c.de/docs/v0.5.0/control-reference.html
DcsBios::RotaryEncoder a("UHF_10MHZ", "DEC", "INC",  PIN_2, PIN_3);
DcsBios::RotaryEncoder b("UHF_10MHZ", "DEC", "INC",PIN_4, PIN_5);
/*DcsBios::RotaryEncoder c("UHF_10MHZ", "DEC", "INC",PIN_6, PIN_7);
DcsBios::RotaryEncoder d("UHF_10MHZ", "DEC", "INC",PIN_8, PIN_9);
DcsBios::RotaryEncoder e("UHF_10MHZ", "DEC", "INC",PIN_10, PIN_11);
DcsBios::RotaryEncoder f("UHF_10MHZ", "DEC", "INC",PIN_16, PIN_17);
DcsBios::RotaryEncoder g("UHF_10MHZ", "DEC", "INC",PIN_18, PIN_19);*/
DcsBios::Switch2Pos uhfLoad("UHF_LOAD", PIN_20);
DcsBios::Switch2Pos uhfTest("UHF_TEST", PIN_21);
DcsBios::Switch2Pos uhfSquelch("UHF_SQUELCH", PIN_22);
DcsBios::Switch2Pos uhfTTone("UHF_T_TONE", PIN_23);
DcsBios::Switch2Pos uhfStatus("UHF_STATUS", PIN_12);

/* paste code snippets from the reference documentation here */

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

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

 

 

I took a look into DcsBios.h There I saw that there is no explicit return value for the sendDCSBiosMessage(), when using DCSBIOS_DEFAULT_SERIAL. I added a return true, and the problem was gone.

#ifdef DCSBIOS_DEFAULT_SERIAL
namespace DcsBios {
	ProtocolParser parser;
	void setup() {
		Serial.begin(250000);
	}
	void loop() {
		while (Serial.available()) {
			parser.processChar(Serial.read());
		}
		PollingInput::pollInputs();
		ExportStreamListener::loopAll();			
	}
}
bool sendDcsBiosMessage(const char* msg, const char* arg) {
	Serial.write(msg); Serial.write(' '); Serial.write(arg); Serial.write('\n');
	return true;  //<-- WAS MISSING 
}
#endif

 

However, there is one problem left.

As soon as I uncomment one more rotary encoder, I get a compile error:

 

Arduino: 1.6.9 (Windows 10), TD: 1.29, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz optimized (overclock), US English"
< removed some 100 messages here, as they are hopefully not important >


"C:\Users\florian\Desktop\arduino-1.6.9\hardware\teensy/../tools/arm/bin/arm-none-eabi-gcc" -O -Wl,--gc-sections,--relax,--defsym=__rtc_localtime=1472847193 "-TC:\Users\florian\Desktop\arduino-1.6.9\hardware\teensy\avr\cores\teensy3/mk20dx256.ld"  -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -o "C:\Users\florian\AppData\Local\Temp\builde9d2d06521e7151248ef909ce7d2b4be.tmp/an_arc164_simple.ino.elf" "C:\Users\florian\AppData\Local\Temp\builde9d2d06521e7151248ef909ce7d2b4be.tmp\sketch\an_arc164_simple.ino.cpp.o" "C:\Users\florian\AppData\Local\Temp\builde9d2d06521e7151248ef909ce7d2b4be.tmp\libraries\dcs-bios-arduino-library-0.2.5\Protocol.cpp.o" "C:\Users\florian\AppData\Local\Temp\builde9d2d06521e7151248ef909ce7d2b4be.tmp/core\core.a" "-LC:\Users\florian\AppData\Local\Temp\builde9d2d06521e7151248ef909ce7d2b4be.tmp" -larm_cortexM4l_math -lm
C:\Users\florian\AppData\Local\Temp\builde9d2d06521e7151248ef909ce7d2b4be.tmp\sketch\an_arc164_simple.ino.cpp.o: In function `DcsBios::RotaryEncoder::RotaryEncoder(char const*, char const*, char const*, char, char)':

C:\Users\florian\Documents\Arduino\libraries\dcs-bios-arduino-library-0.2.5/Encoders.h:62: undefined reference to `vtable for DcsBios::PollingInput'

collect2.exe: error: ld returned 1 exit status

Bibliothek dcs-bios-arduino-library-0.2.5 im Ordner: C:\Users\florian\Documents\Arduino\libraries\dcs-bios-arduino-library-0.2.5 (legacy) wird verwendet
Fehler beim Kompilieren für das Board Teensy 3.2 / 3.1.

 

Well, I am not very much into C, so no idea whats going on here...

 

Anyways, thanks for your help and your effort...

Link to comment
Share on other sites

A quick update: after some googling, I edited DcsBios PollingInput.h.

 

Without knowing what a virtual and a pure virtual method is, I changed:

 

	
namespace DcsBios {

class PollingInput {
	private:
		virtual void pollInput();

 

to

namespace DcsBios {

class PollingInput {
	private:
		virtual void pollInput()=0;

 

It works now :music_whistling: :thumbup:

Link to comment
Share on other sites

  • 3 weeks later...
Any Ideal when DCS-BIOS 2 might be available?

 

So far, not a single line of code has been written, so it's too early to even make wild guesses. That said, I just finished moving to a new apartment, which will probably have a positive effect on my overall productivity and, by extension, the pace of DCS-BIOS development.

 

Those of you who have been following the project may have noticed that there was very little progress over the last year. The drop in productivity coincided with me moving into the place I just left, which didn't get much sunlight and got water damage a few month ago. I can't say for sure whether it was the humidity, lack of sunlight, a combination of those or something else entirely, but I never got much sleep while I stayed there. Judging from my experiences with the new place so far, it looks like that is improving a lot.

Link to comment
Share on other sites

VFD brightness

 

Hi all friend, I need help,

 

Now I use Potentiometer (0~1023) and arduino uno and VFD 20 x 2 for my CMSP but I have the following problem,

I independently find the arduino code ( DSC-Bios to VFD, control VFD brightness),

How to merge the Potentiometer (0~1023) with VFD brightness code for DSC-Bios to VFD), and the VFD brightness code that have 4 degree for 100%, 75%, 50% and 25% brightness, may I use Potentiometer's range (0~255) for 25%, (256~511) for 50%, (512~767) for 75% and (768~1023) for 100% brightness? or any idea for 4 degree brightness with Potentiometer that similar as real cmsp's brightness function.

 

And may I control the turn on or off the Display used the code? I have attached some VFD menu and red high light it may useful.

 

:helpsmilie: Please help, Thank you

 

independently code as the following

 

<< DSC-Bios to VFD >>

 

#define DCSBIOS_IRQ_SERIAL

 

#include "DcsBios.h"

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 

void onCmsp1Change(char* newValue) {

lcd.setCursor(0, 0);

 

lcd.write(newValue[9]);

lcd.write(newValue[0]);

lcd.write(newValue[1]);

lcd.write(newValue[2]);

lcd.write(newValue[3]);

lcd.write(newValue[4]);

lcd.write(newValue[5]);

lcd.write(newValue[6]);

lcd.write(newValue[7]);

lcd.write(newValue[8]);

lcd.write(newValue[9]);

lcd.write(newValue[9]);

lcd.write(newValue[10]);

lcd.write(newValue[11]);

lcd.write(newValue[12]);

lcd.write(newValue[13]);

lcd.write(newValue[14]);

lcd.write(newValue[15]);

lcd.write(newValue[16]);

lcd.write(newValue[17]);

lcd.write(newValue[18]);

lcd.write(newValue[19]);

}

DcsBios::StringBuffer<19> cmsp1Buffer(0x1000, onCmsp1Change);

 

void onCmsp2Change(char* newValue) {

lcd.setCursor(0, 1);

 

lcd.write(newValue[0]);

lcd.write(newValue[1]);

lcd.write(newValue[2]);

lcd.write(newValue[3]);

lcd.write(newValue[4]);

lcd.write(newValue[5]);

lcd.write(newValue[6]);

lcd.write(newValue[7]);

lcd.write(newValue[8]);

lcd.write(newValue[9]);

lcd.write(newValue[9]);

lcd.write(newValue[10]);

lcd.write(newValue[11]);

lcd.write(newValue[12]);

lcd.write(newValue[13]);

lcd.write(newValue[14]);

lcd.write(newValue[15]);

lcd.write(newValue[16]);

lcd.write(newValue[17]);

lcd.write(newValue[18]);

lcd.write(newValue[19]);

}

 

DcsBios::StringBuffer<19> cmsp2Buffer(0x1014, onCmsp2Change);

 

void setup() {

DcsBios::setup();

lcd.begin(20, 2);

lcd.clear();

}

 

void loop() {

DcsBios::loop();

}

 

 

 

 

 

<< control VFD brightness >>

 

/*

LiquidCrystal Library - demo

Extension to control brightness VFD

*/

 

// include the library code:

#include <LiquidCrystal.h>

 

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 

// Adds definitions for VFD:

#define VFD_25pc 0x03

#define VFD_50pc 0x02

#define VFD_75pc 0x01

#define VFD_100pc 0x00

void vfd_brightness(int brightness) {

// unfortunately lcd._displayfunction is private so we've to redefine it

int _displayfunction = LCD_4BITMODE | LCD_2LINE | LCD_5x8DOTS;

lcd.command(LCD_FUNCTIONSET | _displayfunction | brightness);

}

 

void setup() {

// set up the LCD's number of rows and columns:

lcd.begin(2, 16);

lcd.print("hello, world!");

}

 

void loop() {

vfd_brightness(VFD_100pc);

delay(200);

vfd_brightness(VFD_75pc);

delay(200);

vfd_brightness(VFD_50pc);

delay(200);

vfd_brightness(VFD_25pc);

delay(200);

vfd_brightness(VFD_50pc);

delay(200);

vfd_brightness(VFD_75pc);

delay(200);

}

 

 

 

==========================

VFD menu as the following

 

4-4-6. FUNCTION SET

RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 0 0 1 DL N × BR1 BR0

×=don’t care

This instruction sets the width of the data bus for the parallel interface modes, the

number of display lines, and the luminance level (brightness) of the VFD. DDRAM,

CGRAM, and AC contents are not affected by this instruction.

DL = 0 :Sets the data bus width for the parallel interface modes to 4-bit (DB7-DB4).

DL = 1 :Sets the data bus width for the parallel interface modes to 8-bit (DB7-DB0).

N = 0 : Sets the number of display lines to 1 (this setting is not recommended).

N = 1 : Sets the number of display lines to 2

BR1, BR0 = 0,0: Sets the luminance level to 100%.

0,1: Sets the luminance level to 75%.

1,0: Sets the luminance level to 50%.

1,1: Sets the luminance level to 25%.

 

4-5 RESET CONDITIONS

After a power-up reset, the module initializes to the following conditions:

1) All DDRAM locations are set to 20H (character code for a space).

2) The AC is set to DDRAM address 00H (i.e. sets cursor position to 00H).

3) The relationship between DDRAM addresses and character positions on the VFD is set

to the non-shifted position.

4) Entry Mode Set instruction bits:

I/D = 1: The AC increments after each DDRAM or CGRAM access. If S=1, the

information on the display shifts to the left by one character position after

each DDRAM write.

S = 0: The display shift function is disabled.

5) Display On/Off Control instruction bits:

D = 0: The display is off (display blank).

C = 0: The cursor is off.

B = 0: The blinking character function is disabled.

6) Function Set instruction bits:

DL = 1: Sets the data bus width for the parallel interface modes to 8-bit (DB7-DB0).

N = 1: Number of display lines set to 2.

BR1,BR0=0,0: Sets the luminance level to 100%.

 

 

 

Thank you for your help.


Edited by moken
Link to comment
Share on other sites

If you switch the control reference to "Advanced" view, you will find a code snippet to react to changes in CMSP brightness:

 

void onCmspBrtChange(unsigned int newValue) {
   /* your code here */
}
DcsBios::IntegerBuffer cmspBrtBuffer(0x10e6, 0xffff, 0, onCmspBrtChange);

 

newValue will be between 0 (lowest brightness) and 65535 (max. brightness). Since your four brightness levels go from 3 (lowest) to 0 (highest), you could try something like this:

 

void onCmspBrtChange(unsigned int newValue) {
   vfd_brightness(map(newValue, 0, 65535, 3, 0));
}
DcsBios::IntegerBuffer cmspBrtBuffer(0x10e6, 0xffff, 0, onCmspBrtChange);

 

PS: use

 tags to make code snippets in forum posts more readable.
Link to comment
Share on other sites

Ian;2904086']If you switch the control reference to "Advanced" view, you will find a code snippet to react to changes in CMSP brightness:

 

void onCmspBrtChange(unsigned int newValue) {
   /* your code here */
}
DcsBios::IntegerBuffer cmspBrtBuffer(0x10e6, 0xffff, 0, onCmspBrtChange);

 

newValue will be between 0 (lowest brightness) and 65535 (max. brightness). Since your four brightness levels go from 3 (lowest) to 0 (highest), you could try something like this:

 

void onCmspBrtChange(unsigned int newValue) {
   vfd_brightness(map(newValue, 0, 65535, 3, 0));
}
DcsBios::IntegerBuffer cmspBrtBuffer(0x10e6, 0xffff, 0, onCmspBrtChange);

 

PS: use

 tags to make code snippets in forum posts more readable.

 

Thank you Ian,

 

I mean how can I use my Potentimeter to change my physical VFD brightness. Could you let me know?

Link to comment
Share on other sites

Ian;2904086']If you switch the control reference to "Advanced" view, you will find a code snippet to react to changes in CMSP brightness:

 

void onCmspBrtChange(unsigned int newValue) {
   /* your code here */
}
DcsBios::IntegerBuffer cmspBrtBuffer(0x10e6, 0xffff, 0, onCmspBrtChange);

 

newValue will be between 0 (lowest brightness) and 65535 (max. brightness). Since your four brightness levels go from 3 (lowest) to 0 (highest), you could try something like this:

 

void onCmspBrtChange(unsigned int newValue) {
   vfd_brightness(map(newValue, 0, 65535, 3, 0));
}
DcsBios::IntegerBuffer cmspBrtBuffer(0x10e6, 0xffff, 0, onCmspBrtChange);

 

PS: use

 tags to make code snippets in forum posts more readable.

 

Ian;2904100']Just use the normal Potentiometer code snnippet from the reference docs. You turn the pot' date=' the Arduino sends the new position to DCS, in-game brightness changes, the new in-game brightness gets sent to the Arduino, and the Arduino changes the physical brightness.[/quote']

 

 

 

OK, I try, Thank you


Edited by moken
Link to comment
Share on other sites

Hi!

 

I use old version dcs-bios, and use this code for button on analog pins (one pin for many button with resistors):

 

#include <DcsBios.h>
#include <Servo.h>

DcsBios::ProtocolParser parser;

void setup()
{
 Serial.begin(500000);

 pinMode(A0, INPUT);         
 digitalWrite(A0, HIGH);     // pullup
}

int value = 0;
int newbtn = 0;
int btn = 0;

void loop()
{
 value = analogRead(A0);

 if(value < 59 ) newbtn = 1;
 else if (value < 65) newbtn = 2;
 else if (value < 72) newbtn = 3;
 else if (value < 80) newbtn = 4;
 else newbtn = 0;

 if(newbtn != btn) {
   switch(newbtn) {
     case 1: sendDcsBiosMessage("CMSP_ARW1", "1"); break;
     case 2: sendDcsBiosMessage("CMSP_ARW2", "1"); break;
     case 3: sendDcsBiosMessage("CMSP_ARW3", "1"); break;
     case 4: sendDcsBiosMessage("CMSP_ARW4", "1"); break;
     case 0:
     default: 
       switch(btn) {
         case 1: sendDcsBiosMessage("CMSP_ARW1", "0"); break;
         case 2: sendDcsBiosMessage("CMSP_ARW2", "0"); break;
         case 3: sendDcsBiosMessage("CMSP_ARW3", "0"); break;
         case 4: sendDcsBiosMessage("CMSP_ARW4", "0"); break;
       }
   }
   btn1 = newbtn;
 }


 while (Serial.available()) {
     parser.processChar(Serial.read());
 }
 // poll inputs
 DcsBios::PollingInput::pollInputs();

}

void sendDcsBiosMessage(const char* msg, const char* arg) {
 Serial.write(msg);
 Serial.write(' ');
 Serial.write(arg);
 Serial.write('\n');
}

void onDcsBiosWrite(unsigned int address, unsigned int value) {
 
}

 

 

How in new version write this code?

 

#define DCSBIOS_IRQ_SERIAL
#include "DcsBios.h"

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

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

My cockpit A-10C

Строю кокпит A-10C

i7 7700k, 32Gb RAM, SSD NVMe, GTX 1080, Hotas Warthog, HTC Vive.

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

With love from Russia

Link to comment
Share on other sites

How in new version write this code?

 

Try the following (warning: I didn't even try to compile this, I am on my laptop right now).

 

#define DCSBIOS_IRQ_SERIAL
#include "DcsBios.h"

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

 pinMode(A0, INPUT);         
 digitalWrite(A0, HIGH);     // pullup
}

int value = 0;
int newbtn = 0;
int btn = 0;

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

 value = analogRead(A0);

 if(value < 59 ) newbtn = 1;
 else if (value < 65) newbtn = 2;
 else if (value < 72) newbtn = 3;
 else if (value < 80) newbtn = 4;
 else newbtn = 0;

 if(newbtn != btn) {
   switch(newbtn) {
     case 1: while(!sendDcsBiosMessage("CMSP_ARW1", "1")); break;
     case 2: while(!sendDcsBiosMessage("CMSP_ARW2", "1")); break;
     case 3: while(!sendDcsBiosMessage("CMSP_ARW3", "1")); break;
     case 4: while(!sendDcsBiosMessage("CMSP_ARW4", "1")); break;
     case 0:
     default: 
       switch(btn) {
         case 1: while(!sendDcsBiosMessage("CMSP_ARW1", "0")); break;
         case 2: while(!sendDcsBiosMessage("CMSP_ARW2", "0")); break;
         case 3: while(!sendDcsBiosMessage("CMSP_ARW3", "0")); break;
         case 4: while(!sendDcsBiosMessage("CMSP_ARW4", "0")); break;
       }
   }
   btn1 = newbtn;
 }
}

 

sendDcsBiosMessage() is being provided by the DCS-BIOS Arduino library now. It also returns a boolean success value and may fail to send the message, so you have to deal with that. The easy way to do so is to use it in the condition of an empty while loop so you retry until sending succeeds. This is not optimal (if it has to wait for the transmit buffer to free up, the CPU time is wasted instead of being used to update outputs), but should work in most cases.

Link to comment
Share on other sites

Hello everybody!

 

I'm new to all this home cockpit building and working with electronics, all those switches, wires and the Arduino.

 

I've managed to install DCS-Bios and connect it to DCS (I'm on the 1.5). The master caution example works (after I connected the LED in the correct direction it worked too... :doh:).

So, now I'm trying to build a simple AHCP. Unfortunately I'm facing some issues with the three position switches. The IRQ serial script is used as base script, containing the code for the gun/pac switch.

For some reason the connect-serial-port.cmd shows only two messages: 0 and 2. Nevertheless, the Voltmeter shows a change in the voltage (1 V or 5 V) at the respective contacts of the switch (1 and 3).

 

I've looked into the switch.h in the library. I suppose there might be an error in the lines 46 and 47. When I changed the values from LOW to HIGH, the connect-serial-port.cmd shows all three messages (0,1,2) for the different conditions of the switch (and it works, as expected, in DCS).

 

Is there an error in the script or did I do something wrong?

 

Cheers.

 

PS: Ian, thank you very much for all your effords to set up such a wonderful tool! :thumbup:

Link to comment
Share on other sites

This sounds like you connected external pull-down resistors to the A and B pins and connected +5V to the center pin on the switch.

 

The DCS-BIOS Arduino Library assumes that the center pin on the switch is connected to ground and relies on the pull-up resistors that are integrated into the microcontroller to put the A and B pins into a defined state.

 

Many "how to read a switch" tutorials have you use a pull-down resistor on the I/O pin and wire up the switch to connect 5V when it is closed. This will make the pin LOW when the switch is open and HIGH when the switch is closed.

The other way to do it is to use a pull-up resistor on the I/O pin and wire up the switch to connect to ground when closed. This will make the pin HIGH when the switch is open and LOW when the switch is closed.

 

The beginner tutorials use the first option because it makes the logic "look right" -- when the switch is closed / the button is pressed, you intuitively expect to read a logic "HIGH"/"1"/"on" value.

Most real-world applications use the second option because the AVR chips have integrated pull-up resistors that can be enabled in software, so you don't have to use any external resistors.

  • Like 1
Link to comment
Share on other sites

Quick theoretical question:

 

Does the sim export data to program an RWR with tft lcd, arduino and custom symbols, like the CDU? Or is the only way a viewport and lcd with video input board?

 

Short answer: yes for FC3 aircraft (but can be disabled by MP servers), don't know for other aircraft. Even if we only get graphical data out of the sim, a display with a video input is certainly the easiest, but by no means the only option.

 

Long answer:

I know there is an API to do that for FC3 aircraft, which can be disabled by unchecking "allow sensor export" in the MP server settings. I think it includes RWR data in addition to the radar contacts. No idea if the same API works for non-FC3 aircraft, although I suspect it doesn't.

 

Even if the FC3 aircraft API does not work for other airframes, there might be a way to get the data by reading through the Lua files for the RWR, similar to what I did to piece together the content of the A-10C CDU. I wouldn't count on it, but I also don't want to say "this is impossible" without having spent several hours investigating.

 

Assuming that all you can do is export the viewport, that still does not mean you must use a screen with a video input. Assuming you have some external monitor where you can put the exported image (e.g. a virtual screen or a second monitor that is otherwise used to watch TeamSpeak or something), you could write a program to grab the data from there and send it to a suitable microcontroller-driven display. An Arduino connected to a 250000 bps serial port could handle about two or three monochrome frames per second on a 320x240 display, which might be enough for the RWR; if you need more FPS, use something with an ARM processor and USB.

 

How you drive the RWR display will depend on what type of display you get. It seems impossible to find one with the exact dimensions. I discussed this with Warhog recently and the options he is considering include using a slightly too small square display and enlarging the image with a fresnel lens, and using rear projection with one of those cheap pico projectors.

If you want maximum realism (i.e. a working brightness knob in the right place), things get more complicated because even a square display of the correct size would likely interfere with the potentiometer for that knob (hence the rear projection idea); the original RWR uses a round CRT tube.

Link to comment
Share on other sites

Thanks for the detailed response.

 

I am planing and designing my projects to be manufactured in quantities, with a high degree of automation. So I have to design them with simplicity and engineering elegance in mind, no tinkering or garage hacking methods. But mechanical/electrical hardware is my job and my problem. For example, I'm using custom made pcb's with surface mount components. So for an RWR (if standalone tft/arduino is possible) the potentiometer pcb could sit on top of the lcd, with a surface mounted potentiometer, covering the part of the tft that's not used/too large. Without any clearance or alignment problems.

 

But, if what's needed to make a tft/arduino RWR, is another monitor with RWR viewport exported to it, then it defeats the purpose of the tft/arduino simplicity. Then I would just go with small lcd with video input board.

 

Anyway, I have components for both arduino and video solutions on hand so I'll make both prototypes and we'll see what can be made to work.


Edited by hegykc
Link to comment
Share on other sites

Ian;2908764']Try the following (warning: I didn't even try to compile this, I am on my laptop right now).

 

sendDcsBiosMessage() is being provided by the DCS-BIOS Arduino library now. It also returns a boolean success value and may fail to send the message, so you have to deal with that. The easy way to do so is to use it in the condition of an empty while loop so you retry until sending succeeds. This is not optimal (if it has to wait for the transmit buffer to free up, the CPU time is wasted instead of being used to update outputs), but should work in most cases.

 

Many thanks! Do you have any plans to add queues to not use a while loop?

My cockpit A-10C

Строю кокпит A-10C

i7 7700k, 32Gb RAM, SSD NVMe, GTX 1080, Hotas Warthog, HTC Vive.

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

With love from Russia

Link to comment
Share on other sites

Adding queues would be a waste of memory, especially on a system that only has 2048 bytes of RAM. No matter how long you make the queue, you can't guarantee that it doesn't fill up, so you'd still be required to handle the case of not being able to transmit a message immediately.

 

If you don't want to wait until the transmit buffer is free again, you can react differently when sendDcsBiosMessage() returns false. Instead of retrying to send the message until it succeeds, simply skip updating the variable that holds the last seen state, so the change is detected again the next time the program executes loop(). That's what the DCS-BIOS Arduino Library does.

Link to comment
Share on other sites

hello...........

i have bought MEGA 2560 R3 ATMEGA16U2 ATMEGA2560-16AU Board from

here

 

and would love to learn how to make some instruments work for Mirage2000.

I have made almost all the right and left side panel work with Sioc and Opencockpit Cards.

Also managed to make the majority of the leds work.

Now i need your help making some instruments using DCS-BIOS.

thank you in advance

Link to comment
Share on other sites

hello...........

i have bought MEGA 2560 R3 ATMEGA16U2 ATMEGA2560-16AU Board from

here

 

and would love to learn how to make some instruments work for Mirage2000.

I have made almost all the right and left side panel work with Sioc and Opencockpit Cards.

Also managed to make the majority of the leds work.

Now i need your help making some instruments using DCS-BIOS.

thank you in advance

 

I suggest you start with a bunch of reading. The DCS-BIOS Users Guide as well as other related info can be found here: http://dcs-bios.a10c.de/docs/v0.5.0/userguide.html and here: http://dcs-bios.a10c.de/

 

After that you should cruise through this thread: https://forums.eagle.ru/showthread.php?t=141096 There are some examples of how people are using DCS-BIOS although some examples use an older version of DCS-BIOS. Just make sure you use the most recent version including the most recent version of the DCS-BIOS Arduino library.

 

Have fun.:thumbup:

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

  • Recently Browsing   0 members

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