Jump to content

[DCS-BIOS] EGI - problem with stepper motors


Patriot

Recommended Posts

I made engine gauges instruments with stepper motors (vid29) and connect with dcs-bios.

But faced with a problem: when the aircraft is on the ground, then the motors they live their lives. This is clearly seen in the video at 00:50 seconds. I saw a similar problem from someone on the forum, but can't find this topic. What could be the problem? The script for the arduino took here on the forum:

#define DCSBIOS_RS485_SLAVE 67
#define TXENABLE_PIN 2

#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();
     }
   }
};


//                                                        maxSteps  maxSpeed acceleration
struct StepperConfig apuRpmStepperConfig = {(227 * 2), 300, 1000};
AccelStepper apuRpmStepper(AccelStepper::FULL4WIRE, 9, 12, 8, 3);
Vid29Stepper apuRpm(0x10be, apuRpmStepper, apuRpmStepperConfig, [](unsigned int newValue) -> unsigned int {
 return map(newValue, 0, 65535, 0, apuRpmStepperConfig.maxSteps);
});

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

Patriot how many Arduino's do you use for your engine cluster? If you use just one then that may be the problem. I seem to recall Warhog talking about the fact that a Nano/Uno isn't fast enough to run all 12 gauges.

 

p.s. very nice engine cluster you have made by the way :-)

 

Cheers

 

Hans


Edited by Hansolo
Link to comment
Share on other sites

I think Hans hit the nail on the head. The fellow who created the Acelstepper Library warned me about trying to run more than a couple of steppers from one Arduino board. They just don't have the processing power. Nowhere in my cockpit do I run more than 2 motors from one board. Because the cost of Arduino boards are very inexpensive I decided to do one motor, one board wherever I could. The EMI is my only exception.

 

If your intent on running the entire EMI with one board, consider the more powerful 32bit ARM Cortex boards. They should be able to run 12 motors without breaking a sweat. I see Arduino has a board called the TIAN. Runs at 530 MHz. Probably overkill but it sure is impressive. I purchased a ChipKit Uno32 on the advise of the Acelstepper Author who was adiment that this board could do the job. Unfortunately I cannot vouch for its ability to run the EMI as I haven't done any testing yet. However, Failing that I will do the one board/one motor thing as I’ve done everywhere else in the cockpit.

 

Whatever direction you choose, please post your results as I am sure others will benifit from your testing.

 

Good luck.


Edited by Warhog

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

Thank you all for your help, but the problem persists if one motor is connected to one Arduino.

 

 

I use 3 Arduino to 12 motors. Today, almost found the problem. If 3 Arduino connected to each other, then from somewhere there is noise in the rs485 bus. If at least any one of Arduino disable, then everything is okay. The reason for this behavior are not yet understood. Schematically sketched how it was connected to the problem, and how it reconnected now.

 

Connected with noise in bus:

 

z44oa-t2TaCCFuFmoK2vXw.png

 

Reconnected normal:

 

CrqbY5wtQd6-TJsp3x9sQw.png

 

And photo:

 

gpq9cX5fQya7R_yE8dNvPQ.png

 

And how work now:

 

lhbkAwPKrlw

 

So, one Arduino can control minimum 4 motors :)

 

p.s. very nice engine cluster you have made by the way :-)

Thanks! :)

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

One quick thought - I noted problems with my setup if the prams were not matching what my motors were capable of - maybe try reducing maxSpeed/acceleration?

 

struct StepperConfig stepperConfig =

{

400, // maxSteps

100, // maxSpeed

100 // acceleration

};

Link to comment
Share on other sites

  • Recently Browsing   0 members

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