markjhall Posted February 24, 2020 Share Posted February 24, 2020 I have several panels with servos, toggles, rotary encoders & LEDs running DCS-BIOS using Arduino NANOs but I cannot get any of it working with the same sketches on a MEGA 2560 even though the code uploads and DCS-BIOS can connect to the board. I’m starting to wonder if the MEGA can only be used e.g. as a master for RS-485 comes but not physical I/O. I can’t find this stated explicitly. I’ve tried a genuine MEGA and two different clones. I have the latest Arduino IDE and DCS-BIOS. It would be great to have a list of which Arduinos will do what with DCS-BIOS. If I get good info I’ll make a YouTube video to share the info... Link to comment Share on other sites More sharing options...
Jself Posted February 24, 2020 Share Posted February 24, 2020 Not sure about DCS-BIOS but I know the sketches that use the joystick.h library will only work on the pro micro or Leonardo. Link to comment Share on other sites More sharing options...
Hansolo Posted February 24, 2020 Share Posted February 24, 2020 Hi markjhall I use Nano's and Mega 2560 as slaves depending on different panels. As far as I remember I have following running of Mega 2560; IFF via RS485 UHF AN/ARC-164 via RS485 2x VHF AN/ARC-186 via RS485 TACAN via RS485 EWMU/CMSP in trial over USB Rest are Nano's over RS-485. Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
crash test pilot Posted February 24, 2020 Share Posted February 24, 2020 I have several megas running as slaves. The master can only be a mega, slaves should work with all arduinos. Link to comment Share on other sites More sharing options...
markjhall Posted February 26, 2020 Author Share Posted February 26, 2020 Thank for the replies very helpful. I see the MEGA often used with DCS-BIOS as a master with NANO slave(s) over RS-485: PC---(USB)---MEGA---(RS-485)---NANO(s)---LEDs, switches etc Putting the RS-485 aside, I always had success with NANOs over USB. PC---(USB)---NANO---LEDs, switches etc but always struggled with MEGAs over USB using the same sketch as the NANOs. PC---(USB)---MEGA---LEDs, switches etc For example using a single NANO connected to PC by USB I can run a simple sketch showing the Master Caution light on an LED and operating the Master Caution reset from a pushbutton. If I remove the NANO and replace it with a MEGA and upload the same sketch I cannot get it to work with DCS-BIOS. There seems to be something about the MEGA that stops it being used to interface hardware I/O directly over USB, without using any RS-485. It's a shame because the MEGA has such a large number of I/O it would be useful sometimes to use it over USB with no RS-485, for interfacing LEDs, switches etc. I suppose my fundamental question is what is the difference to DCS-BIOS between a NANO and a MEGA, and is there a way to get the MEGA working for hardware I/O without involving RS-485? Thanks again. Mark Link to comment Share on other sites More sharing options...
Hansolo Posted February 26, 2020 Share Posted February 26, 2020 I see the MEGA often used with DCS-BIOS as a master with NANO slave(s) over RS-485: PC---(USB)---MEGA---(RS-485)---NANO(s)---LEDs, switches etc Yes that is the only way to run a DCS-BIOS Master. The DCS-BIOS Master board MUST be a Mega board because it has multiple communication lines. RX0/TX0 for the USB line RX1/TX1 & RX2/TX2 & RX3/TX3 for RS-485. For example using a single NANO connected to PC by USB I can run a simple sketch showing the Master Caution light on an LED and operating the Master Caution reset from a pushbutton. If I remove the NANO and replace it with a MEGA and upload the same sketch I cannot get it to work with DCS-BIOS. When you upload the same sketch to the Mega you change the com port number in Arduino IDE, correct? Do you also change the DCS-BIOS communication to the same com port number? If not then you are trying to communicate to the Nano which is no longer attached. There seems to be something about the MEGA that stops it being used to interface hardware I/O directly over USB, without using any RS-485. It's a shame because the MEGA has such a large number of I/O it would be useful sometimes to use it over USB with no RS-485, for interfacing LEDs, switches etc. I suppose my fundamental question is what is the difference to DCS-BIOS between a NANO and a MEGA, and is there a way to get the MEGA working for hardware I/O without involving RS-485? There shouldn't be anything different. As you may notice from my post the CMSP/EWMU is running on a Mega but via USB Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album Link to comment Share on other sites More sharing options...
markjhall Posted February 27, 2020 Author Share Posted February 27, 2020 Thank you Hans, yes I change the COM ports accordingly and in fact the MEGA’s Rx LED indicates data is streaming to it from DCS-BIOS but the Tx light does not light. Your confirmation that the MEGA should work standalone over USB inspires me to try again I. If I can’t crack it I will try to upload a video to A10SimPilot YouTube to show the problem. Link to comment Share on other sites More sharing options...
markjhall Posted February 28, 2020 Author Share Posted February 28, 2020 Example code #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" DcsBios::Switch2Pos downlockOverride("DOWNLOCK_OVERRIDE", 2); void setup() { DcsBios::setup(); } void loop() { DcsBios::loop(); } This sketch works with NANOs and UNOs, but not with 3 different MEGA 2560s (genuine, SainSmart, Elegoo). When I connect DCS-BIOS via the Hub, with DCS A-10C running, the Rx LED on the MEGA starts flashing quickly. Shorting MEGA digital pin 2 to ground does not operate the downlock override in DCS World and the Tx LED does not flash on the MEGA. Link to comment Share on other sites More sharing options...
Ferlo Posted December 4, 2021 Share Posted December 4, 2021 On 2/28/2020 at 8:10 AM, markjhall said: Example code #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" DcsBios::Switch2Pos downlockOverride("DOWNLOCK_OVERRIDE", 2); void setup() { DcsBios::setup(); } void loop() { DcsBios::loop(); } This sketch works with NANOs and UNOs, but not with 3 different MEGA 2560s (genuine, SainSmart, Elegoo). When I connect DCS-BIOS via the Hub, with DCS A-10C running, the Rx LED on the MEGA starts flashing quickly. Shorting MEGA digital pin 2 to ground does not operate the downlock override in DCS World and the Tx LED does not flash on the MEGA. Hello Mark ! I have the same problem ! I load the sketch into Arduino UNO and it works. but using a MEGA no! Could you find the solution? Saludos ! Link to comment Share on other sites More sharing options...
No1sonuk Posted December 5, 2021 Share Posted December 5, 2021 (edited) Part of the problem is likely that the Mega has a different processor to the UNO and Nano... Mega uses ATmega2560, Uno and Nano use ATmega328P. Try: #define DCSBIOS_DEFAULT_SERIAL Instead of #define DCSBIOS_IRQ_SERIAL Edited December 5, 2021 by No1sonuk Link to comment Share on other sites More sharing options...
markjhall Posted May 14, 2022 Author Share Posted May 14, 2022 Well I found a way to work with the problem. To recap: I found the Arduino MEGA 2560 to be unreliable with DCS-BIOS, compared to the Arduino NANO, using A-10C & A-10C II modules, and not involving any RS-485 communications, just USB leads: What I found is that the MEGA is fussy about the order in which the various components are started: This always WORKS for a MEGA: start DCS-BIOS and serial comms to the MEGA before starting a flight in DCS World There many other combinations of starting/stopping the various parts that do not work. E.g. I cannot start a flight first and then start serial comms from DCS-BIOS to the MEGA, nor can I stop and restart serial comms from DCS-BIOS to the MEGA during a flight. By leaving some test code running in the MEGA I can see that when DCS-BIOS serial comms to the MEGA fail, the MEGA "crashes" - it's not just the DCS-BIOS code that stops, the test code also stops running on the MEGA. The MEGA recovers when the DCS World flight stops. Arduino NANOs are not so fussy: for every combination I tried of starting and stopping DCS world / DCS-BIOS / serial comms to the NANO, it always picks up the connection and starts working. #define DCSBIOS_DEFAULT_SERIAL and #define DCSBIOS_IRQ_SERIAL do not make a difference to these effects I tried these tests on several genuine and clone MEGAs and on several PCs / laptops always with the same results. With the latest versions (April 2022) of DCS World & modules / DCS-BIOS and modules. The only clue I found to the cause of this is maybe related to the baud rate / comms speed that DCS-BIOS uses for its serial comms to the Arduino but I can't verify this. I will try to post a video on YouTube A10SimPilot channel when I have some time... 1 Link to comment Share on other sites More sharing options...
Gizmata Posted June 9, 2022 Share Posted June 9, 2022 On 5/14/2022 at 4:52 AM, markjhall said: This always WORKS for a MEGA: start DCS-BIOS and serial comms to the MEGA before starting a flight in DCS World Thanks for figuring that out. I spent hours frustrated with no progress until I found your post. It is not fun having to boot DCS World for every code change, but it solves the problem. Link to comment Share on other sites More sharing options...
No1sonuk Posted June 9, 2022 Share Posted June 9, 2022 8 hours ago, Gizmata said: It is not fun having to boot DCS World for every code change, but it solves the problem. Try before the flight start, not restart DCS. Link to comment Share on other sites More sharing options...
Gizmata Posted June 10, 2022 Share Posted June 10, 2022 On 6/9/2022 at 5:11 AM, No1sonuk said: Try before the flight start, not restart DCS. Great suggestion, that worked nicely and is faster. 1 Link to comment Share on other sites More sharing options...
Recommended Posts