Jump to content

DCS-BIOS Discussion Thread


FSFIan

Recommended Posts

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

 

However many you need to.

 

You can run several copies of the connect-serial-port.cmd script to handle multiple boards connected to separate USB ports (DCS-BIOS 2.0 will make this a bit easier to handle).

 

If you have more than two or three boards, you should consider using an RS-485 bus. In that setup, only one Arduino (the "bus master", which has to be an Arduino Mega 2560) is connected to the PC. It is also connected to up to three RS-485 transceivers (MAX487 chips), each of which is the start of an RS-485 bus. With the MAX487, each RS-485 bus can theoretically connect up to 126 other Arduino boards (each of which needs a MAX487 chip and one free I/O pin to control the TX_ENABLE signal for that chip).

 

The RS-485 bus support is a relatively new addition to DCS-BIOS. Several people have gotten it to work, but no one knows where the practical limits are yet (the practical limit for the number of devices on a bus might be closer to a few dozen devices instead of the theoretical max. of 126). One bus master can theoretically talk to three RS-485 buses, but I am not sure if I need to limit that number to two to guarantee reliable operation. That said, RS-485 is definitely the way to go if you are planning to build a full cockpit.

 

If you want to play around with RS-485, buy some MAX487 chips (search for MAX487CPA, should be about $0.15 to $0.20 per chip), read its datasheet and the comments in the RS485 example sketches.

 

What would be the best board to use?

 

For best results and to be able to use the RS-485 support, you need a board with either the ATMega328 processor (Uno, Nano, Pro Mini, several other variants) or an ATMega2560 processor (Arduino Mega 2560).

 

I recommend the Nano for most applications: compared to the Uno, it is cheaper, smaller (easier to hide behind the panel), and it can be plugged into a solderless breadboard. Due to its smaller form factor you cannot plug a shield into it, but you won't need that for cockpit panels anyway.

 

The Pro Mini is even cheaper and smaller, but is slightly more annoying to program (you need a separate USB-to-serial converter board).

 

The Arduino Mega 2560 shines if you need an RS-485 bus master (which needs the 4 UARTs that the Mega provides) or you have a panel that needs more I/O pins.

 

Some people go with Megas for everything so they need less Arduino boards. Warhog and I decided to build each panel as an independent module, so he uses mostly Nanos and Pro Minis. This allows each panel to be built and tested in independently and reduces the number of wires across panel boundaries.

 

Multiple small Arduinos are slightly more expensive (mostly because you need a few more MAX487 chips), but you get a more modular setup and more processing power (the ATMega2560 has more I/O pins and more RAM than the ATMegea328 but it does not run faster). The 16 MHz processor on the microcontroller won't be an issue for switches and LEDs, but it becomes a relevant factor if you do timing critical things like stepper motor control.

Link to comment
Share on other sites

hi everybody, i m geting stuck and i need some help about how to make stepper turns in modulo ...

here s the part of the code where i ve problemes

 

code:

 

void onRsbnRange1Change(unsigned int DalnostValue) {

int Dalnost = map (DalnostValue, 0, 65535, 0, 3020);

if (DalnostValue == 65535){

Dalnomer.setCurrentPosition(3020);

}

else{

Dalnomer.moveTo(Dalnost);

}

 

}

DcsBios::IntegerBuffer rsbnRange1Buffer(0x3222, 0xffff, 0, onRsbnRange1Change);

 

 

 

in this case it s the RSBN range instrument, it turns until 10 km then it goes back to 0 ....

 

in other terms i need to explain that when DCSBIOS value passes by 0 it don t need to go back to the 0 but to continues in the same direction ...

 

 

thank s for the futur answer (s) ...

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

Thank you Ian, you sorted up some mess in my head. did some testing today with an Arduino UNO. my first DCS-BIOS project would probably be the UH-1 caution panel. so i hooked up some leds, they all worked fine, setup was nice and easy. then i tried to operate the test/reset switch - that did not worked. the bright/dimm switch didn't work either. i tested the hardwre switches on some other switches in the cockpit (gov, ldg lights...)- they worked fine.

So i observed those two switches on the interactive control reference. when i flip the switch in the virtual cockpit, it will change it's state in the control reference. when i flip the hardware switch nothing happens.

switch conected to GND on common lead, pin 5 and 6 as the inputs.

my line of code for the switch looks like that:

