Jump to content

DCS-BIOS over RS485


Hansolo

Recommended Posts

  • 1 month later...

Hi, im having some issues with an LCD over RS485 which seems to be realted to too long drawing times and missing data on the RS485 bus. A quick skim through the code suggests DCS-BIOS doesn’t use interrupts for RS485 slaves. Is this not done because noone needed it - or is it impossible to add for some reason?


Edited by maciekish
Link to comment
Share on other sites

Hi all! I just don't know where to ask, pls advise ))) where can I find an airspeed and AoA for FA18? I used BORT but there is no such parameters 😞

Thanks

 

=WRAG=345

R7 5800X @ 4,8 GHz; DDR4 32Gb RAM (+32Gb swap); Radeon RX 6800 16Gb; 3840x2160; Win10-64

Link to comment
Share on other sites

1 час назад, milit сказал:

Hi all! I just don't know where to ask, pls advise ))) where can I find an airspeed and AoA for FA18? I used BORT but there is no such parameters 😞

Thanks

 

Посмотри в разделе CommonData, там есть разные скорости

Спойлер

image.png

По углу атаки не знаю.

А вообще можно в официальном чате в Дискорде спросить. Может, там быстрее подскажут.

https://discord.gg/5svGwKX

 


Edited by Диванный пилот
Link to comment
Share on other sites

5 hours ago, milit said:

Hi all! I just don't know where to ask, pls advise ))) where can I find an airspeed and AoA for FA18? I used BORT but there is no such parameters 😞

Thanks

 

Try "Standby Airspeed Indicator".  The primary is on the HUD.

 

Link to comment
Share on other sites

5 часов назад, No1sonuk сказал:

Try "Standby Airspeed Indicator".  The primary is on the HUD.

 

It returns a needle position 😞

 

Max 65535. Have to be converted somehow to the value of speed. Any ideas?

=WRAG=345

R7 5800X @ 4,8 GHz; DDR4 32Gb RAM (+32Gb swap); Radeon RX 6800 16Gb; 3840x2160; Win10-64

Link to comment
Share on other sites

56 минут назад, milit сказал:

It returns a needle position 😞

 

Max 65535. Have to be converted somehow to the value of speed. Any ideas?

Посмотри этот пример.Engine RPM to LCD2004_i2c.ino

Чтобы быстрее оцифровывать стрелочные индикаторы, я создал табличку.

Rotor rpm.xlsx

Link to comment
Share on other sites

6 hours ago, milit said:

It returns a needle position 😞

 

Max 65535. Have to be converted somehow to the value of speed. Any ideas?

You can use the Arduino "map" function.

