Jump to content

DCS-BIOS over RS485


Hansolo

Recommended Posts

Alright I have been thinking about this post for a while so finally got around to it. I am certain it frustrates many that the DCS-BIOS over RS485 makes so many troubles. A small consolation is that I find equally frustrating since I cannot see what the problem is and it just works for me. This has driven me to write this post.

 

-----------------------------------------------------------------------------------------------------------

 

Disclaimer! Before progressing any further into DCS-BIOS over RS485 you should ask yourself what it is you want to achieve with your cockpit.

 

If you want just a single Arduino or few running DCS-BIOS you should consider if you really want to go through all the excitement of RS485 or if you ‘just’ want to go with USB connections. There is little point in over complicating your system if you don’t have to.

 

If you want to run multiple Arduinos and/or would like to get rid of some of the USB cable then DCS-BIOS over RS485 may be a solution for you.

 

-----------------------------------------------------------------------------------------------------------

 

The setup was done last night. Nothing fancy just an illustration on how I get it to work. I have deviated slightly from what I normally do but that is only to the consideration of how the Arduino’s are powered.

 

On the test setup:

• Both Arduino’s are power via USB.

• The Slave uses the onboard LED PIN13 as Master Caution light and A0 as CDU Power ON/OFF

 

These are the components I have been using for this test;

zsYsJDX.jpg

 

 

