Jump to content

Stepper motor drivers for use with Arduino and DCS Bios


lesthegrngo

Recommended Posts

5 часов назад, outbaxx сказал:


Шаги на оборот для этих степперов составляют 720 полных шагов, с микрошагом 1/8 у вас есть 5760 шагов на оборот.

Максимальный ход шагового двигателя это что? 320 градусов?

320/360*5760->5120 шагов?
Попробуйте установить stepperconfig.maxSteps на 5120 плюс-минус.

Thanks guys for the clarification. It seems that I figured it out with the arrow. According to this program, the arrow moves evenly (up to 250 it works correctly). but since after 300, the divisions go by 100 on the device, the readings do not correspond to those on the screen. How to prescribe so that after 250 it goes to hundreds?

MPH.png

Link to comment
Share on other sites

2 часа назад, outbaxx сказал:

Есть ли какая-либо другая скорость полета в контрольной ссылке?
На том, что у вас сейчас, написано airspeedRPM… есть ли другое?
Я думаю, вам нужно найти тот, который возвращает 0-65535, тогда игла должна работать правильно.

unfortunately no other

1363121497_DesktopScreenshot2019_08_08-12_32_01_09.png.0eee952c0f5a42dd5bcb4899542ccb1d.png

Link to comment
Share on other sites

27 минут назад, outbaxx сказал:

Я имею в виду, что в контрольной ссылке в dcsBios тот, который у вас есть, говорит airspeedMPH… Может
быть один, который называется airspeedNeedle или аналогичный и возвращает значения 0-65535.

there is this one

Screenshot_4.jpg

Link to comment
Share on other sites

30 минут назад, outbaxx сказал:

Я бы попробовал использовать его вместо этого, надеюсь, стрелка будет двигаться, как в симуляторе с этим.

I tried with these parameters, but it turns out that the arrow shows less than on the screen

 

here is my code

#define DCSBIOS_IRQ_SERIAL

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

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


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

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


struct StepperConfig stepperConfig = {
  5760,  // maxSteps
  1000, // maxSpeed
  1000 // acceleration
  };


AccelStepper stepper(AccelStepper::DRIVER, 11, 10);

Vid29Stepper airspeedNeedleBuffer(0x5030, stepper, stepperConfig, [](unsigned int newValue) -> unsigned int {

  return map(newValue, 0, 65535, 0, stepperConfig.maxSteps);
}); 


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

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

Link to comment
Share on other sites

I tried with these parameters, but it turns out that the arrow shows less than on the screen
 
here is my code
#define DCSBIOS_IRQ_SERIAL
#include
#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()           stepper.setCurrentPosition(0);
          initState = 2;
          stepper.moveTo(stepperConfig.maxSteps);
        }
      }
      if (initState == 2) { // running normally
        if (hasUpdatedData()) {
          unsigned int newPosition = map_function(getData());
          newPosition = constrain(newPosition, 0, stepperConfig.maxSteps);
          stepper.moveTo(newPosition);
        }
        stepper.run();
      }
    }
};

struct StepperConfig stepperConfig = {
  5760,  // maxSteps
  1000, // maxSpeed
  1000 // acceleration
  };

AccelStepper stepper(AccelStepper::DRIVER, 11, 10);
Vid29Stepper airspeedNeedleBuffer(0x5030, stepper, stepperConfig, [](unsigned int newValue) -> unsigned int {
  return map(newValue, 0, 65535, 0, stepperConfig.maxSteps);
}); 

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

What numbers does it return in the control reference?
Link to comment
Share on other sites

Do you guys remember when I said this:

On 5/29/2022 at 1:01 PM, No1sonuk said:

I gave up on the P-51 airspeed indicator. 
There's a bug which means the number output doesn't relate directly to the angle of the needle.
This means that if your gauge face is marked as in the game, the reading doesn't match your airspeed.

I wasn't kidding about the bug.
I asked the guys that maintain the FlightPanels fork of DCS-BIOS, and they couldn't figure out why the gauge reads differently.

  • Like 1
Link to comment
Share on other sites

Years ago I found a strange behavior with the MiG-21's radar altimeter. The values were not linear scaleable. The problem could be solved by using the "multiMap" library for Arduino. Maybe that you are facing similar issues.

Below is that part of my code:

Spoiler
...
    String raltNd(raltNdValue); 

    int raltNdTemp = (raltNd.toInt() * 1000 / 65535); // conversion factor

/*    RadAlt needle values must be mapped according to DCS internal RadAlt scale
      see document "mainpanel_init" --> RADIO_ALTIMETER_indicator
      note: the in[] array should have increasing values
      out[] holds the values wanted in m  */
 
      int in[]  = { 0.0, 41, 70, 103, 130, 181, 210, 245, 260, 298, 325, 472, 580, 680, 732, 807, 867, 909, 1000 };
      int out[] = { 0.0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 250, 300, 400, 500, 600, 1000 };
      int ralt = multiMap(raltNdTemp, in, out, 19); // for multiMap function see declaration part on top of this sheet


...

 

 

Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

31.05.2022 в 18:07, outbaxx сказал:

Вы можете попытаться настроить maxSteps на меньшее число или изменить 0,65535 на 0,45000.
Не меняйте оба 🙂

Guys tell me how to make the backlight of the scale in the device? I can’t find the item for which the backlight is responsible (what to look for?), and which pins to connect the LEDs to?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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