You map the gauge 0-65535 to the full range of the gauge (I don't know the top end number).

E.g.

speed= map(newValue, 0, 65535, 0, 850);

That assumes "speed" is already declared as a global variable, the max speed value is 850 (a guess), and the code is in the function called when the value changes.

However, as mentioned above, the speed is available from the common data.

Link to comment
Share on other sites

17 часов назад, No1sonuk сказал:

You can use the Arduino "map" function.

You map the gauge 0-65535 to the full range of the gauge (I don't know the top end number).

E.g.

speed= map(newValue, 0, 65535, 0, 850);

That assumes "speed" is already declared as a global variable, the max speed value is 850 (a guess), and the code is in the function called when the value changes.

However, as mentioned above, the speed is available from the common data.

I mentioned speed just as an example. However, speed taken from common data is rather delaying in comparison with gauge in especially Mi-24P. And much accurate in FC3 planes.

And I didn't know about map function. Thanks a lot! I assume it's useful in case of linear dial. Right?

=WRAG=345

R7 5800X @ 4,8 GHz; DDR4 32Gb RAM (+32Gb swap); Radeon RX 6800 16Gb; 3840x2160; Win10-64

Link to comment
Share on other sites

Yes, the "map" function is to match one linear range of values to values of another linear range.

If you want to match non linear ranges, you have to use a kind of multimapping function or a dedicated library.

See below for some code fragments. My interpretation of internet multimap code, a few years ago for the MiG-21's radar altimeter non linear scaling.

Spoiler
// Function to adjust Radar Altimeter values --> multiMap()
// note: the _in array should have increasing values, "size" is the number of values within one array
int multiMap(int val, int* _in, int* _out, uint8_t size)
{
  // take care the value is within range
  // val = constrain(val, _in[0], _in[size-1]);	// values automatically may be constrained to the range by uncommenting this line
  if (val <= _in[0]) return _out[0];
  if (val >= _in[size-1]) return _out[size-1];

  // search right interval
  uint8_t pos = 1;  // _in[0] allready tested
  while(val > _in[pos]) pos++;

  // this will handle all exact "points" in the _in array
  if (val == _in[pos]) return _out[pos];

  // interpolate in the right segment for the rest
  return map(val, _in[pos-1], _in[pos], _out[pos-1], _out[pos]);
}

 

// show Radar Altimeter

if (address == 0x2286) {
    unsigned int raltNdValue = (value & 0xffff) >> 0;
    String raltNd(raltNdValue); 

    int raltNd1000 = (raltNd.toInt() * 1000 / 65535); // conversion factor

/*    RadAlt needle values must be mapped according to DCS internal RadAlt scale
      see document "mainpanel_init" --> RADIO_ALTIMETER_indicator */

      // note: the in[] array should have increasing values
      int in[]  = { 0.0, 41, 70, 103, 130, 181, 210, 245, 260, 298, 325, 472, 580, 680, 732, 807, 867, 909, 1000 };
      
      // out[] holds the values wanted in m
      int out[] = { 0.0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 250, 300, 400, 500, 600, 1000 };

      int ralt = multiMap(raltNd1000, in, out, 19);
 	
  // now use the variable "ralt" to print the height in meters to your display
  // for example like here on a 16x2 LCD
      {
      lcd.setCursor(10,1);
      lcd.print ("R:");
      if (ralt >= 995)  // RadAlt out of Range (995 m)
        {
          lcd.setCursor(13,1);
          lcd.print("   ");
        }
      else
        {
          lcd.setCursor(13,1);
          lcd.print(ralt);
        }
    }
}

 

 

Regards, Vinc


Edited by Vinc_Vega
  • Like 2

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • 2 weeks later...
it is strange, it's almost as if the OLED / LCD devices interfere with the signal somehow. I had previously noted that you can't run an OLED and a stepper motor successfully one one Nano as the stepper movement is massively impacted. My suspicion for that is that the stepper update  cadence is directly related to the OLED refresh rate, and the U8G2 driven OLEDs would slow it down to a point where it was useless.
However I can't imagine why there would be any effect on other Nanos that are just connected via RS485
Despite this, the multiple Mega master solution does seem to be a viable one so my intention is to use one dedicated Master for all the stepper motor driven devices, and one or two others for all the remaining OLEDs, LCD's and things like the CLP
One other thing I will try is some 5v bus bars so that the 5v supply to the devices are not just on the RS485 lines. I doubt it will make any difference but costs nothing to try
Les

Awesome!! I have this issue too, I have my servos connected to a PCA9685 with external power and I couldn’t figure out why I got this behavior. My steppers work as they should though.
So a second mega to run the gauges/ or the oleds should do the trick? I’m also using the U8G2 on my displays. I have one Nano per display as I use my custom font and that maxes out the memory :)

Cheers
/F
Link to comment
Share on other sites

I can confirm that using individual devices for the different gauges does really help. If you want to run more than one gauge off a single Nano / Uno / Mega over RS485, as long as they are not very active gauges you can. So on the A-10, hydraulic, fuel, Oxy pressure, Oxy Qty, flap position and cabin pressure gauges are ok where you want to use multiple on one arduino, as they mostly are either virtually static, or move slowly. As a result you won't notice any difference.

For the Altimeter, VVI, AOA and ALL the engine and APU gauges, I use one for each to prevent issues

I can also attest to using 3 RS485 masters on one Mega, which splits the network into three separate ones, which made my wiring simpler and works great

For the U8G2 use, try replacing the 'F' in the sketch code (after 'NONAME') with 1 or 2 - this is apparently the frame buffer, 'F' is 'full' whereas you can choose a lower value. It may help with the memory issue. Here's an example

change 

U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R3, /* clock=*/SCL, /* data=*/SDA, /* reset=*/U8X8_PIN_NONE);

to 

U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R3, /* clock=*/SCL, /* data=*/SDA, /* reset=*/U8X8_PIN_NONE);

 Cheers

 

Les