DcsBios::Switch3Pos clpResetTestSw("CLP_RESET_TEST_SW", 5, 6);

i wonder what am i doing wrong?

Cheers,

Yoreh

Link to comment
Share on other sites

hi everybody, i m geting stuck and i need some help about how to make stepper turns in modulo ...

 

Here is a sketch that WarHog and I have written for the Vid 60 series of stepper motors. It is built on top of the AccelStepper library.

 

Something like this will eventually be added to the DCS-BIOS Arduino library (when I get around to write proper documentation for it, etc), but right now I am concentrating on writing DCS-BIOS 2.0 so I am not concentrating on the Arduino library.

 

In the mean time, simply copying the Vid60Stepper class to the top of the sketch will do the trick. (If it's ugly but it works...)

Link to comment
Share on other sites

not work

 

Can somebody help me ?

Excuse for many words, but already I have broken my brain, BUT the tumbler doesn't turn on

 

 

I build mig 15 cocpit. And i want realize it on DCS -BIOS. It`s everything work in A-10.

And for begin I want press one 2pos toggle ACCU

A small part of my -------- clickable.lua and --------------- device_int.lua ------command_defs.lua

 

-------- clickable.lua

-- Right Panel
elements["pnt_152"]		= default_2_position_tumb(_("Accumulator Switch, ON/OFF"), devices.ELEC_INTERFACE, electric_commands.Mig15_Command_BatterySw, 152) --3071
elements["pnt_153"]		= default_2_position_tumb(_("Generator Switch, ON/OFF"), devices.ELEC_INTERFACE, electric_commands.Mig15_Command_GeneratorSw, 153)
elements["pnt_151"]		= default_2_position_tumb(_("Nose Light Master Switch, ON/OFF"), devices.ELEC_INTERFACE, electric_commands.Mig15_Command_CB_NoseLight, 151)
....................................................


--------------- device_int.lua

MainPanel = {"Mig15::ccMig15MainPanel", 
		LockOn_Options.script_path.."mainpanel_init.lua",
		{{"FM_Proxy", devices.FM_PROXY},
		 {"electric_interface", devices.ELEC_INTERFACE},
		 {"hydro_interface", devices.HYDROSYS_INTERFACE},
		 {"gear_interface", devices.GEAR_INTERFACE},
.............................................

local count = 0
local function counter()
count = count + 1
return count
end

count = 3000
electric_commands =
{
Mig15_Command_BatterySw			= counter();

...................................................
 

 

So, I need use

element 152 "Accumulator Switch, ON/OFF"

devices.ELEC_INTERFACE (Num.2)

electric_commands.Mig15_Command_BatterySw (Num.3001)

 

1. I create MIG15.lua

--------Mig15.lua

local success1 = pcall(dofile, lfs.currentdir().."mods/aircraft/Mig-15bis/Cockpit/devices.lua")
local success2 = pcall(dofile, lfs.currentdir().."mods/aircraft/Mig-15bis/Cockpit/command_defs.lua")
if success1 and success2 then 

BIOS.protocol.beginModule("MiG-15Bis", 0x2200)
BIOS.protocol.setExportModuleAircrafts({"MiG-15Bis"})

local documentation = moduleBeingDefined.documentation

local document = BIOS.util.document

local parse_indication = BIOS.util.parse_indication

local defineFloat = BIOS.util.defineFloat
local defineIndicatorLight = BIOS.util.defineIndicatorLight
local definePushButton = BIOS.util.definePushButton
local definePotentiometer = BIOS.util.definePotentiometer
local defineRotary = BIOS.util.defineRotary
local defineSetCommandTumb = BIOS.util.defineSetCommandTumb
local defineTumb = BIOS.util.defineTumb
local defineToggleSwitch = BIOS.util.defineToggleSwitch
local defineToggleSwitchToggleOnly = BIOS.util.defineToggleSwitchToggleOnly
local defineFixedStepTumb = BIOS.util.defineFixedStepTumb
local defineFixedStepInput = BIOS.util.defineFixedStepInput
local defineVariableStepTumb = BIOS.util.defineVariableStepTumb
local defineString = BIOS.util.defineString
local defineRockerSwitch = BIOS.util.defineRockerSwitch
local defineMultipositionSwitch = BIOS.util.defineMultipositionSwitch

dofile(lfs.currentdir().."mods/aircraft/Mig-15bis/Cockpit/devices.lua")
dofile(lfs.currentdir().."mods/aircraft/Mig-15bis/Cockpit/command_defs.lua")

defineToggleSwitch("AC_GEN", 2, 3001, 152, "Main Power Panel", "Accumulator Switch, ON/OFF")
--defineToggleSwitch("AC_GEN",  devices.ELEC_INTERFACE,  electric_commands.Mig15_Command_BatterySw, 152, "Main Power Panel", "Accumulator Switch, ON/OFF")

 

2) Changed mig21.lua on mig15.lua in bios.lua

 

dofile(lfs.writedir()..[[scripts\dcs-bios\lib\mig15.lua]])

 

Add

a("MiG-15Bis", true)

in AircraftList.lua

3) changed in dcsbios.h string

Serial.begin(9600); //my comport 9600

 

4)

 

Arduino Mega2560 sketch

 

#define DCSBIOS_DEFAULT_SERIAL

#include "DcsBios.h"

DcsBios::Switch2Pos AccBtn("AC_GEN", 10);

void setup() {

DcsBios::setup();

}

 

void loop() {

DcsBios::loop();

}

 

Start Arduino. test by connect_serial.

Press button 3 time

Get answer (in attachments)

 

So I see the data received. BUT DCS not see them? and tumb not input

Data go to arduino, because, diodes TX blinking, and go out from Arduino, because diodes RX blinking, and socket work too.

DCS.log not have mistake, dcs_bios.log is empty.

 

 

I hope on your help !!

send.thumb.jpg.3c1cac148a86ac80ea4cae5fe8145fc0.jpg


Edited by jazzymanserg
Link to comment
Share on other sites

So, I need use

element 152 "Accumulator Switch, ON/OFF"

devices.ELEC_INTERFACE (Num.2)

electric_commands.Mig15_Command_BatterySw (Num.3001)

 

You are correct, you need to use 3001 for the button number.

 

defineToggleSwitch("AC_GEN", 2, 3000, 152, "Main Power Panel", "Accumulator Switch, ON/OFF")

 

...but it seems you are using 3000 instead. Try changing that to 3001, that should do it. If that does not work, let me know and I'll grab a Mig-15 beta key and take a closer look.

Link to comment
Share on other sites

Oh, Ian ! Great thanks for answer. It was typographical error.

In game

defineToggleSwitch("AC_GEN", 2, 3001, 152, "Main Power Panel", "Accumulator Switch, ON/OFF") I edited past message

and nothing work.

Socket Ok, com ok, maybe it some secrets in Mig-15?

Not shure? but maybe problem in configuration?

I have 2 arduino UNO on com3 com4 and 2 arduino nano on com 6 and com 8/ they wrk by PPjoy witout sockets.

And arduino Mega on com 9 by dcs_bios


Edited by jazzymanserg
Link to comment
Share on other sites

I corrected but not result. I found one proble. When I listen Com port, I hear symbols, and when I wrote in program

void setup() {

Serial.begin(9600);

//DcsBios::setup();

}

I become see AC_GEN 1 AC_GEN 0/ Its good but......

but tumbler not change

then I wrote for test

#define DCSBIOS_DEFAULT_SERIAL

#include "DcsBios.h"

DcsBios::Switch2Pos masterCautionBtn("AC_GEN", 10);

void setup() {

Serial.begin(9600);

}

 

void loop() {

sendDcsBiosMessage("AC_GEN", "1");

}

and see in com port AC_GEN 1, so its every thing good with com port and problem is in socket. Where data from com send to tcp or udp? May be uncorrect com bitrate stay there ? I have 9600 bod. I dont find file with this sending


Edited by jazzymanserg
Link to comment
Share on other sites

Some have been asking about the script for the CMSC panel for the A-10C.

Counter Measure Set Control Panel

Arduino Nano or Uno is driving 74HC595N which in turn is driving the HDSP-2531.

This script drives 2 of the 3 displays that are on the CMSC. The third display is driven by a separate Arduino/HDSP-2531 combo.

 

 

/* CMSC Chaff/Flare Display and MWS Display

* Trouble-shooting notes, if power wire comes loose from TB then it not work right.

*

* Two HDSP-2531 being wired to two 74HC595N

* HDSP-2531 pin 2 "/Flash Ram" - 5VDC

* HDSP-2531 pin 10 "A4" - No Connect

* HDSP-2531 pin 11 "Clock Source" - 5VDC

* HDSP-2531 pin 12 "Clock In/Out" - No Connect

* HDSP-2531 pin 17 "Thermal Test" - No Connect

* HDSP-2531 pin 15 "Vcc" - 5VDC

* HDSP-2531 pin 16 "GND" - Ground

* HDSP-2531 pin 18 "GND" - Ground

* HDSP-2531 pin 19 "Read" - No Connect

*/

 

#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"

 

// HDSP-2531 Chip #1

int RST = A0; // HDSP-2531 pin 1 (share amoungst the two chips)

int WR = A1; // HDSP-2531 pin 13

int CE = 10; // HDSP-2531 pin 14

int AD0 = A2; // HDSP-2531 pin 3

int AD1 = A3; // HDSP-2531 pin 4

int AD2 = A4; // HDSP-2531 pin 5

int AD3 = A5; // HDSP-2531 pin 6 (share amoungst the two chips)

int DS = 2; // 74HC595N pin 14 shift register data pin

int ST_CP = 3; // 74HC595N pin 12 shift register storage clock(latch)

int SH_CP = 4; // 74HC595N pin 11 shift register shift clock(data polling)

 

// HDSP-2531 Chip #2

int WR_2 = 5; // HDSP-2531 pin 13

int CE_2 = 6; // HDSP-2531 pin 14

int AD0_2 = 7; // HDSP-2531 pin 3

int AD1_2 = 8; // HDSP-2531 pin 4

int AD2_2 = 9; // HDSP-2531 pin 5

int DS_2 = 11; // 74HC595N pin 14 shift register data pin

int ST_CP_2 = 12; // 74HC595N pin 12 shift register storage clock(latch)

int SH_CP_2 = 13; // 74HC595N pin 11 shift register shift clock(data polling)

 

/*

* HDSP-2531 to 74HC595N wiring

* HDSP-2531 "D0" pin 20 to 74HC595N pin 15

* HDSP-2531 "D1" pin 21 to 74HC595N pin 1

* HDSP-2531 "D2" pin 25 to 74HC595N pin 2

* HDSP-2531 "D3" pin 26 to 74HC595N pin 3

* HDSP-2531 "D4" pin 27 to 74HC595N pin 4

* HDSP-2531 "D5" pin 28 to 74HC595N pin 5

* HDSP-2531 "D6" pin 29 to 74HC595N pin 6

* HDSP-2531 "D7" pin 30 to 74HC595N pin 7

* 74HC595N "/MasterReset" pin 10 to 5V

* 74HC595N "/OutputEnable" pin 13 to GND

* 74HC595N "Data Out" pin 9 to No Connect

* 74HC595N "Ground" pin 8 to GND

* 74HC595N "Vcc" pin 16 to 5V

*/

 

void setup() {

DcsBios::setup();

pinMode(RST, OUTPUT);

pinMode(WR, OUTPUT);

pinMode(WR_2, OUTPUT);

pinMode(CE, OUTPUT);

pinMode(CE_2, OUTPUT);

pinMode(AD0, OUTPUT); // data register selection // these 4 pins allow one to select a data register.

pinMode(AD0_2, OUTPUT);

pinMode(AD1, OUTPUT); // data register selection

pinMode(AD1_2, OUTPUT);

pinMode(AD2, OUTPUT); // data register selection

pinMode(AD2_2, OUTPUT);

pinMode(AD3, OUTPUT); // data register selection

pinMode(DS, OUTPUT); // shift register serial in

pinMode(DS_2, OUTPUT);

pinMode(ST_CP, OUTPUT); // shift register storage pin(latch)

pinMode(ST_CP_2, OUTPUT);

pinMode(SH_CP, OUTPUT); // shift register clock pin(clock)

pinMode(SH_CP_2, OUTPUT);

digitalWrite(CE, HIGH); // chip enable, go low before write. go high after write

digitalWrite(CE_2, HIGH);

digitalWrite(WR, HIGH); // write enable, go low to start write, go high when done.

digitalWrite(WR_2, HIGH);

resetDisplay();

}

 

void resetDisplay()

{

digitalWrite(RST, LOW);

delayMicroseconds(1);

digitalWrite(RST,HIGH);

delayMicroseconds(150);

digitalWrite(AD3, HIGH);

}

 

void writeChaffDisplay(char *input)

{

for (int i=0; i<8; i++)

{

digitalWrite(AD0, (1&i)!=0?HIGH:LOW); // character address because there are 8 alphanumeric digits

digitalWrite(AD1, (2&i)!=0?HIGH:LOW); // 000 is digit on far left. 111 is digit on far right

digitalWrite(AD2, (4&i)!=0?HIGH:LOW);

delay(1);

digitalWrite(CE, LOW);

delay(1);

digitalWrite(WR, LOW);

delay(1);

digitalWrite(ST_CP, LOW);

delay(1); //allow the display to retrieve the values set to the Data pins

shiftOut(DS, SH_CP, MSBFIRST, input);

delay(1);

digitalWrite(ST_CP, HIGH);

delay(1);

digitalWrite(WR, HIGH);

delay(1);

digitalWrite(CE, HIGH);

delay(1);

}

}

 

void writeMWSDisplay(char *input)

{

for (int i=0; i<8; i++)

{

digitalWrite(AD0_2, (1&i)!=0?HIGH:LOW); // character address because there are 8 alphanumeric digits

digitalWrite(AD1_2, (2&i)!=0?HIGH:LOW); // 000 is digit on far left. 111 is digit on far right

digitalWrite(AD2_2, (4&i)!=0?HIGH:LOW);

delay(1);

digitalWrite(CE_2, LOW);

delay(1);

digitalWrite(WR_2, LOW);

delay(1);

digitalWrite(ST_CP_2, LOW);

delay(1); //allow the display to retrieve the values set to the Data pins

shiftOut(DS_2, SH_CP_2, MSBFIRST, input);

delay(1);

digitalWrite(ST_CP_2, HIGH);

delay(1);

digitalWrite(WR_2, HIGH);

delay(1);

digitalWrite(CE_2, HIGH);

delay(1);

}

}

 

void loop() {

DcsBios::loop();

}

 

// Chaff / Flare Amount Display

void onCmscTxtChaffFlareChange(char* newValue) {

writeChaffDisplay(newValue);

}

DcsBios::StringBuffer<8> cmscTxtChaffFlareBuffer(0x108e, onCmscTxtChaffFlareChange);

 

// MWS Status Display

void onCmscTxtMwsChange(char* newValue) {

writeMWSDisplay(newValue);

}

DcsBios::StringBuffer<8> cmscTxtMwsBuffer(0x12b0, onCmscTxtMwsChange);

Link to comment
Share on other sites

Ian;3092502']Here is a sketch that WarHog and I have written for the Vid 60 series of stepper motors. It is built on top of the AccelStepper library.

 

Something like this will eventually be added to the DCS-BIOS Arduino library (when I get around to write proper documentation for it, etc), but right now I am concentrating on writing DCS-BIOS 2.0 so I am not concentrating on the Arduino library.

 

In the mean time, simply copying the Vid60Stepper class to the top of the sketch will do the trick. (If it's ugly but it works...)

 

thank you IAN for the answer i ll give it a try tonight after work, and i ll try to find the part that interest me in that code ...

 

good luck for the 2.0 and waiting for it :)

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

and see in com port AC_GEN 1, so its every thing good with com port and problem is in socket. Where data from com send to tcp or udp? May be uncorrect com bitrate stay there ? I have 9600 bod. I dont find file with this sending

 

Sorry, I did not notice that when I first read your post.

Why are you trying to run the COM port at 9600 bps? DCS-BIOS uses 250000 bps everywhere. If the PC and Arduino use different baud rates, the RX and TX LEDs will still blink, but the data will be misinterpreted and arrive as garbage.

 

Even if you'd get the PC and Arduino to agree on 9600 bps, it would be too slow for all the export data.

 

On the other hand, you said everything works with the A-10C, so why would the serial comms work with the A-10C and not with the Mig-15?

 

Can you operate the Mig-15 switch through the interactive control reference?

Link to comment
Share on other sites

Ian, first of all, thank you for your attention!

 

Ian;3092841']

Can you operate the Mig-15 switch through the interactive control reference?

 

No I have not mig 15 json, file, but Metadatastart sad me that module is Mig-15 . and changeged _UPDATE_SKIP_COUNTER

I think that i not need control reference, but took your advice I decided to make the json for the mig-15 for one button.

[b]{ "[color=Red]Main Power Panel"[/color]: [/b]{
[b]"[color=Red]AC_GEN"[/color]: {[/b]
"category": "Main Power Panel", 
"control_type": "selector",
"description": "AC Generator On/Off", 
"identifier": "AC_GEN", 
[b]"[color=Red]inputs"[/color]: [ {[/b]
"description": "switch to previous or next state", "interface": "fixed_step" 
},
{"description": "set position", 
"interface": "set_state", 
"max_value": 1
}, 
{ "argument": "TOGGLE", 
"description": "Toggle switch state", 
"interface": "action"  } ], 
"momentary_positions": "none",
[b][color=Red]"outputs":[/color] [ {[/b]
"address": 8704,
"description": "selector position",
"mask": 8, 
"max_value": 1,
"shift_by": 3, 
"suffix": "", 
"type": "integer" } ], 
"physical_variant": "toggle_switch" 
}   }}

So, where can I get output

parametres "address","description", "selector position","mask","max_value","shift_by","suffix","type"

 

About 250000. I can't setup on 250000 I have only 128000.

So, plug arduino, enter in devices menager, open Com9. Try change bod rate, open list,and there... from 1200 to 128000.

 

I will try 128000. May be it will enought

 

when i install it on A-10. I not change anithing and not corrected baud rate in windows, and it worked/ I don't understand how

 

Ian tell me please, in whitch lua file data received from com port? I can find it

 

json.jpg.e0aa3e53e548e701336fadcbf9ba25a4.jpg


Edited by jazzymanserg
Link to comment
Share on other sites

No I have not mig 15 json, file, but Metadatastart sad me that module is Mig-15 . and changeged _UPDATE_SKIP_COUNTER

I think that i not need control reference

The MetadataStart module will tell you the name of any aircraft, whether it has DCS-BIOS support or not.

 

If you do not have a MiG-15bis.json file despite not having any errors in dcs.log, your Mig15.lua file was never loaded.

 

Did you edit BIOS.lua to load your Mig15.lua with dofile()?

If you do, you should get an error message in dcs.log about the missing 'end' statements for the 'if' statement at the top of your file (unless you did not post your entire file).

 

About 250000. I can't setup on 250000 I have only 128000.

The list in Device Manager only goes up to 128000. That does not mean that your USB-to-serial chip can't support more than that. The connect-serial-port.cmd script configures the port for 250000 bps, you don't have to configure that yourself.

 

I have only ever seen two variants of the Arduino Mega 2560, they either use an ATMega16U2 for the USB connection (as intended in the original design) or they use the cheaper CH340 chip. Both variants handle 250000 bps without issues on Windows 7 and Windows 10.

 

Ian tell me please, in whitch lua file data received from com port? I can find it

It isn't. Export.lua only talks to the network. The connect-serial-port.cmd script runs socat, which talks to your Arduino over the serial port and to Export.lua over the network and sends data back and forth between the two.

Link to comment
Share on other sites

Thanx Ian, I'll expect com baud rate in evening

Ian;3092923']

Did you edit BIOS.lua to load your Mig15.lua with dofile()?

If you do, you should get an error message in dcs.log about the missing 'end' statements for the 'if' statement at the top of your file (unless you did not post your entire file).

I'm not use "if". In higher post it was Mig15.jsonp file.

I'm reading developer guide and try to understand about start address for output parametrs. For example: I have begin module address 0x2800, and i have

defineToggleSwitch("AC_GEN", 2, 3001, 152, "Main Power Panel", "AC Generator On/Off") Its creates by bios.utils.

So, I must write output address 10240 (0x2800 in DEC)

Mask (number of edit bit) =1 Shift (number of shift bit)=0 because it's first

SO output.

"address": 10240,

"description": "selector position",

"mask": 1,

"max_value": 1,

"shift_by":0,

"suffix": "",

"type": "integer" } ],

 

Am I right?

Is there some program for calculating address, mask and shift all off crafts variable of, for example, A10.lua? Or i must manual calculate each of them ?


Edited by jazzymanserg
Link to comment
Share on other sites

Its crazy I try everything, inspect all codes. Tx - blinking - socket create, rx blink when press botton, dcs.log without mistake, dcs_bios log empty. Control reference launch properly. I see Mig -15 and can switch toggle,

BUT IN COCPIT - NOTHING

I attach all needle files.

Ian I can't solved this quest.

What can I use for debugging / I think that problem in LUA

I hope, you help me solve it!:joystick:

And why is the file dcs-bios.log empty? This is strange. I even delete it, no result. Bios create it again, and it empty

 

When I wrote simple export.lua file

dofile(lfs.currentdir().."mods/aircraft/MiG-15bis/Cockpit/Scripts/devices.lua")

dofile(lfs.currentdir().."mods/aircraft/MiG-15bis/Cockpit/Scripts/command_defs.lua")

function LuaExportBeforeNextFrame()

GetDevice(2):performClickableAction(3001,1)--power ON

end

Its working, but without dcs_bios

AircraftList.lua

BIOS.lua

clickabledata.lua

command_defs.lua

device_init.lua

devices.lua

Export.lua

log.txt

MiG-15bis.lua

AC_GEN.thumb.jpg.2d2d4369f7daced96a6fd6a9c037f26d.jpg

json.thumb.jpg.767f11790c7acc6493b31c81b8f40bf8.jpg

501087664_Consoleafterlaunchgame.thumb.jpg.b5ba9123a28a8be7bd462f858c816966.jpg


Edited by jazzymanserg
Link to comment
Share on other sites

thank you soooooooo much IAN, like that it s working fine :)

 

the only think i ve to do now is to test it in time and see if the stepper dont miss distances ...

 

i m trying to add the modulo function, so when i ll do it, i ll let you know for more advices

 

thank you another time for you time :)

 

 

 

 

void onRsbnRange1Change(unsigned int DalnostValue) {
   int currentStepperPosition = 0; 
   signed long lastAccelStepperPosition;
   int Dalnost;
 int targetPosition = map(DalnostValue, 0, 65535, 0, 3020-1);
   int movementSinceLastUpdate = Dalnomer.currentPosition() - lastAccelStepperPosition;
    currentStepperPosition += movementSinceLastUpdate;
    lastAccelStepperPosition = Dalnomer.currentPosition();

   if (currentStepperPosition < 0) currentStepperPosition += 3020;
   if (currentStepperPosition > 3020) currentStepperPosition -= 3020;

int delta = targetPosition - currentStepperPosition;


  if (delta < -(3020/2)) delta += 3020;

  if (delta > (3020/2)) delta -= 3020;


Dalnomer.move(delta);
      
   
   
   

}
DcsBios::IntegerBuffer rsbnRange1Buffer(0x3222, 0xffff, 0, onRsbnRange1Change);

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

hello IAN ...

 

a question, in my RSBN range instrument i ve 3 events which are the units the tens and the hundreds ( on args 64,65,66), is it possible to mix them together to have only one event in order to guarentee the atomicity as uniq data ?

 

 

really sorry for the late question ...

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

is it possible to mix them together to have only one event in order to guarentee the atomicity as uniq data ?

 

The normal code examples pass a callback function to the IntegerBuffer or Int16Buffer class. You can also choose to pass NULL for the callback parameter and use the buffer classes "hasUpdatedData()" and "getData()" methods in your loop() function.

 

Here's a sketch to display the A-10C's altimeter pressure setting on an OLED display. It is a good example of this technique.

 

Lines 30 to 33 define the IntegerBuffer instances (note that we pass NULL to the last argument).

 

In the loop() function, we check in line 52 if any of the integer buffers got new data. If so, we get the value from all of them and draw it to the display.

 

Some background on how this works: when new data comes in, the IntegerBuffer will set an internal "dirty" flag. The hasUpdatedData() method returns that flag. The flag is reset whenever you call getData().

 

If you pass a callback function, every time loop() runs, the IntegerBuffer will do this:

if (hasUpdatedData()) callback(getData());

So if you want to handle the flag yourself, you must not pass a callback function.

 

This way of structuring the code comes in handy whenever you have to treat multiple values as a unit, for example because they get written to the same display and updating parts of the display is as slow as updating the complete display.

 

Note that this helps with the performance of display updates (e.g. for SSD1306 OLEDs or MAX7219 chips), but it does not guarantee atomicity. There is still a tiny chance that there will be a ~30 millisecond age difference between some of the data.

 

The only thing in the DCS-BIOS Arduino library that cares about atomicity is the StringBuffer (it does double buffering). It was the only case where I thought it was worth spending the extra RAM.

 

If you want to absolutely guarantee that all of your RSBN distance digits come from the exact same frame in DCS: World, you'll either have to "misuse" a StringBuffer (if all of your data values have adjacent addresses) or you will have to implement your own class that inherits from ExportStreamListener and implements a onConsistentData() method that disables interrupts and copies the data to a second buffer. Note that onConsistentData() should do as little work as possible; any work that may take some time (e.g. digitalWrite() or display updates) should be called from the loop() method.

Link to comment
Share on other sites

Ian;3096525']The normal code examples pass a callback function to the IntegerBuffer or Int16Buffer class. You can also choose to pass NULL for the callback parameter and use the buffer classes "hasUpdatedData()" and "getData()" methods in your loop() function.

 

Here's a sketch to display the A-10C's altimeter pressure setting on an OLED display. It is a good example of this technique.

 

Lines 30 to 33 define the IntegerBuffer instances (note that we pass NULL to the last argument).

 

In the loop() function, we check in line 52 if any of the integer buffers got new data. If so, we get the value from all of them and draw it to the display.

 

Some background on how this works: when new data comes in, the IntegerBuffer will set an internal "dirty" flag. The hasUpdatedData() method returns that flag. The flag is reset whenever you call getData().

 

If you pass a callback function, every time loop() runs, the IntegerBuffer will do this:

if (hasUpdatedData()) callback(getData());

So if you want to handle the flag yourself, you must not pass a callback function.

 

This way of structuring the code comes in handy whenever you have to treat multiple values as a unit, for example because they get written to the same display and updating parts of the display is as slow as updating the complete display.

 

Note that this helps with the performance of display updates (e.g. for SSD1306 OLEDs or MAX7219 chips), but it does not guarantee atomicity. There is still a tiny chance that there will be a ~30 millisecond age difference between some of the data.

 

The only thing in the DCS-BIOS Arduino library that cares about atomicity is the StringBuffer (it does double buffering). It was the only case where I thought it was worth spending the extra RAM.

 

If you want to absolutely guarantee that all of your RSBN distance digits come from the exact same frame in DCS: World, you'll either have to "misuse" a StringBuffer (if all of your data values have adjacent addresses) or you will have to implement your own class that inherits from ExportStreamListener and implements a onConsistentData() method that disables interrupts and copies the data to a second buffer. Note that onConsistentData() should do as little work as possible; any work that may take some time (e.g. digitalWrite() or display updates) should be called from the loop() method.

 

 

thank you IAN, :pilotfly: :) this will really help me in the near futur


Edited by kadda

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

#define DCSBIOS_IRQ_SERIAL


#include "DcsBios.h"
#include <AccelStepper.h>



AccelStepper Dalnomer(AccelStepper::DRIVER,35,34);

long  range1,range10,range100;
long  position;
unsigned long positionmoteur;


DcsBios::IntegerBuffer rsbnRange10Buffer(0x3224, 0xffff, 0, NULL);
DcsBios::IntegerBuffer rsbnRange100Buffer(0x3226, 0xffff, 0, NULL);


void onRsbn1Change(unsigned int range1val) {

    range1 = (range1val* (unsigned long)100)/6553;
    if(rsbnRange10Buffer.hasUpdatedData()){
            range10= (rsbnRange10Buffer.getData())/6553;
    }
    if(rsbnRange100Buffer.hasUpdatedData()){
            range100= (rsbnRange100Buffer.getData())/6553;
    }

    position = range1+range10*1000+range100*10000;

    positionmoteur = (position*3020)/1000;  
 
    Dalnomer.moveTo(positionmoteur);

}

DcsBios::IntegerBuffer rsbnRange1Buffer(0x3222, 0xffff, 0, onRsbn1Change);



void setup() {
 Dalnomer.setMaxSpeed(800.);
 Dalnomer.setAcceleration(600.);
 DcsBios::setup();
}

void loop() {
 DcsBios::loop();
 Dalnomer.run();
}

 

 

 

it s working juste fine like that :)

 

 

 

thatnk you IAN for you explains :)

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

Hi all,

 

I have a question for Ian,

I don't know if the question has ever been posed..

 

Have you ever considered a multi aircraft use ?

 

In my squadron (2nd FFS), we have multiple guys that fly with many DCS modules and they are interested for generic panels (with general functions like landing gear, lights, canopy, etc...)

 

i don't know how this can be implemented, maybe with the module library address ??

a test at the beginning of the Arduino sketch ?

 

have you planned to add this feature to your roadmap ?

 

Thx !!

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • Recently Browsing   0 members

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