Inverted Posted July 7, 2017 Posted July 7, 2017 (edited) A DCS BIOS noob here. Has anyone used automotive gauges with DCS BIOS? As they are very cheap from China and would seem to make building a sim pit quicker and cheaper. So has anyone done this before, if so, how did you do it? Edited July 7, 2017 by Inverted
draken152 Posted July 7, 2017 Posted July 7, 2017 What we are missing is one general thread about DCS-Bios and Instruments. Some of guys here have already build instruments using DCS-BIOS and stepper motors or servos, but it is hard to collect information’s because there are usually in different builds-threads. Can someone write short guide ,,How to“ where will be described used hardware, code examples and so on... It will be for sure help to DCS community... [sIGPIC][/sIGPIC] Building FW190D pit ,,To Dora with love" http://forums.eagle.ru/showthread.php?t=132743
WhoMadeWho Posted July 8, 2017 Posted July 8, 2017 I'm using many automotive stepper motors for my A-10C cockpit build. I've had very good luck with the VID29 / X.25.168 motors. These are/were commonly used in GM vehicles. They are available on ebay and also Amazon. Here's a link - https://www.amazon.com/dp/B00LQ9AQOY/_encoding=UTF8?coliid=I3GJY1C1ABFDFS&colid=25UHEBSM29ZLZ As for code - (not my own) I've had great luck using the below reference. Just use the DCS-BIOS documentation to find the correct hex value for the instrument you want to slave to the stepper motor. I agree more docs are needed and I believe this is in work. Folks on this forum have been a big resource for me. #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 = { 475, // 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 apu(0x10be, 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(); }
draken152 Posted July 8, 2017 Posted July 8, 2017 Can you please also post your hardware - ardunio type, are motors connected directly or via driver board, how many of motors are connected to one ardunio and so on.... [sIGPIC][/sIGPIC] Building FW190D pit ,,To Dora with love" http://forums.eagle.ru/showthread.php?t=132743
WhoMadeWho Posted July 9, 2017 Posted July 9, 2017 Can you please also post your hardware - ardunio type, are motors connected directly or via driver board, how many of motors are connected to one ardunio and so on.... Sure. I'm using Arduino 'Mini' boards. These are very cheap to obtain from China on eBay (like $3 a piece). You will need to solder the leads on the boards, but this is pretty easy to do if you have some soldering experience. Out of the ~50 Arduino mini boards I've purchased, I've only had ONE bad board. Pretty good. Link to eBay seller I've had good luck with http://www.ebay.com/itm/5Pcs-MINI-USB-CH340G-Nano-V3-0-16M-5V-ATmega328P-Micro-Controller-Board-Arduino-/361919929243?hash=item54441bdb9b I'm also using an Adafruit H-Bridge to drive the motors. Link to the H-bridge https://www.adafruit.com/product/2448 Here are a few photos of my hardware - hopefully you can see the wiring OK. This will work with the code I posted above. I hope this is helpful to you and others.
Hansolo Posted July 10, 2017 Posted July 10, 2017 Very nice writeup WhoMadeWho :thumbup: @Inverted & @Draken152 you may also use an EasyDriver Shield instead; http://www.ebay.com/itm/A3967-EasyDriver-Shield-Stepper-Motor-Driver-Module-V44-For-Arduino-3D-Printer-/400522271040?epid=581015416&hash=item5d40fcd940:g:fc0AAOSwq1JZLplm In that case you need to use this code by Warhog/Ian #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 = { 120, // maxSteps 1200, // maxSpeed 10000 // acceleration }; // define AccelStepper instance [b]AccelStepper stepper(AccelStepper::DRIVER, 11, 10);[/b] // 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 vvi(0x10a0, 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(); } It is almost identical to WhoMadeWho's code except for the highlighted part where you define which two pins are used for the the Step and Direction. Advantage with this is that it only uses 2 pins from the Arduino. Just make sure you have the correct 'AccelStepper.h' version as otherwise you get a compiling error. WhoMadeWho was kind enought to lead me to the correct one; http://www.airspayce.com/mikem/arduino/AccelStepper/index.html Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album
draken152 Posted July 10, 2017 Posted July 10, 2017 Thx guys you helps me a lot:thumbup:... Now I must buy proper hardware, and start with creating FW 190D module for DCS BIOS... [sIGPIC][/sIGPIC] Building FW190D pit ,,To Dora with love" http://forums.eagle.ru/showthread.php?t=132743
ESA_Falke Posted December 4, 2017 Posted December 4, 2017 Hi Guys Is it possible to use a code with the pololu driver DRV8834? Thx
WhoMadeWho Posted February 21, 2018 Posted February 21, 2018 You'll want separate instances of hardware for running that many steppers.! I'm running 1 Arduino + h-bridge for each stepper. So for my engine panel, that's twelve (12) Arduinos and (12) h-bridges. Is there a better way? Probably with a more powerful Arduino + an externally powered motor driver. I've found separate instances work best for me.
Pavespawn Posted February 21, 2018 Posted February 21, 2018 I assume this setup would be supported on a RS485 bus to allow for this many nanos?
moken Posted February 22, 2018 Posted February 22, 2018 Hi, i don't understand how to connect from arduino to easydriver shield, I want to learn from yours, I found the example page in example 4 for multiple stepper motor , if it can helpful for you, please let me know, I will follw your step. Thank you http://www.schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html
Recommended Posts