Link to comment
Share on other sites

  • 2 weeks later...

Question..

I made a connection RS485 

Master a Mega and this code.

/*
  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();
}

Standard i think..

Connection Master - RS

TX - Ro

RX - DI

RE+DE - Pin2

RS master - RS Slave

A - A

B - B

+5V - +5v

GND - GND

RS Slave - RS

TX - DI

RX - TX

RE+DE - Pin2

Rotary encoder Pin A1 A2

here the code

#define RS485  // default is USB mode, uncomment for using at the RS485 bus

#ifndef RS485
  #define DCSBIOS_IRQ_SERIAL  // use for Arduino UNO, NANO and MEGA
  // #define DCSBIOS_DEFAULT_SERIAL  // use for other boards like ESP32 or Raspberry Pi Pico
#endif

#ifdef RS485
  #define DCSBIOS_RS485_SLAVE 1 // change according your slave number (1 to 128)
  #define TXENABLE_PIN 2
#endif

#include "DcsBios.h"

/* paste code snippets from the reference documentation here */
DcsBios::RotaryEncoder altPressSet("ALT_PRESS_SET", "-3200", "+3200", A1, A2);

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

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

If i put the slave in usb mode it workes..

On rs485 mode it is not..

who can shine some light on this? or do i mis somthing?

16803696017912316460494316521713.jpg

Link to comment
Share on other sites

26 minutes ago, Vinc_Vega said:

Try to use TX1 (pin 18) and RX1 (pin 19) at the Master.

Regards, Vinc

Same.. do I need to change somthing on dcs or when I rotatie the encoder a led must do somthing? Now only thr green led is on and the L is on.. tx and rx is doing nothing..

Link to comment
Share on other sites

For the wiring have a look at the graphics in the first page of this topic.

https://forum.dcs.world/topic/208455-dcs-bios-over-rs485/?do=findComment&comment=3926198

TX (transmit to the bus)-> DI (driver in)

RX (receive from bus)-> RO (receiver out)

D2 -> DE (driver enable) and RE (receiver enable)

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

3 hours ago, Vinc_Vega said:

For the wiring have a look at the graphics in the first page of this topic.

https://forum.dcs.world/topic/208455-dcs-bios-over-rs485/?do=findComment&comment=3926198

TX (transmit to the bus)-> DI (driver in)

RX (receive from bus)-> RO (receiver out)

D2 -> DE (driver enable) and RE (receiver enable)

Regards, Vinc

 

Ok.. then I have that also good.. 

Link to comment
Share on other sites

3 hours ago, lesthegrngo said:

Be aware that some Megas have the pins mis-named - I have one and it caused me issues because the TX1 and RX1 pins were marked in reverse

Les

Yes saw that.. this is the original.. and tested it by exchange them.. but also no luck

Link to comment
Share on other sites

Glad you found it, but it also goes to show that it is too easy to go down rabbit holes chasing complicated solutions what the problem is a simple one. I've done it, chasing the problem by swapping chips, nanos, steppers, you name it... only to find it was a duPont jumper wire or a USB cable. Always try replacement cables first, and try to log what you change because it's too easy to lose track. 

One trap I fell into was to use an Ohmmeter to check continuity on a cable, which showed it was OK while I was holding it down, only for the problem to reappear what the cable was installed. By holding the cable down to check it, I was unwittingly making the broken cable make contact, which then opened up when I let it go. As a result, I try to check the cables in the loose state, or swap the cable out if there is one I can 

A last word about USB cables, at least from my experience; some USB cables are better than others, some are good for charging, others not, and the same for data. 

Lastly, the one that really killed me for about 9 months was an issue with the PC itself. My RS485 network just stopped working, and nothing I did changed it. It never occurred to me that it might be the PC used to program the arduinos until a chance comment from someone on this forum. Using another PC which happened to have a later version of the Arduino IDE installed instantly cured the issue.

The moral is, when troubleshooting don't discount anything, but always start with the basics. And be methodical. 

Cheers 

Les

  • Like 1
Link to comment
Share on other sites

I was setting up a test.. and wire for wire I transfert until it stops working... I put in the usbc in.. only one site and it stops.. in.. out.. in out.. it works slow.. took a new one... worked perfectly... up to the next project on the panel... the compas..

Link to comment
Share on other sites

  • Recently Browsing   0 members

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