Jump to content

Recommended Posts

Posted

I'm in the midst of building my A10-C simpit and I'm going to use arduino and DCS bios for a few of the panels, but I have zero experience with either one. I have watched a few videos and read through some documentation but I'm pretty lost and I have yet to find anything that takes a newbie like myself from step one to a finished and working panel. If anyone knows of anything like this, PLEASE let me know as I'd love to check it out. I'm a visual learner and typically need to watch someone do it from beginning to end before I really understand and can do it on my own. Or, if you can write a quick how to, I'll take that as well and do my best to work thru it. I have DCS Bios downloaded and installed as well as the Arduino IDE software. The first panel I'm going to use an arduino and DCS Bios with is the Landing gear Panel. I am using an Arduino Uno for the panel. I have the panel completely built and now I need to know how to wire the landing gear level (micro switches, one for gear up and one for gear down) to the arduino, how to wire 2 LEDs in the gear lever knob for when the gear is in transit, the three gear indicator lights for when the gear is down and locked/safe, the flap position indicator(Servo with 3 wires +/-/Signal) and of course all of the wording/coding for the arduino. The anti-skid and landing light toggle switches are just going to be wired to a GP WIZ40 that I already have and installed. Any help or pointing me in the right direction would be greatly appreciated! 

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted (edited)

At what point are you stuck? do you have the software installed? do you have export.lua talking to DCS BIOS? do you have a test device programmed with "Master caution" example? 

Specifically on LDG Panel I described my efforts here:
https://forums.eagle.ru/topic/130540-grass-pit-quotridgewoodquot/?do=findComment&comment=4505679
 

I have PCBs that holds arduino nano made specifically  for LDG device . I can spare one.

 

 

my Arduino Code for slave DCS-BIOS device:
 



/*
  The following #define tells DCS-BIOS that this is a RS-485 slave device.
  It also sets the address of this slave device. The slave address should be
  between 1 and 126 and must be unique among all devices on the same bus.
*/

//int skidTripValue

#define DCSBIOS_RS485_SLAVE 9
#define TXENABLE_PIN 2
#include <Servo.h>
#include "DcsBios.h"


/* paste code snippets from the reference documentation here */
//Anti-Skid for Overcurrent trip of Circuit breaker
DcsBios::Switch2Pos antiSkidSwitch("ANTI_SKID_SWITCH", A0);
  
void onAntiSkidSwitchChange(unsigned int skidTripValue) {
    if (skidTripValue==0) {        
    digitalWrite(8, HIGH);
   }
   else if (skidTripValue==1){
    digitalWrite(8, LOW);
   }
}
DcsBios::IntegerBuffer antiSkidSwitchBuffer(0x1110, 0x0080, 7, onAntiSkidSwitchChange);
DcsBios::ServoOutput flapPos(0x10a0,3, 544, 2400);

//Landing gear lever
DcsBios::Switch2Pos gearLever("GEAR_LEVER", 5, true);

DcsBios::LED handleGearWarning(0x1026, 0x4000, 9);

//Landing gear SAFE
DcsBios::LED gearRSafe(0x1026, 0x2000, 10);
DcsBios::LED gearNSafe(0x1026, 0x0800, 11);
DcsBios::LED gearLSafe(0x1026, 0x1000, 12);

//Laning lights TAXI/OFF/LAND
DcsBios::Switch3Pos landingLights("LANDING_LIGHTS", A4, A5);

//Downlock override
DcsBios::LED downlockOverride(0x1110, 0x0010, 13);

