Jump to content

DCS-BIOS missing data over RS485


maciekish

Recommended Posts

Hi, I've been pulling my hair with this for a long time, seems like when the Arduino is too busy drawing something on screen, or just toggling some LEDs, data gets missed on the RS485 bus. All the sketches i've tested work over USB with the same Arduino, but exhibit the exact same issue when run over RS485. If its a display, it either misses updates completely, misses half the screen, or starts writing out random data from the RS485 stream, even including the DCS-BIOS synchronization sequence on screen as text "UUUU". I even tried a simpler panel, the caution panel with direct register access for toggling the LEDs and its still too slow just blinking ~10 LEDs. If i reduce the number of LEDs to 2, it works perfectly.

Here is an example of the caution panel of the A-10C, the blinking LEDs should be blinking at a steady pace, not take pauses like they do in the video below. Here is the code, i dont think it can be optimized much more than that... https://github.com/maciekish/warthogathome/blob/master/Arduino/23_Caution_Panel/23_Caution_Panel.ino

Has anyone else run into these issues? Is DCS-BIOS handling the RS485 interrupts properly? Am i missing something completely different?

 

 

Link to comment
Share on other sites

I had a similar issue when I tried using a Mega to directly control the A10 WLP LEDs. The setup and sketch worked perfectly over USB, but when I connected RS485 it would only display maybe 30% of the lights correctly. In the end I had to go back to using a MAX7219 chip to control the LEDs, which does work over RS485. 

I think No1sonuk put it down to 'bit-banging'......

Les

Link to comment
Share on other sites

@maciekish ISTR some people reporting problems with using Megas as RS485 slaves. I assume that's what you're trying to do if you're direct driving the LEDs.

That's also possibly not a good idea due to the amount of power you'll be drawing from the Arduino.

You say you tried a smaller panel. Was that also with the Mega? Can you try it with an Uno?

@lesthegrngo "Bit banging" * should only be a problem if you're using a software serial port. RS485 masters should be Megas because they have multiple hardware serial ports so bit-banging isn't required.

Those connect to the hardware serial ports on the slave devices (usually D0 and D1).

The only problem then is the combination of data rate, size of the UART buffers and the amount of data processing required.

The MAX7219 doesn't increase processor overhead because, as far as I'm aware, the I2C/SPI port is another hardware port specifically for I2C and SPI.

 

* "Bit-banging" is where the program has to turn on and off the output pin in the correct timing to create the serial data stream, or read the input pin at the correct intervals to receive the data. This requires a processor core to only do this task.

This is what the code does automatically if you set up a serial port on a pin that isn't connected to a hardware UART.

In the case of a hardware serial port, the code writes or reads a single memory location and the processor's hardware deals with the data transmission/reception. This obviously takes virtually no processor time.

For this reason, Megas are used as RS485 masters because they have more than one hardware UART available. 

  • Thanks 1
Link to comment
Share on other sites

@No1sonuk Hi, thanks for your time, i really appreciate it.

To clarify, the direct-drive of the LEDs is done properly via transistors + PWM via ULN2003A on the negative side, so no power is drawn from the Arduino, and its dimmable programatically. While i can certainly try a MAX7219, it would be a step back in development as i already have hardware for individual LED control. Will a MAX7219 library really be faster than direct register writes for 48 LEDs? I'm afraid the library code will add more overhead than the direct register writes, but I'm no expert on that matter. I tried a different LED controller before, don't remember which one but i had the same issue, inconsistent and dropped updates, which is why i decided to try low-level fast direct writes.

Regarding the Arduinos, I'm using my own hardware consisting of customized Nanos and Megas. This panel indeed uses a mega, and i could possibly try a Nano, but that would mean 2-3 Arduinos for something as simple as a caution panel which is not ideal, especially considering i have already handled the power delivery to the LEDs.

Since everything works fine over USB (approximately same amount of data), I'm instead suspecting that this has something to do with the Arduino not handling interrupts properly. For example, in Protocol.cpp, it looks like interrupts get disabled for RS485 slaves. Could you perhaps shed some light on this? I would much rather fix the underlying issue as this applies to displays as well, and if i can't even drive a Nextion over hardware serial, thats a big problem, and another reason i'm suspecting the MAX7219 won't really help.

So to summarize, considering things are working over USB but not RS485 i draw the conclusion that there is a software issue in DCS-BIOS in RS485 mode. If you, or anyone else is knowledgeable enough to address this, i may be willing to pay up for the help, as this is a very serious issue for me. I'm in the process of designing and producing a special dev-kit PCB which will include master & slave on one board with appropriate test-points to troubleshoot this, and it will be made available to anyone who seriously considers fixing the root cause of this issue.


Edited by maciekish
Black text background, didnt notice as i was writing in dark mode.
Link to comment
Share on other sites

@maciekish Sorry, but I can't help with the ins and outs of that code. Maybe try the Flightpanels fork Discord?

All I remember is a mention that there were issues with using a Mega as a slave device.  I don't remember the details or if there was any resolution. 

I suppose the easiest option would be to use USB for that device if it works.

Link to comment
Share on other sites

1 hour ago, No1sonuk said:

@maciekish Sorry, but I can't help with the ins and outs of that code. Maybe try the Flightpanels fork Discord?

All I remember is a mention that there were issues with using a Mega as a slave device.  I don't remember the details or if there was any resolution. 

I suppose the easiest option would be to use USB for that device if it works.

I've tried the Discord but there aren't many people with that deep Arduino and RS485 knowledge, and the ones that do are understandably quite busy.

Ill give the Nano a try but it won't be usable in many instances where the issue manifests, because i need either the pin count or the ram/program space.

I want to avoid USB because of the additional cabling and COM-ports, but if its impossible then its impossible.

Link to comment
Share on other sites

Another option is to use one Nano and the Max7219 solution.

It is fast and you don't need to care of shifting registers, the magic is to use the 48 LEDs as one ->LED-matrix<-.

It won't bring stability over the RS485 network but will "block" only one USB port instead of two or three.

 

 

Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • Recently Browsing   0 members

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