Jump to content

DCS-BIOS Discussion Thread


FSFIan

Recommended Posts

Well, the Warhog solution will most definitely cover all possible scenarios when it comes to power requirements :)

Personally I use ULN2803 circuits that is good enough for driving a couple of led's or light bulbs for indicators for my panels. They are simple to use and doesn't require any additional components.

Link to comment
Share on other sites

Hi

 

thanks for the responses; teach me never to try short cuts!

 

Neal

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Link to comment
Share on other sites

Hi John

what size resisters are you using, i cant quiet make it out in the picture?

 

thanks

 

Neal

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Link to comment
Share on other sites

Neil, go to the link I posted. It will have everything you need right there.

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

NOOB TIME !!!

 

i m stuck making my stepper working, for the moment i need just to understand how to make it get data of the altimeter, i don t need to program zeroing because i maked a machanical way to take it back to the zero if i need ...

 

code:

 

#define DCSBIOS_DEFAULT_SERIAL

 

#include <AccelStepper.h>

#include "DcsBios.h"

#define FULLSTEP 4

 

 

// Motor pin definitions

#define motorPin1 3

#define motorPin2 4

#define motorPin3 5

#define motorPin4 6

 

 

AccelStepper Motor1(FULLSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

 

 

void onVd20Change(unsigned int newValue) {

newValue = map (onVd20Change ,0 , 65535, 0, 81920);

Motor1.run();

}

DcsBios::IntegerBuffer vd20Buffer(0x3200, 0xffff, 0, onVd20Change);

 

void setup() {

DcsBios::setup();

}

 

void loop() {

DcsBios::loop();

}

 

 

thanks a lot, any help is welecome


Edited by kadda

With respect

_________________

Kadda

_________________

My works

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

Link to comment
Share on other sites

This is the code I've been using to control VID stepper motors for my cockpit. I found in the ED Forums. It works very well. Not sure if it's considered the latest code... You will need to modify prams depending on your stepper and what instrument you are targeting. It does zero the stepper at power on/DCS-BIOS init.

 

#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/2);
       }
     }
     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 = {
 695,  // maxSteps
 100, // maxSpeed
 100 // acceleration
 };


// define AccelStepper instance
AccelStepper stepper;
// define Vid29Stepper 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 abc(0x12c0, stepper, stepperConfig, [](unsigned int newValue) -> unsigned int {
 /* this function needs to map newValue to the correct number of steps */
 return map(newValue, 0, 65535, 0, stepperConfig.maxSteps);
}); 


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

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

 

i m stuck making my stepper working, for the moment i need just to understand how to make it get data of the altimeter, i don t need to program zeroing because i maked a machanical way to take it back to the zero if i need ...

 

code:

 

#define DCSBIOS_DEFAULT_SERIAL

 

#include <AccelStepper.h>

#include "DcsBios.h"

#define FULLSTEP 4

 

 

// Motor pin definitions

#define motorPin1 3

#define motorPin2 4

#define motorPin3 5

#define motorPin4 6

 

 

AccelStepper Motor1(FULLSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

 

 

void onVd20Change(unsigned int newValue) {

newValue = map (onVd20Change ,0 , 65535, 0, 81920);

Motor1.run();

}

DcsBios::IntegerBuffer vd20Buffer(0x3200, 0xffff, 0, onVd20Change);

 

void setup() {

DcsBios::setup();

}

 

void loop() {

DcsBios::loop();

}

 

 

thanks a lot, any help is welecome

Link to comment
Share on other sites

This is the code I've been using to control VID stepper motors for my cockpit. I found in the ED Forums. It works very well. Not sure if it's considered the latest code... You will need to modify prams depending on your stepper and what instrument you are targeting. It does zero the stepper at power on/DCS-BIOS init.

 

#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/2);
       }
     }
     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 = {
 695,  // maxSteps
 100, // maxSpeed
 100 // acceleration
 };


// define AccelStepper instance
AccelStepper stepper;
// define Vid29Stepper 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 abc(0x12c0, stepper, stepperConfig, [](unsigned int newValue) -> unsigned int {
 /* this function needs to map newValue to the correct number of steps */
 return map(newValue, 0, 65535, 0, stepperConfig.maxSteps);
}); 


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

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

 

thx for the answer i ll give it a try this evening :)

With respect

_________________

Kadda

_________________

My works

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

Link to comment
Share on other sites

now the stepper is turning, but only in one way, can someone tell me what i miss

 

CODE:

#define DCSBIOS_DEFAULT_SERIAL

 

#include <AccelStepper.h>

#include "DcsBios.h"

#define FULLSTEP 4

 

 

 

#define motorPin1 3

#define motorPin2 4

#define motorPin3 5

#define motorPin4 6

 

 