void setup() {

  DcsBios::setup();
  pinMode(8, OUTPUT);
}
void loop() {
  DcsBios::loop();

 

20210509_190157.jpg

Edited by agrasyuk

Anton.

 

My pit build thread .

Simple and cheap UFC project

Posted (edited)

Thanks so much for the response agrasyukFirst of all, awesome simpit!! You do awesome work.

 

I've installed DCS Bios and Arduino IDE, that's about as far as I've gotten. I know the Uno is connected and communicating with dcs bios. I just don't know where to go in Arduino IDE to write the script and how exactly to write the script. Second, I also don't know where to put all the wires in the arduino for the gear handle micro switches, gear indicator light wires (Pos, Neg, and Signal) and the pos/neg of the red LEDs in my gear handle knob, and the flap indicator wires (pos,neg,signal).

 

I'm not connecting anything else from the landing gear lever panel to the arduino uno. Just the Landing gear lever microswitches, the red LEDs that are in the gear handle knob, the gear indicator SAFE lights and the flap position indicator. 

 

I found the master caution example from the dcs bios library. Not sure what to do with it though, but if you want to start there, I'm all ears.

Edited by Kenpilot

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted (edited)

Welcome to the rabbit hole! Have you found the wiki?

 

https://github.com/DCSFlightpanels/dcs-bios/blob/master/Scripts/DCS-BIOS/doc/userguide.adoc

 

I recommend to start there, wether you are using the hub version or the flightpanel-fork. Installation is different for these; usage is the same. As agrasyuk said: Try the master caution example script (arduino ide: file menu, examples, dcs-bios) and work your way up. For the leds dont forget resistors! The uno may not take damage using leds without resistors, but the leds will burn.

 

Edit: Heres the hub-version wiki:

 

https://dcs-bios.readthedocs.io/en/latest/hardware.html

Edited by crash test pilot
Posted
1 minute ago, crash test pilot said:

Welcome to the rabbit hole! Have you found the wiki?

 

https://github.com/DCSFlightpanels/dcs-bios/blob/master/Scripts/DCS-BIOS/doc/userguide.adoc

 

I recommend to start there, wether you are using the hub version or the flightpanel-fork. Installation is different for these; usage is the same. As agrasyuk said: Try the master caution example script (arduino ide: file menu, examples, dcs-bios) and work your way up. For the leds dont forget resistors! The uno may not take damage using leds without resistors, but the leds will burn.

Ha, thanks! I have found and read as much as I could from the userguide. Unfortunately I learn from watching, so reading only gets me so far. I'm a visual learner. I'm trying to find videos but I haven't really found any that are useful for a beginner yet. I'll play around with the master caution script and see if I can learn anything from it. Thanks for the heads up on the resistor!

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted

Yes... By reading it can be a bit overwhelming at first.  I got myself a cheap arduino learning kit and had a good time trying and learning. It also gives the benefit of having resistors, leds, pushbuttons, pots and more stuff for testing bigger constructions. I would recommend one with a mega2560, because if you want to build a rs-485 network (great for using multiple arduinos on one usb-port) you will need one for the master-role. The time i started, i wanted just a landing gear lever - now i have a complete cockpit. Beware! Highly addictive! Have fun...

Posted (edited)
1 hour ago, Kenpilot said:

I've installed DCS Bios and Arduino IDE, that's about as far as I've gotten. I just don't know where to go in Arduino IDE to write the script and how exactly to write the script.

I found the master caution example from the dcs bios library. 

 

 crash test pilot specified how to load the example into the Arduino IDE. that example demonstrates how input and output happens. I assume you know how to load Arduino sketches into the device. 

 

Quote

I know the Uno is connected and communicating with dcs bios.

How did you confirm? can you get to this page? 
(at the moment my master device is unplugged hence the "missing")

image.png

Quote

Second, I also don't know where to put all the wires in the arduino for the gear handle micro switches, gear indicator light wires (Pos, Neg, and Signal) and the pos/neg of the red LEDs in my gear handle knob, and the flap indicator wires (pos,neg,signal).

 

the code itself specifies the pins you attaching the wires to. the Master Caution example demonstrates the pin assignment:

/* Declare a Master Caution Reset button on pin 10 */
DcsBios::Switch2Pos masterCautionBtn("UFC_MASTER_CAUTION", 10);
/* Make the LED connected to pin 13 into a Master Caution Light */
DcsBios::LED mcLed(0x1012, 0x0800, 13);


Uno pinout:
Arduino Uno Tutorial [Pinout]

Hint: the built in LED is on pin13 (on the Nano boards, on the Uno it might be different, i don't remember) so you don't even need a led. just a pushbutton to ground the input 10.

Hint: DCS BIOS has a built in guide:

image.png

 

 

In the control reference you will find all the entities exposed to DCS-BIOS for particular aircraft.
basically you just cut and paste all the elements you want to use on the particular device and bam, it's all working. 
image.png





yes. it can be overwhelming at first. 
Good luck!

 

Edited by agrasyuk

Anton.

 

My pit build thread .

Simple and cheap UFC project

Posted

Thanks so much guys, I GREATLY appreciate you guys taking the time to help me out. I can get to the DCS BIOS HUB page yes, and that's where I saw the uno is on COMM3 and is connected. I do know how to upload a sketch on to the uno as well. I tried the master caution sketch last night but got an error message and had to call it a night. I'm going to try it again later today and see if I can't figure out what I did wrong. If I still can't get it to work and get another error message I'll post it and see if you guys can help me figure it out. Thanks again!!

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted (edited)

This is the error message I'm getting when trying to upload the sketch on to the uno. "


An error occurred while uploading the sketch
avrdude: ser_open(): can't open device "\\.\COM3": Access is denied.

 

And here is the sketch:

 

/*
  Tell DCS-BIOS to use a serial connection and use interrupt-driven
  communication. The main program will be interrupted to prioritize
  processing incoming data.
  
  This should work on any Arduino that has an ATMega328 controller
  (Uno, Pro Mini, many others).
 */
#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"

/* paste code snippets from the reference documentation here */
DcsBios::LED masterCaution(0x1012, 0x0800, 13);
DcsBios::Switch2Pos ufcMasterCaution("UFC_MASTER_CAUTION", 10);
void setup() {
  DcsBios::setup();
}

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

 

Edited by Kenpilot

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted

Are you using the dcs-bios hub version? If so, it will occupy the com port, making it impossible to write code to the arduino via the ide. Quit the dcs-bios hub ( or use the disconnect option) and you should be good to go.

Posted

I was. I'll close it out and try again tomorrow. Thanks!! 

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted

I made sure DCS BIOS Hub wasn't open and tried to upload the sketch on to the uno and this is the new message I'm getting now:

 

avrdude: ser_open(): can't open device "\\.\COM3": The system cannot find the file specified.

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted

Check it's not on a different com port.
I have had at least one instance where it used a different com port when in programming mode.

Also, for future reference, avoid using pins D0 and D1 unless you have to, and if you do, make sure they're either not connected when you try to program the board, or are on "pull-down" switches that are in the OFF position.
This is because those two lines are the serial RX0 and TX0 that are used for programming - the pin numbers may vary with other devices, but avoid RX0 and TX0 if you can.

Posted
29 minutes ago, No1sonuk said:

Check it's not on a different com port.
I have had at least one instance where it used a different com port when in programming mode.

Also, for future reference, avoid using pins D0 and D1 unless you have to, and if you do, make sure they're either not connected when you try to program the board, or are on "pull-down" switches that are in the OFF position.
This is because those two lines are the serial RX0 and TX0 that are used for programming - the pin numbers may vary with other devices, but avoid RX0 and TX0 if you can.

Copy all, thanks! I'll Check the comm ports.

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted (edited)

When I go in to TOOLS>Port it says "COMM3 Arduino Uno". At the bottom right corner it says Arduino Uno on COM3. In my Device Manager for the PC it says COM3 Arduino Uno. What am I doing wrong? It still gives me the same error message.

 

Disregard. I tried changing USB ports and it worked! I'm not sure which of my USB ports are USB 2.0 or 3.0, but maybe it was one of the 3.0s and it didn't like it?

Edited by Kenpilot
  • Like 1

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted (edited)

ok, now that I got the master caution sketch to work, What should the Flap position indicator sketch look like? Do I use the same format as the master caution sketch, just delete the commands for the master caution and copy and paste the commands for the flap position indicator and servo motor from the DCS Bios control reference? Also, in the servo motor command line, it has PIN, 544, 2400 RED. I know what to replace the PIN with, but do I keep the 544 and 2400 or what do I put in their place? Thanks! 

Edited by Kenpilot

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted

You can use as many dcs-bios commands in one scetch as you have pins available on your arduino. For the servo: it gets position info via pwm - pulse width modulation. Means in this case: A pulse with a length of 2400 ms for minus 90 degrees from center (the up position) and a lenght of 544 ms for plus 90 degrees (the down position). You have to try how to make it fit for your needs, as the flap indicator turns only 90 degrees in the real aircraft. My servo is mounted with the gear wheel up and the needle directly attached to it (no gears) and my setting is:

DcsBios::ServoOutput flapPos(hexnumber, pin, 2400, 1472);

 

servo.jpg

 

 

Do not let this pic fool you - you can set the servo to -90 degree and then stick the pointer pointing to the right - it will turn clockwise from right to left.

Posted (edited)

Ok, I think I've got the idea about the 544 and 2400, but that doesn't help my sketch that won't upload due to the error:

" Flap_Position_Indicator:18:10: error: 'ServoOutput' in namespace 'DcsBios' does not name a type
 DcsBios::ServoOutput flapPos(0x10a0,9, 544, 2400);
          ^~~~~~~~~~~
exit status 1
'ServoOutput' in namespace 'DcsBios' does not name a type

 

What is wrong with the sketch? Any chance you could write what it's supposed to look like so I can compare them and see what is wrong with mine? All I did was take the Master Caution example sketch, delete what I had copied and pasted from the DCS BIOS control reference for the master caution sketch, and copy and paste the Flap Position Indicator language from the DCS BIOS control  reference and it's giving me the above error message when I try to upload it. 

 

This is the sketch for the flap position indicator:

/*
  Tell DCS-BIOS to use a serial connection and use interrupt-driven
  communication. The main program will be interrupted to prioritize
  processing incoming data.

  This should work on any Arduino that has an ATMega328 controller
  (Uno, Pro Mini, many others).
*/
#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"

/* paste code snippets from the reference documentation here */
void onFlapPosChange(unsigned int newValue) {
    /* your code here */
}
DcsBios::IntegerBuffer flapPosBuffer(0x10a0, 0xffff, 0, onFlapPosChange);
DcsBios::ServoOutput flapPos(0x10a0,9, 544, 2400);
void setup() {
  DcsBios::setup();
}

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

Edited by Kenpilot

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted (edited)

Ok, here is my landing gear panel scetch, but beware: it is a slave scetch for a rs-485 network. Both lines beginning with #define should look different in your script. Maybe you forgot to include servo.h?

 

 

 

 

Edit: when i comment out the servo.h i get your error message so this is most likely missing in your script...

 

f1.ino

 

Edit 2: ah, just saw your edit. yes, you need to #include "Servo.h"

 

Edit 3: The servooutput line needs to go where /*your code here*/ stands.

Edited by crash test pilot
Posted

Ok, I put that line in there, now I'm getting this message:

 

Flap_Position_Indicator:12:10: error: #include expects "FILENAME" or <FILENAME>
 #include "Servo.h
          ^~~~~~~~
exit status 1
#include expects "FILENAME" or <FILENAME>

I forgot a " at the end of the line, but Now I'm getting this message:

Flap_Position_Indicator:18:10: error: 'ServoOutput' in namespace 'DcsBios' does not name a type
 DcsBios::ServoOutput flapPos(0x10a0,9, 544,1472);
          ^~~~~~~~~~~
exit status 1
'ServoOutput' in namespace 'DcsBios' does not name a type

 

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted

Ok, I'm getting really confused now. Here is my sketch:

 

/*
  Tell DCS-BIOS to use a serial connection and use interrupt-driven
  communication. The main program will be interrupted to prioritize
  processing incoming data.

  This should work on any Arduino that has an ATMega328 controller
  (Uno, Pro Mini, many others).
*/
#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"
#include "Servo.h"
/* paste code snippets from the reference documentation here */
    /* your code here */

DcsBios::IntegerBuffer flapPosBuffer(0x10a0, 0xffff, 0, onFlapPosChange);
DcsBios::ServoOutput flapPos(0x10a0,9, 544,1472);
void setup() {
  DcsBios::setup();
}

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

 

 

I'm getitng this message now:

 

Flap_Position_Indicator:16:57: error: 'onFlapPosChange' was not declared in this scope
 DcsBios::IntegerBuffer flapPosBuffer(0x10a0, 0xffff, 0, onFlapPosChange);
                                                         ^~~~~~~~~~~~~~~
Flap_Position_Indicator:17:10: error: 'ServoOutput' in namespace 'DcsBios' does not name a type
 DcsBios::ServoOutput flapPos(0x10a0,9, 544,1472);
          ^~~~~~~~~~~
exit status 1
'onFlapPosChange' was not declared in this scope

 

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted (edited)

The line DcsBios::Integerbuffer flapPosBuffer(going-on-and-on); was part of the display void (think of a void as a sub program run within the main program) so you need to delete that too.

 

Edit:

minimal code should look like this:

 

#define DCSBIOS_DEFAULT_SERIAL

#include "Servo.h"
#include "DcsBios.h"

DcsBios::ServoOutput flapPos(0x10a0, 9, 2400, 1472);

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

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

 

Edited by crash test pilot
Posted

awesome, got it to upload, but nothing is happening in DCS. I have COMM3 connected in DCS BIOS, I have gnd connected to gnd, I have the positive wire from the servo going to the 5v pwr pin and the orange signal pin connected to pin 9 on the uno. I change the flaps and the indicator in my panel isn't moving at all. I tried 0-10 and 20 flap settings, doesn't move. It moves in the game, but not on my panel indicator. 

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

  • Recently Browsing   0 members

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