Arduino Mega (https://www.ebay.com/itm/MEGA-2560-R3-ATmega2560-16AU-CH340G-Develope-Board-W-Cable-for-Arduino/201383981895?epid=25022877442&hash=item2ee36bb347:g:J1EAAOSw0JpV5W9g&frcectupt=true)

 

Breakout board for Mega (https://www.ebay.com/itm/MEGA-2560-R3-Prototype-Screw-Terminal-Block-Shield-Board-Kit-For-Arduino/232393202659?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2060353.m1438.l2649)

 

Arduino Nano (https://www.ebay.com/itm/5PCS-USB-CH340G-Nano-V3-0-16M-5V-ATmega328P-Micro-Controller-Board-For-Arduino/262123434387?hash=item3d07c63193:g:IuEAAOSwJtJcExWk&frcectupt=true)

 

Breakout board for Nano (https://www.ebay.com/itm/Nano-Terminal-Adapter-for-the-Arduino-Nano-AVR-ATMEGA328P-AU-Module-Board-DIY/263082889276?hash=item3d40f6503c:g:TMUAAOSwQolbFi3g)

 

Prototype board https://www.ebay.com/itm/10X-DIY-Prototype-Paper-PCB-Universal-Experiment-Matrix-Circuit-Board-8-5x20cm-B/162839493171?hash=item25e9fd7a33:g:ZE0AAOSw2x1XLZ6O

 

MAX487 chips; https://www.mouser.dk/ProductDetail/700-MAX487CPA

 

8 pin sockets; https://www.ebay.com/itm/IC-Sockets-6-8-14-16-18-20-24-28-32-40-42-48-Pin-DIL-DIP-2-54mm-Socket-Holder/192636766911?hash=item2cda0bcabf:m:m457cJ_fIGlh-csj5pK5Dlw

 

In addition a soldering iron and wire is of cause needed. I also have a coil of hook up wire to make jumpers (https://www.sparkfun.com/products/8022).

 

First part involved soldering the pins to the Arduino Nano. I normally mount the pins in the Nano breakout board to keep them in place while soldering. I apply solder flux using a pen.

fxOYaAJ.jpg

 

 

The breakout board for the Arduino Mega isn’t strictly necessary and I only use it for testing new panels. It’s very much easier to test all the functions works properly before start soldering all the wires in. An additional advantage with the Mega breakout board is that the screw terminals ensure good contact whereas breadboards can sometimes be a little dodgy.

The Mega breakout board is mounted directly on top of the Mega

hPfV0FO.jpg

 

 

The 8 pin IC sockets are mounted with the marker in the same position

5z1896C.jpg

 

 

The marker on the IC sockets shall align with the marker on the MAX487 chips

And soldered on the rear side

9xtPXrW.jpg

 

 

One of the advantages with this prototype board is that it leaves a lot of soldering holes for each of the pins on the IS sockets.

Also for more advanced boards it is possible to use some of the strips as GND, 5VDC and 12VDC, which will make the power wiring for different components more neat.

Use jumper wire to short pins 2-3 on both IC sockets

WnU0Swg.jpg

 

7E7n3yU.jpg

 

 

Solder following wires on Master chip (colours are of cause optional and just to keep better track of what is connected to what);

Pin 2&3 (RE+DE) on IC socket - BLUE - Pin 2 on Mega

Pin 1 (RO) on IC Socket - GREEN - Pin 19 on Mega

Pin 4 (DI) on IC socket - YELLOW - Pin 18 on Mega

Pin 5 (GND) on IC socket - GREY - GND on Mega

Pin 8 (Vcc) on IC socket - PINK - 5V on Mega

 

NOTE!!! On some Arduino Mega's pins 18 & 19 have been mislabeled. The correct label for Pin18 is TX1 and for Pin19 is RX1. Please wire according to above;

Pin 1 (RO) on IC Socket - GREEN - Pin 19 on Mega

Pin 4 (DI) on IC socket - YELLOW - Pin 18 on Mega

 

UzyWril.jpg

 

Closeup of the wire connections between Master Mega and Master MAX487 chip

zK61F1E.jpg

 

 

Solder following wires on Slave chip;

Pin 2&3 (RE+DE) on IC socket - BLUE - Pin 2 on Nano

Pin 1 (RO) on IC Socket - GREEN - Pin RX0 on Nano

Pin 4 (DI) on IC socket - YELLOW - Pin TX0 on Nano

Pin 5 (GND) on IC socket - GREY - GND on Nano

Pin 8 (Vcc) on IC socket - PINK - 5V on Nano

xrF6Hvr.jpg

 

 

Interconnection between the two MAX487 chips

Pin 6 (A) on Master IC socket - YELLOW - Pin 6 (A) on Slave IC socket

Pin 7 (B) on Master IC socket - GREEN - Pin 7 (B) on Slave IC socket

Pin 5 (GND) on Master IC socket - GREY - Pin 5 (GND) on Slave IC socket

 

Added toggle switch on Nano GND and pin A0

 

Complete setup should look like this

rukZPJJ.jpg

 

 

Loaded following sketch on Mega Master

/*
 Tell DCS-BIOS this is a RS-485 Master.
 You will need to flash this to a Mega 2560.
*/
#define DCSBIOS_RS485_MASTER

/*
 Define where the TX_ENABLE signals are connected.
 You can connect up to three half-duplex RS-485 transceivers.
 
 Arduino Pin             RS-485 Transceiver Pin
 TXn ------------------- DI (driver input)
 RXn ------------------- RO (Receiver Output)
 UARTn_TXENABLE_PIN ---- /RE, DE (active low receiver enable, driver enable)
 
 If you have less than three transceivers connected, comment out the corresponding
 #define UARTn_TEXENABLE_PIN lines for receivers that are not present.
*/
#define UART1_TXENABLE_PIN 2
//#define UART2_TXENABLE_PIN 3
//#define UART3_TXENABLE_PIN 4

#include "DcsBios.h"

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

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

 

 

Loaded following sketch on Nano slave

/*
 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.
*/
#define DCSBIOS_RS485_SLAVE 126

/*
 The Arduino pin that is connected to the
 /RE and DE pins on the RS-485 transceiver.
*/
#define TXENABLE_PIN 2

#include "DcsBios.h"

/* paste code snippets from the reference documentation here */
DcsBios::Switch2Pos aapCdupwr("AAP_CDUPWR", A0);
DcsBios::LED masterCaution(0x1012, 0x0800, 13);

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

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

 

 

Test

As already stated both Arduinos ran on USB power.

Start SOCAT with the com port for the Mega Master, in my case COM9. Now I was be able to see communication when flipping the switch on the Nano, even without running DCS. This is what it looks like when SOCAT is running but DCS is not. Note this is an older test thus doesn't show the exact slave sketch running

 

Started DCS and and confirmed that the CDU Power switch flipped when activating the toggle switch. Activated Master Caution light and confirmed onboard LED was running.

 

Hope the images will be slightly helpful to get your DCS-BIOS over RS485 up and running.

 

Cheers

Hans


Edited by Hansolo
Added YT showing SOCAT, USB power highlited, mislabeling highlighted
Link to comment
Share on other sites

DCS-BIOS over RS485 - more info

 

This is going to be the second part of the DCS-BIOS over RS485 tutorial, focusing on getting beyond the initial post #1.

If you haven’t gotten communications to work at all please go back to post #1 and get the initial steps done.

 

Questions:

 

First things first. I have gotten a lot of questions via PM regarding this which I would like to address:

 

1. Despite the fact that the communication line A & B are using voltage to send the communication, A & B lines are *not transferring 5VDC for power consumers*. In this respect the Arduino slave, MAX487 communications chips etc are power consumers.

This means that Arduino’s and MAX487 chips needs to be powered in some way.

 

 

2. For each of the connections you need a MAX487 chip. That applied to the Master as well as the Slaves.

So if you have a setup with one Master and 4 Slaves unit you need a total of 5 pieces MAX487 chips.

 

3. You can probably use alternate RS485 communication chips. The reason I have used MAX487 is because Ian (Father of DCS-BIOS) advised used of these.

 

I believe Tekkx started using DS36276 chips from Texas Instruments (https://forums.eagle.ru/showpost.php?p=3229891&postcount=18).

 

As with many things in DCS and outside there are many ways to go about a task, not just a single solution.

 

*BUT! Remember to read the data sheet for your specific communications chip so that you ensure that it’s compatible and the pinout is the same! Sometimes the data sheet speaks of DIP/SO/ µMAX.

DIP means Dual Inline Package

 

SO or more correctly SOIC mean Small Outline Integrated Circuits

 

µMAX is a package smaller then SO but only used by MAX.

 

 

4. The Master Arduino can only handle the master communications sketch i.e. you cannot connect any switches, diode etc. to this board. This means that all the nice Input/Output on the Master boards are mostly lost. Check if your really need RS485 as per updated post #1.

 

 

5. The Arduino Mega must be used as Master as it has sufficient RX/TX ports. At least two sets of RX/TX are needed to run DCS-BIOS RS485 Master.

 

RX0/TX0 to communicate to the PC via USB,

RX1/TX1 to communicate with the Master MAX487 chip. The Arduino Due has same sets of communication lines but IIRCC the Due is not compatible with DCS-BIOS.

 

 

Last but not least I would kindly suggest to get questions out into a post instead of via PM. There are a lot of skilled people here that all can assist or give advise. We may all learn something for these questions.

 

 

Communication

 

When applying more than the simple setup as per post #1 you need to start thinking about how you want your specific setup which depends on how much you want to do.

1. You may want to run just a single Master with one or two communication lines OR you may also want to run multiple Masters, e.g. having a Master in center unit and one for each side consoles.

 

 

2. You may want to run the Slaves centralized so that one Arduino handles multiple panels OR you have an Arduino for each panel.

 

 

3. You may want to have a hub where more Slaves connect into, OR you may want to have that each board have an input and output connector.

 

 

A very good example of the latter is Blue73’s beautiful and cleaver work on the his modular design. If you haven’t visited his thread I kindly suggest you do so; https://forums.eagle.ru/showthread.php?t=219982

 

 

4. You don’t actually need to be able to disconnect the individual Slaves units, but it is good advice to make a system to do so.

 

One of the many benefits with DCS-BIOS is that you can remove a Slaves but will still be able to run your SIM pit on the remaining Slaves units and only loose the functionality of the one you removed.

 

I would like to caution removal of a Slave unit under power. I did in the beginning experience a few fried MAX487 chips when removing on power. It may not have been related to the power but I have made it a habit of removing power before making disconnects.

 

Connector wise there are a bunch of different options. Blue73 and my self are using DB9 connector. They are relatively cheap. Other use RJ45 connectors or MOLEX.

 

NOTE! Only rule I would adhere to is that the individual Slaves units connect into a female connector so that you remove the risk of having live pins exposed. It’s the same setup you see in wall plugs in your house installation. The live ends are in the wall using female connector, whereas the individual consumers use a male connector.

 

NOTE! Above should not be taken as the only combinations possible. There are many different way and you as a cockpit builder need to find what suits your design criteria best.

Make a sketch of how you want your layout to be in your system. It will make it easier to implement.

 

 

Power

 

CAUTION!!! Take care when selecting your wires and cables for your power supply. Even though its just 5VDC or 12VDC the power supply may be able to supply a lot of amperes.

 

I have an old PC power supply unit which is capable of delivering 36A @5VDC plus 20A @12VDC.

Here in DK we are running 400/230VAC 50Hz. Normal house lighting is driven by 230VAC fused by 10/13A on 1.5 sqmm wires.

The power supply mentioned above is capable of supplying 3 times amperage that at 5VDC and about 2 times the amperage at 12VDC.

 

NOTE! Make sure you sufficiently protect your wires from overcurrent which can lead to heat and subsequent fire. Last thing we want is having our houses burned to the ground because of our desire to build home cockpits.

Also ensure that you installation is adequately grounded to prevent the risk of electric shock. Not from the 5/12VDC but from the 230VAC that supplies them.

 

All the Arduino’s and communication chips need power (voltage) of some sort. Again there are many way of applying the power to your chips and Arduinos.

 

 

1. The Master would automatically be power by the USB but you may also apply an external power source. The Arduino’s have an internal voltage regulator which will lower the voltage from supply down to 5VDC which are used to drive the onboard electronics.

 

 

2. The Slaves needs to be powered in some way;

a. You can power them via the USB cable, provided they have one.

b. You can power them via the Vin and GND pins (recommended 7-12VDC). The onboard voltage regulator will lower the voltage to 5VDC needed for the onboard components.

c. You can power them directly onto the 5V (output) pin of the board. In this case you have to ensure that you don’t get any voltage spikes from your power supply as this would fry your board components.

 

 

3. The communications chips need to be powered in some way;

a. You can power them from the 5VDC regulated by the Arduino which they server as communicator for.

b. You can also supply them with 5VDC from and external power supply unit.

 

Note! To Ensure that all boards have the same reference point, you should interconnect your GND’s for all your 5VDC or 12VDC.

 

 

Inspiration or ideas

 

A few examples on different setups:

 

Blue73 has made a very skilled and clever example of a modular design with input and output connectors. The circuit is powered from a common 5VDC power supply directly connected to the 5VDC pin on Arduinos and MAX487.

 

As far as I understand Blue73 uses to Master’s each running two communication lines with about 20 Slaves units

 

LlDsLIVh.png

 

Mine runs a single Master and a single communication line. The initial idea was that I wanted to stress test the communication. I so far have about 23 Slaves running on that single line.

 

cnJVSvKh.png

 

In each side console I have a connection box where the individual panels connect into.

 

AuyJjOZh.png

 

 

 

Hope this was little bit of inspiration.

 

Many thanks for Blue73 for allowing me to show his design as well as sharing all his very clever work. Again I can only recommend to check out his work; https://forums.eagle.ru/showthread.php?t=219982

 

 

All the best

Hans


Edited by Hansolo
Added more information
Link to comment
Share on other sites

WOW, Hans!

 

This post perfectly illustrates the generosity and kindness of some members of this DCS community... well, specifically, yourself!

 

Thanks so much! I will give this my undivided consideration over the coming days. Also, a new set of Max487's arrived from a reliable supplier....

 

Mole

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

Thanks so much for posting this! I am in the early stages of building my first panel and I know this will be super helpful.

Intel i7-4770k @ 4.4ghz, 32gb ram, GTX 1080ti, Oculus Rift S

 

Advanced apologies if my post contains typos or missing letters. Many of my posts are typed on a laptop with an old keyboard that has a personality all its own.

Link to comment
Share on other sites

Tried it this morning Hans, with the results in the attached screenshot - this seems to be working just fine. change in the switch position is annunciated on the CMD screen with zero delay.

 

 

****EDIT**** is an LED supposed go on and off on the Nano or Mega? If so, it is not fully working for me. I connected the +v connection of an LED (with 200 ohm resistor in series) to the D13 pin on the nano and the other to the common GND, but that didn't work either

 

 

For info this was not running on the PC that the DSC game is on, not sure if that makes a difference?

 

You didn't mention how to power the Nanao so I fed +5v to the +5v pin and GND from a phone charger, and GND was connected between the four devices

 

 

Cheers

 

Les

75398651_RS485testusingHansSchematicandsketches.thumb.png.b5194b5975592acc58448fa60577c9ec.png


Edited by lesthegrngo
Link to comment
Share on other sites

Congratulations Les. Yoo are now running one Arduino Nano via RS485 :thumbup:

 

You didn't mention how to power the Nanao so I fed +5v to the +5v pin and GND from a phone charger, and GND was connected between the four devices

s

 

It wasn't highlited but I have done this now;

As already stated both Arduinos ran on USB power.

 

 

****EDIT**** is an LED supposed go on and off on the Nano or Mega? If so, it is not fully working for me. I connected the +v connection of an LED (with 200 ohm resistor in series) to the D13 pin on the nano and the other to the common GND, but that didn't work either

 

 

For info this was not running on the PC that the DSC game is on, not sure if that makes a difference?

 

First you do not need to connect a LED with resistor to PIN13. There is an onboard LED connected to PIN13 so you just have to monitor that one.

 

Secondly since your PC doesn't run DCS then the Nano don't receive any information whatsoever via RS485. The Arduino Mega Master doesn't receive any information from DCS because DCS isn't running (actually it's not even installed)

 

And since you loaded the Master Caution code unto the Nano, then it shall be the Nano onboard LED that shall blink when Master Caution lamp blinks when DCS is running (also unpaused).

 

Cheers

Hans

Link to comment
Share on other sites

Switched it to my DCS PC, and the switch interacts correctly with the game and the LED blinks in cohort with the master caution light.

 

Thanks Hans, I will follow up with my other issues on the original thread I started

 

Excellent. Mission accomplished sir. Now you have a base to start experimenting from. You know the RS485 is running so if your code doesn't do what you expect you can start commenting out segments of code until you get it working again, thereby isolating where the culprit is.

 

@molevitch, @agathon, @lesthegrngo, @DeadMeat & @Blue73 many thanks a lot for the kind words. I hope this is enough to get a hole through to DCS-BIOS over RS-485 done by @Ian.

 

Just remember that the write-up is not the all universal truth. It's just a simple setup to get it going and establish communication over RS485. Once you get more panels, more cable etc you may have to use termination resistors. I write 'may' as I haven't seen any issues excluding them in my pit setup. But that doesn't mean that another setup won't suffer without the termination resistors.

 

Also in the MAX487 datasheet a capacitor is mentioned. I have left this out here (as well as on all my other panels) simply because the power to the MAX487 comes from the adjacent Arduino which has a capacitor in the 5VDC line.

 

 

Have a great weekend.

 

Cheers

Hans

Link to comment
Share on other sites

  • 1 month later...

Question for Hans. This is a little bit over my level right now. But including the code is amazing! I had a question about using the max487 chip versus using an RS485 module like so.

 

https://www.amazon.com/Max485-Chip-RS-485-Module-Raspberry/dp/B00NIOLNAG/ref=sr_1_4?keywords=rs485&qid=1566267818&s=gateway&sr=8-4

 

Is that possible? Or just more expensive than using the max487 chip?

 

Great demonstration Hans.

Link to comment
Share on other sites

Question for Hans. This is a little bit over my level right now. But including the code is amazing! I had a question about using the max487 chip versus using an RS485 module like so.

 

https://www.amazon.com/Max485-Chip-RS-485-Module-Raspberry/dp/B00NIOLNAG/ref=sr_1_4?keywords=rs485&qid=1566267818&s=gateway&sr=8-4

 

Is that possible? Or just more expensive than using the max487 chip?

 

Great demonstration Hans.

 

Thanks SteenosMT,

 

Don't use the premade boards from Amazon or Ebay. I can't find it now but Ian advised against it since they all have termination resistors on them. Stay with the MAX-487 chips.

 

Cheers

Hans

Link to comment
Share on other sites

  • 2 months later...

Hi Hans,

 

After leaving it all alone for a few months, I came back to the RS485 Network conundrum with fresh eyes. After 1 or 2 hours of new soldering, I am proud to say that now I have one button working on a Nano slave!

 

Hurrah, (rubbing hands together), now the real work begins!

 

Mole

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

  • 4 weeks later...

DCSBIOS Network running, but slow (?)

 

Hi Hans,

 

So I now have 3 panels all working on the network. Each was tested as a standalone under serial irq, before adjusting the code for slavery.

 

I am running 9v 1a power into the network via vin. I am running a Nano for a Radio selector board (SPU-7), another Nano for a Freq Preset Dialler and a Mega which is for the ARK-9/15 for which you helped me write the Sketch.

 

The strange result I am getting is... the input response is slow, and varies a lot. For example, I turn a dial and it can take 10 seconds for the dial to change in DCS. Some panels are slower than others. And some switches respond immediately.

 

And then after a period of time the network just sort of..... stops.

 

Any opinions on what is causing this will be happily received.

 

Thanks,

 

Molevich

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

Network?

 

 

Sent from my iPhone using Tapatalk

 

This thread is about running DCS-BIOS over a RS485/Max487 Network... or am I sadly mistaken?

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

  • 3 months later...

You wrote:

In each side console I have a connection box where the individual panels connect into.... There you draw 5 different lines. But the other image before have only 4 lines.

I don't really understand the difference.

But great explained!

my tutorial for dcs-bios, multimonitorsetup with a JF-17

https://github.com/shadowframe/jf17_multimonitor

 

discord shadowframe#7916

Link to comment
Share on other sites

  • Recently Browsing   0 members

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