AccelStepper Motor1(FULLSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

 

 

void onVd20Change(unsigned int newValue) {

 

long newPosition = ((unsigned long)newValue *(unsigned long)(40960))/(unsigned

long)65535;

 

 

Motor1.moveTo(newPosition);

Motor1.run();

}

 

DcsBios::IntegerBuffer vd20Buffer(0x3200, 0xffff, 0, onVd20Change);

 

void setup() {

DcsBios::setup();

Motor1.setMaxSpeed (1500);

Motor1.setAcceleration(800);

 

 

}

void loop() {

DcsBios::loop();

}

With respect

_________________

Kadda

_________________

My works

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

Link to comment
Share on other sites

Ian;3016342']I don't understand what you mean. What problem are you trying to solve?

 

my probleme is that my stepper is moving correctly, to the required position for ex if i climb to 1000 meters it makes exactly one revolution ... when i stop climbing it stops accelerate and decelerate cerrectly ... but when descending it continu rotating in the same dirrection, so when i m back to 0 m it indicate 2000m :(

 

 

i thought that maybe i ve a probleme with the speed of my card ... but i ve noticed that the values , that shows the "connect-serial-port.cmd" never go back they only augments .....

With respect

_________________

Kadda

_________________

My works

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

Link to comment
Share on other sites

good morning every one :), trying to solve my problem, i decided at 3am to re install completely DCS-BIOS, so i dowloaded it a new time then installed it completely new... the controle reference is working properly and the connect-serial-port.cmd is receiving data correctly "i think" , but now with the same stepper and the same skatch the stepper don t move ...

 

 

- how can i know that my export.lua file is working?

 

 

and another question do DCS-BIOS work with ARDUINO MEGA 2560 REV 3?

 

thanks in advance for answering ...


Edited by kadda

With respect

_________________

Kadda

_________________

My works

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

Link to comment
Share on other sites

- how can i know that my export.lua file is working?

 

Try a very simple sketch (e.g. the MasterCaution example) and see if it works.

 

and another question do DCS-BIOS work with ARDUINO MEGA 2560 REV 3?

 

Yes.

 

 

now the stepper is turning, but only in one way, can someone tell me what i miss

 

CODE:

#define DCSBIOS_DEFAULT_SERIAL

 

#include <AccelStepper.h>

#include "DcsBios.h"

#define FULLSTEP 4

 

 

 

#define motorPin1 3

#define motorPin2 4

#define motorPin3 5

#define motorPin4 6

 

 

AccelStepper Motor1(FULLSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

 

 

void onVd20Change(unsigned int newValue) {

 

long newPosition = ((unsigned long)newValue *(unsigned long)(40960))/(unsigned

long)65535;

 

 

Motor1.moveTo(newPosition);

Motor1.run();

}

 

DcsBios::IntegerBuffer vd20Buffer(0x3200, 0xffff, 0, onVd20Change);

 

void setup() {

DcsBios::setup();

Motor1.setMaxSpeed (1500);

Motor1.setAcceleration(800);

 

 

}

void loop() {

DcsBios::loop();

}

 

Sorry, I missed that post of yours because it's the last on its page, so when I got back to this thread I only saw the one after that.

 

You are not calling Motor1.run() from loop(), so the only time the AccelStepper library ever gets the chance to move the motor for one step in any direction is when the value from DCS has just changed. DCSBIOS_DEFAULT_SERIAL mode should be avoided if possible, use IRQ_SERIAL instead. I can't tell which value you are monitoring, 0x3200 does not seem to be a valid address for any of the aircraft currently supported by DCS-BIOS. Your calculation of newValue will probably run into an integer overflow issue because the result of multiplying 65535 by 40960 is too large to fit into a 32-bit unsigned integer variable.

 

Take a look at the Vid29Stepper class that WhoMadeWho posted (which started as an answer to this question).

It is known to work, but stepper motors can be tricky. If there are any problems, you should run some tests without DCS-BIOS (e.g. modified example sketches from the AccelStepper library) to make sure there are no problems with the hardware itself (something wired incorrectly? needle too heavy for the motor? etc...).

 

@All: if I missed anything else in the past two weeks or so, feel free to remind me via PM. I had to deal with frequent headaches for a few days after a dentist appointment, so I might have marked something as read and forgot to reply later.

Link to comment
Share on other sites

The 0x3200 is the adress for the L-39 that i m adding to dcs bios and the 40960 is my mistake i thought «wrong» that i need to specify number of steps for 20 revolutions of the stepper but i need only 2048 steps per rev

 

So i need to run the motor from the loop?

Does dcs bios support arduino mega 2560 rev3?

 

thank u very much for your answer


Edited by kadda

With respect

_________________

Kadda

_________________

My works

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

Link to comment
Share on other sites

Sorry about asking many time the same question i didn t see the complete answer :)

 

 

Ian;3017269']Try a very simple sketch (e.g. the MasterCaution example) and see if it works.

 

 

 

Yes.


Edited by kadda

With respect

_________________

Kadda

_________________

My works

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

Link to comment
Share on other sites

Hi every body, can some one tell me why my starting value is not 0 but 65498? and if possible how can i make it back to 0 ? thanks

 

We need a lot more information. What do you mean by "starting value"? What sketch and circuit? What instrument in what aircraft are we talking about? It might just be an implementation detail of that particular control.

 

If it's L-39 related, you also need to include a link to the additions you made to DCS-BIOS so others have a chance to replicate the behavior.

Link to comment
Share on other sites

Ian;3020853']We need a lot more information. What do you mean by "starting value"? What sketch and circuit? What instrument in what aircraft are we talking about? It might just be an implementation detail of that particular control.

 

If it's L-39 related, you also need to include a link to the additions you made to DCS-BIOS so others have a chance to replicate the behavior.

 

code:

 

#define DCSBIOS_IRQ_SERIAL

 

 

#include <AccelStepper.h>

#include "DcsBios.h"

#define FULLSTEP 4

 

 

 

#define motorPin1 3

#define motorPin2 4

#define motorPin3 5

#define motorPin4 6

 

// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with

//28BYJ-48

AccelStepper Motor1(FULLSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

 

 

 

void onVd20Change(unsigned int newValue) {

 

 

 

 

unsigned int newPosition = map (newValue ,0 , 65498, 0, 40960);

 

 

 

 

Motor1.moveTo(newPosition);

 

 

 

}

 

DcsBios::IntegerBuffer vd20Buffer(0x3200, 0xffff, 0, onVd20Change);

 

void setup() {

DcsBios::setup();

Motor1.setMaxSpeed (800);

 

Motor1.setAcceleration(800);

 

 

}

void loop() {

DcsBios::loop();

 

Motor1.run();

}

------------------------end of sketch-------------------------------

 

i m talking about the altimeter for the L-39, so i followed the developer guide and your advices to add a new module to DCS-bios with the starting adress "0x3200" for the moment i'm trying to master the programing part it s why i didn't add other instruments

 

the stepper that i use for experiments is the "28BYJ-48" it makes 2048 steps per revolution, and i added the argument for the km indication, the instrument it self is maked to show 20km so it s why i have 40960 as a max step value.

 

at the start of the simulation the stepper makes a little less than 20 revolutions because of the " Value From DCS : 65498, then 20 revolutions back when that value passes by 0 then it work as it should be ...

 

i m more than ready to share all the changes that i ve made, it's just that i added just one instrument " altimeter " for testing and mastering the beast at the present moment, and i'll add all the other instruments in the futur few day ( i m speaking only about the instruments not about the other controles for the moment ) then i ll have some thing relatively significant to share with great pleasure on GitHub

With respect

_________________

Kadda

_________________

My works

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

Link to comment
Share on other sites

the stepper that i use for experiments is the "28BYJ-48" it makes 2048 steps per revolution, and i added the argument for the km indication, the instrument it self is maked to show 20km so it s why i have 40960 as a max step value.

 

For 20 km of altitude, the in-game pointer does exactly one rotation (I am assuming you are talking about cockpit argument 52 -- you didn't link your DCS-BIOS modifications so I have to guess). That means you should use a max step value of 2048, so 1 revolution in the virtual cockpit = one revolution on your stepper. You should map(newValue , 0 , 65535, 0, 2048);

 

I don't know why the initial value you get from DCS-BIOS is 65498. That would correspond to an argument value of about 0.9994, so it's just a little to the left of the zero on the scale. It's either an internal rounding error within DCS or it may be the altimeter's way of indicating a negative altitude. While there is no terrain below sea level in DCS, if you are at 0 ft MSL you can get a negative altitude indication if the barometric pressure setting is slightly off.

Link to comment
Share on other sites

If I might make a suggestion regarding the motor you are using, before you go to much further you really should verify whether that motor will be fast enough to keep up to the cockpit altimeter when you are in a dive. From past experimenting I was unable to get that motor to turn fast enough.

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

Ian;3020921']For 20 km of altitude, the in-game pointer does exactly one rotation (I am assuming you are talking about cockpit argument 52 -- you didn't link your DCS-BIOS modifications so I have to guess). That means you should use a max step value of 2048, so 1 revolution in the virtual cockpit = one revolution on your stepper. You should map(newValue , 0 , 65535, 0, 2048);

 

I don't know why the initial value you get from DCS-BIOS is 65498. That would correspond to an argument value of about 0.9994, so it's just a little to the left of the zero on the scale. It's either an internal rounding error within DCS or it may be the altimeter's way of indicating a negative altitude. While there is no terrain below sea level in DCS, if you are at 0 ft MSL you can get a negative altitude indication if the barometric pressure setting is slightly off.

 

yes i m using the cockpit argument 52, in the instrument that i get from the simulator, the meters and km gauges are related mechanically to make and the shaft is related with the meters gauge ... so if i use the 53 arg witch is for meters and map that with 2048 it would be like a max step value that the motor can t go so i took the 52th argument and amplified his mouvement to simulate the 53th

 

 

the terrain " Batumi " that i use for my tests is 11m MSL

With respect

_________________

Kadda

_________________

My works

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

Link to comment
Share on other sites

  • Recently Browsing   0 members

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