Jump to content

DCS-BIOS over RS485


Hansolo

Recommended Posts

Also try commenting out all LED lines but the one to pin 13 and see if it works then.

If it does, uncomment each line until it stops working.

Sound like very good advise.

 

I'm running 17 leds in each pinout of the nano, leaving D2 for the MAX487 chip.

Depending on which LED's your are using you may very well be overloading the Arduino's. I think I am using 30mA LED's but may be mistaken. Yes max load on a digital output is 40mA but the max load on the microcontroller itself is just 200mA;

https://electronics.stackexchange.com/questions/67092/how-much-current-can-i-draw-from-the-arduinos-pins

 

Thought it was a power supply problem, but although sending mega's 5V through VIN and connecting the nano to the PC, it keeps doing that.

The input range on the VIN is 6-12V because it runs through a voltage regulator. If you use the Mega's 5V pin (output) then you need to attach it the the Nano's 5V pin as well to bypass the voltage regulator. Otherwise you may very well run the Nano at too low voltage. A 5V regulator needs a little head to be able to maintain 5V, hence the 6-12V input voltage

 

IIRCC the USB is bypassing the voltage regulator which may be why it works via USB and not over RS485.

 

Cheers

Solo

Link to comment
Share on other sites

40mA is the absolute maximum, not what it should be used at. IIRC, that limit is usually quoted as 20mA per pin.

 

17 LEDs would be limited to 11mA each with a 200mA supply and leave a bit for the processor.

 

Arduino pins can sink that current as well as source it, so a way round that limit would be to "invert" the LEDs.

Rather than turn them on by supplying power from the arduino, through the LED to ground, connect the LEDs (through resistors) to the same external +5V supply you're feeding to the arduino 5V pin and use the arduino to drive the ground line low to turn on the LED.

 

Having said that, this page indicates there may be another limit that's in play. It's for the Uno, but the processor is the same as the Nano:

https://diyi0t.com/arduino-uno-tutorial/

 

This says that although each individual pin can source or sink 40mA, there's a combined limit which means you couldn't use all of them at that individual limit.

 

Personally, I'd use Neopixels or WS2812 addressable RGB LEDs. They're more expensive, but you only need a single external supply, and all the arduino has to do is send I2C data to the string. Plus you can make them show pretty much any colour you want.


Edited by No1sonuk
Link to comment
Share on other sites

  • 3 weeks later...

This is a very interesting thread. Thanks to all who are posting such helpful information here. I think I am beginning to understand the Max 487 / Master-slave configuration, thanks to the excellent diagrams by Hans and Blue73. I looks like it may be an easier concept than I originally thought a few years ago.

 

I've been away from this topic for several years due to real-world priorities, but I hope to get back to experimenting with Arduino / DCS-BIOS solution.

Link to comment
Share on other sites

Hey guys. I have used my cdu display via serial perfectly and now trying to run via rs485. I have everything wired up correctly as described and buttons work no problem but the display will show correct screen and font for about 5 seconds then it starts to display wrong characters in random places. I can switch to a different cdu page and it'll do the same things again. I've tried this without any buttons connected. Like I said, it works via serial, no weird characters or glitching fonts.

 

Mega master and mega slave. TX/RX pins on the slave mega are on 1 and 0. 18 and 19 will not tx or rx data.

 

This is the slave sketch

 

 

 

 

 

#define DCSBIOS_RS485_SLAVE 1

#define TXENABLE_PIN 2

#include "DcsBios.h"

#include <Adafruit_GFX.h>

#include <UTFTGLUE.h>

 

DcsBios::Switch2Pos cduLsk3l("CDU_LSK_3L", A0);

DcsBios::Switch2Pos cduLsk5l("CDU_LSK_5L", A1);

DcsBios::Switch2Pos cduLsk7l("CDU_LSK_7L", A2);

DcsBios::Switch2Pos cduLsk9l("CDU_LSK_9L", A3);

DcsBios::Switch2Pos cduLsk3r("CDU_LSK_3R", A4);

DcsBios::Switch2Pos cduLsk5r("CDU_LSK_5R", A5);

DcsBios::Switch2Pos cduLsk7r("CDU_LSK_7R", A6);

DcsBios::Switch2Pos cduLsk9r("CDU_LSK_9R", A7);

DcsBios::Switch2Pos cduSys("CDU_SYS", A8);

DcsBios::Switch2Pos cduNav("CDU_NAV", A9);

DcsBios::Switch2Pos cduWp("CDU_WP", A10);

DcsBios::Switch2Pos cduOset("CDU_OSET", A11);

DcsBios::Switch2Pos cduFpm("CDU_FPM", A12);

DcsBios::Switch2Pos cduPrev("CDU_PREV", A13);

DcsBios::Switch2Pos cdu0("CDU_0", A14);

DcsBios::Switch2Pos cdu1("CDU_1", A15);

DcsBios::Switch2Pos cdu2("CDU_2", 3);

DcsBios::Switch2Pos cdu3("CDU_3", 4);

DcsBios::Switch2Pos cdu4("CDU_4", 5);

DcsBios::Switch2Pos cdu5("CDU_5", 6);

DcsBios::Switch2Pos cdu6("CDU_6", 7);

DcsBios::Switch2Pos cdu7("CDU_7", 8);

DcsBios::Switch2Pos cdu8("CDU_8", 9);

DcsBios::Switch2Pos cdu9("CDU_9", 10);

DcsBios::Switch3Pos cduPg("CDU_PG", 11, 12);

 

UTFTGLUE myGLCD(0x9486,A2,A1,A3,A4,A0);

 

void printChar(int row, int col, unsigned char c) {

int16_t x = 13 + col * 19;

int16_t y = row * 32 + 6;

myGLCD.drawChar(x, y, c, 0x07E0, 0x0, 3);

}

 

/* paste code snippets from the reference documentation here */

void onCduLine0Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(0, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine0Buffer(0x11c0, onCduLine0Change);

 

void onCduLine1Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(1, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine1Buffer(0x11d8, onCduLine1Change);

 

void onCduLine2Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(2, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine2Buffer(0x11f0, onCduLine2Change);

 

void onCduLine3Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(3, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine3Buffer(0x1208, onCduLine3Change);

 

void onCduLine4Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(4, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine4Buffer(0x1220, onCduLine4Change);

 

void onCduLine5Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(5, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine5Buffer(0x1238, onCduLine5Change);

 

void onCduLine6Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(6, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine6Buffer(0x1250, onCduLine6Change);

 

void onCduLine7Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(7, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine7Buffer(0x1268, onCduLine7Change);

 

void onCduLine8Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(8, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine8Buffer(0x1280, onCduLine8Change);

 

void onCduLine9Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(9, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine9Buffer(0x1298, onCduLine9Change);

 

void setup() {

DcsBios::setup();

 

// Setup the LCD

myGLCD.InitLCD();

myGLCD.clrScr();

myGLCD.setTextSize(3);

myGLCD.setColor(0, 0, 0); // seems to have no effect

myGLCD.drawRect(0, 0, 0, 255);

myGLCD.invertDisplay(1);

}

 

void loop() {

DcsBios::loop();

}

 

 

 

 

 

 

 

My font file. glcdfont.c

 

 

 

// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0.

// See gfxfont.h for newer custom bitmap font info.

// Modified for DCS A-10C CDU 2016-03-14

 

 

#ifndef FONT5X7_H

#define FONT5X7_H

 

#ifdef __AVR__

#include <avr/io.h>

#include <avr/pgmspace.h>

#elif defined(ESP8266)

#include <pgmspace.h>

#else

#define PROGMEM

#endif

 

// Standard ASCII 5x7 font

 

static const unsigned char font[] PROGMEM = {

0x00, 0x00, 0x00, 0x00, 0x00,

0x3E, 0x5B, 0x4F, 0x5B, 0x3E,

0x3E, 0x6B, 0x4F, 0x6B, 0x3E,

0x1C, 0x3E, 0x7C, 0x3E, 0x1C,

0x18, 0x3C, 0x7E, 0x3C, 0x18,

0x1C, 0x57, 0x7D, 0x57, 0x1C,

0x1C, 0x5E, 0x7F, 0x5E, 0x1C,

0x00, 0x18, 0x3C, 0x18, 0x00,

0xFF, 0xE7, 0xC3, 0xE7, 0xFF,

0x00, 0x18, 0x24, 0x18, 0x00,

0xFF, 0xE7, 0xDB, 0xE7, 0xFF,

0x30, 0x48, 0x3A, 0x06, 0x0E,

0x26, 0x29, 0x79, 0x29, 0x26,

0x40, 0x7F, 0x05, 0x05, 0x07,

0x40, 0x7F, 0x05, 0x25, 0x3F,

0x5A, 0x3C, 0xE7, 0x3C, 0x5A,

0x7F, 0x3E, 0x1C, 0x1C, 0x08,

0x08, 0x1C, 0x1C, 0x3E, 0x7F,

0x14, 0x22, 0x7F, 0x22, 0x14,

0x5F, 0x5F, 0x00, 0x5F, 0x5F,

0x06, 0x09, 0x7F, 0x01, 0x7F,

0x00, 0x66, 0x89, 0x95, 0x6A,

0x60, 0x60, 0x60, 0x60, 0x60,

0x94, 0xA2, 0xFF, 0xA2, 0x94,

0x08, 0x04, 0x7E, 0x04, 0x08,

0x10, 0x20, 0x7E, 0x20, 0x10,

0x08, 0x08, 0x2A, 0x1C, 0x08,

0x08, 0x1C, 0x2A, 0x08, 0x08,

0x1E, 0x10, 0x10, 0x10, 0x10,

0x0C, 0x1E, 0x0C, 0x1E, 0x0C,

0x30, 0x38, 0x3E, 0x38, 0x30,

0x06, 0x0E, 0x3E, 0x0E, 0x06,

0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x5F, 0x00, 0x00,

0x00, 0x07, 0x00, 0x07, 0x00,

0x14, 0x7F, 0x14, 0x7F, 0x14,

0x24, 0x2A, 0x7F, 0x2A, 0x12,

0x23, 0x13, 0x08, 0x64, 0x62,

0x36, 0x49, 0x56, 0x20, 0x50,

0x00, 0x08, 0x07, 0x03, 0x00,

0x00, 0x1C, 0x22, 0x41, 0x00,

0x00, 0x41, 0x22, 0x1C, 0x00,

0x2A, 0x1C, 0x7F, 0x1C, 0x2A,

0x08, 0x08, 0x3E, 0x08, 0x08,

0x00, 0x80, 0x70, 0x30, 0x00,

0x08, 0x08, 0x08, 0x08, 0x08,

0x00, 0x00, 0x60, 0x60, 0x00,

0x20, 0x10, 0x08, 0x04, 0x02,

0x3E, 0x51, 0x49, 0x45, 0x3E,

0x00, 0x42, 0x7F, 0x40, 0x00,

0x72, 0x49, 0x49, 0x49, 0x46,

0x21, 0x41, 0x49, 0x4D, 0x33,

0x18, 0x14, 0x12, 0x7F, 0x10,

0x27, 0x45, 0x45, 0x45, 0x39,

0x3C, 0x4A, 0x49, 0x49, 0x31,

0x41, 0x21, 0x11, 0x09, 0x07,

0x36, 0x49, 0x49, 0x49, 0x36,

0x46, 0x49, 0x49, 0x29, 0x1E,

0x00, 0x00, 0x14, 0x00, 0x00,

0x00, 0x40, 0x34, 0x00, 0x00,

0x00, 0x08, 0x14, 0x22, 0x41,

0x14, 0x14, 0x14, 0x14, 0x14,

0x00, 0x41, 0x22, 0x14, 0x08,

0x02, 0x01, 0x51, 0x09, 0x06, //?

0x3E, 0x41, 0x5D, 0x59, 0x4E,

0x7C, 0x12, 0x11, 0x12, 0x7C,

0x7F, 0x49, 0x49, 0x49, 0x36,

0x3E, 0x41, 0x41, 0x41, 0x22,

0x7F, 0x41, 0x41, 0x41, 0x3E,

0x7F, 0x49, 0x49, 0x49, 0x41,

0x7F, 0x09, 0x09, 0x09, 0x01,

0x3E, 0x41, 0x41, 0x51, 0x73,

0x7F, 0x08, 0x08, 0x08, 0x7F,

0x00, 0x41, 0x7F, 0x41, 0x00,

0x20, 0x40, 0x41, 0x3F, 0x01,

0x7F, 0x08, 0x14, 0x22, 0x41,

0x7F, 0x40, 0x40, 0x40, 0x40,

0x7F, 0x02, 0x1C, 0x02, 0x7F,

0x7F, 0x04, 0x08, 0x10, 0x7F,

0x3E, 0x41, 0x41, 0x41, 0x3E,

0x7F, 0x09, 0x09, 0x09, 0x06,

0x3E, 0x41, 0x51, 0x21, 0x5E,

0x7F, 0x09, 0x19, 0x29, 0x46,

0x26, 0x49, 0x49, 0x49, 0x32,

0x03, 0x01, 0x7F, 0x01, 0x03,

0x3F, 0x40, 0x40, 0x40, 0x3F,

0x1F, 0x20, 0x40, 0x20, 0x1F,

0x3F, 0x40, 0x38, 0x40, 0x3F,

0x63, 0x14, 0x08, 0x14, 0x63,

0x03, 0x04, 0x78, 0x04, 0x03,

0x61, 0x51, 0x49, 0x45, 0x43, //Z

0x00, 0x7F, 0x41, 0x41, 0x41,

0x02, 0x04, 0x08, 0x10, 0x20,

0x00, 0x41, 0x41, 0x41, 0x7F,

0x04, 0x02, 0x01, 0x02, 0x04,

0x40, 0x40, 0x40, 0x40, 0x40,

0x00, 0x03, 0x07, 0x08, 0x00,

0x20, 0x54, 0x54, 0x78, 0x40,

0x7F, 0x28, 0x44, 0x44, 0x38,

0x38, 0x44, 0x44, 0x44, 0x28,

0x38, 0x44, 0x44, 0x28, 0x7F,

0x38, 0x54, 0x54, 0x54, 0x18,

0x00, 0x08, 0x7E, 0x09, 0x02,

0x18, 0xA4, 0xA4, 0x9C, 0x78,

0x7F, 0x08, 0x04, 0x04, 0x78,

0x00, 0x44, 0x7D, 0x40, 0x00,

0x20, 0x40, 0x40, 0x3D, 0x00,

0x7F, 0x10, 0x28, 0x44, 0x00,

0x00, 0x41, 0x7F, 0x40, 0x00,

0x7C, 0x04, 0x78, 0x04, 0x78,

0x7C, 0x08, 0x04, 0x04, 0x78,

0x38, 0x44, 0x44, 0x44, 0x38,

0xFC, 0x18, 0x24, 0x24, 0x18,

0x18, 0x24, 0x24, 0x18, 0xFC,

0x7C, 0x08, 0x04, 0x04, 0x08,

0x48, 0x54, 0x54, 0x54, 0x24,

0x04, 0x04, 0x3F, 0x44, 0x24,

0x3C, 0x40, 0x40, 0x20, 0x7C,

0x1C, 0x20, 0x40, 0x20, 0x1C,

0x3C, 0x40, 0x30, 0x40, 0x3C,

0x44, 0x28, 0x10, 0x28, 0x44,

0x4C, 0x90, 0x90, 0x90, 0x7C,

0x44, 0x64, 0x54, 0x4C, 0x44,

0x00, 0x08, 0x36, 0x41, 0x00,

0x00, 0x00, 0x77, 0x00, 0x00,

0x00, 0x41, 0x36, 0x08, 0x00,

0x02, 0x01, 0x02, 0x04, 0x02,

0x3C, 0x26, 0x23, 0x26, 0x3C,

0x1E, 0xA1, 0xA1, 0x61, 0x12,

0x3A, 0x40, 0x40, 0x20, 0x7A,

0x38, 0x54, 0x54, 0x55, 0x59,

0x21, 0x55, 0x55, 0x79, 0x41,

0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut

0x21, 0x55, 0x54, 0x78, 0x40,

0x20, 0x54, 0x55, 0x79, 0x40,

0x0C, 0x1E, 0x52, 0x72, 0x12,

0x39, 0x55, 0x55, 0x55, 0x59,

0x39, 0x54, 0x54, 0x54, 0x59,

0x39, 0x55, 0x54, 0x54, 0x58,

0x00, 0x00, 0x45, 0x7C, 0x41,

0x00, 0x02, 0x45, 0x7D, 0x42,

0x00, 0x01, 0x45, 0x7C, 0x40,

0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut

0xF0, 0x28, 0x25, 0x28, 0xF0,

0x7C, 0x54, 0x55, 0x45, 0x00,

0x20, 0x54, 0x54, 0x7C, 0x54,

0x7C, 0x0A, 0x09, 0x7F, 0x49,

0x32, 0x49, 0x49, 0x49, 0x32,

0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut

0x32, 0x4A, 0x48, 0x48, 0x30,

0x3A, 0x41, 0x41, 0x21, 0x7A,

0x3A, 0x42, 0x40, 0x20, 0x78,

0x00, 0x9D, 0xA0, 0xA0, 0x7D,

0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut

0x3D, 0x40, 0x40, 0x40, 0x3D,

0x3C, 0x24, 0xFF, 0x24, 0x24,

0x48, 0x7E, 0x49, 0x43, 0x66,

0x2B, 0x2F, 0xFC, 0x2F, 0x2B,

0xFF, 0x09, 0x29, 0xF6, 0x20,

0xC0, 0x88, 0x7E, 0x09, 0x03,

0x20, 0x54, 0x54, 0x79, 0x41,

0x7F, 0x41, 0x00, 0x41, 0x7F, //0x00, 0x00, 0x44, 0x7D, 0x41, A1 - Data Entry

0x30, 0x48, 0x48, 0x4A, 0x32,

0x38, 0x40, 0x40, 0x22, 0x7A,

0x00, 0x7A, 0x0A, 0x0A, 0x72,

0x7D, 0x0D, 0x19, 0x31, 0x7D,

0x26, 0x29, 0x29, 0x2F, 0x28,

0x26, 0x29, 0x29, 0x29, 0x26,

0x30, 0x48, 0x4D, 0x40, 0x20,

0x1C, 0x22, 0x2A, 0x22, 0x1C, //0x38, 0x08, 0x08, 0x08, 0x08 A9 - bullseye

0x08, 0x08, 0x08, 0x08, 0x38,

0x08, 0x1C, 0x2A, 0x08, 0x08, //0x2F, 0x10, 0xC8, 0xAC, 0xBA, AB - arrow to left

0x2F, 0x10, 0x28, 0x34, 0xFA,

0x00, 0x00, 0x7B, 0x00, 0x00,

0x14, 0x22, 0x7F, 0x22, 0x14, // 0x08, 0x14, 0x2A, 0x14, 0x22, AE - up-down arrow

0x22, 0x14, 0x2A, 0x14, 0x08,

0x55, 0x00, 0x55, 0x00, 0x55,

0x07, 0x05, 0x07, 0x00, 0x00, //B0 - degree

0x48, 0x48, 0x7E, 0x48, 0x48, //B1 - +_ symbol

0x00, 0x00, 0x00, 0xFF, 0x00,

0x10, 0x10, 0x10, 0xFF, 0x00,

0x14, 0x14, 0x14, 0xFF, 0x00,

0x10, 0x10, 0xFF, 0x00, 0xFF,

0x7F, 0x7F, 0x7F, 0x7F, 0x7F, // 0x10, 0x10, 0xF0, 0x10, 0xF0,B6 - CDU cursor

0x14, 0x14, 0x14, 0xFC, 0x00,

0x14, 0x14, 0xF7, 0x00, 0xFF,

0x00, 0x00, 0xFF, 0x00, 0xFF,

0x14, 0x14, 0xF4, 0x04, 0xFC,

0x08, 0x08, 0x2A, 0x1C, 0x08, // 0x14, 0x14, 0x17, 0x10, 0x1F, BB - arrow to right

0x10, 0x10, 0x1F, 0x10, 0x1F,

0x14, 0x14, 0x14, 0x1F, 0x00,

0x10, 0x10, 0x10, 0xF0, 0x00,

0x00, 0x00, 0x00, 0x1F, 0x10,

0x10, 0x10, 0x10, 0x1F, 0x10,

0x10, 0x10, 0x10, 0xF0, 0x10,

0x00, 0x00, 0x00, 0xFF, 0x10,

0x10, 0x10, 0x10, 0x10, 0x10,

0x10, 0x10, 0x10, 0xFF, 0x10,

0x00, 0x00, 0x00, 0xFF, 0x14,

0x00, 0x00, 0xFF, 0x00, 0xFF,

0x00, 0x00, 0x1F, 0x10, 0x17,

0x00, 0x00, 0xFC, 0x04, 0xF4,

0x14, 0x14, 0x17, 0x10, 0x17,

0x14, 0x14, 0xF4, 0x04, 0xF4,

0x00, 0x00, 0xFF, 0x00, 0xF7,

0x14, 0x14, 0x14, 0x14, 0x14,

0x14, 0x14, 0xF7, 0x00, 0xF7,

0x14, 0x14, 0x14, 0x17, 0x14,

0x10, 0x10, 0x1F, 0x10, 0x1F,

0x14, 0x14, 0x14, 0xF4, 0x14,

0x10, 0x10, 0xF0, 0x10, 0xF0,

0x00, 0x00, 0x1F, 0x10, 0x1F,

0x00, 0x00, 0x00, 0x1F, 0x14,

0x00, 0x00, 0x00, 0xFC, 0x14,

0x00, 0x00, 0xF0, 0x10, 0xF0,

0x10, 0x10, 0xFF, 0x10, 0xFF,

0x14, 0x14, 0x14, 0xFF, 0x14,

0x10, 0x10, 0x10, 0x1F, 0x00,

0x00, 0x00, 0x00, 0xF0, 0x10,

0xFF, 0xFF, 0xFF, 0xFF, 0xFF,

0xF0, 0xF0, 0xF0, 0xF0, 0xF0,

0xFF, 0xFF, 0xFF, 0x00, 0x00,

0x00, 0x00, 0x00, 0xFF, 0xFF,

0x0F, 0x0F, 0x0F, 0x0F, 0x0F,

0x38, 0x44, 0x44, 0x38, 0x44,

0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta

0x7E, 0x02, 0x02, 0x06, 0x06,

0x02, 0x7E, 0x02, 0x7E, 0x02,

0x63, 0x55, 0x49, 0x41, 0x63,

0x38, 0x44, 0x44, 0x3C, 0x04,

0x40, 0x7E, 0x20, 0x1E, 0x20,

0x06, 0x02, 0x7E, 0x02, 0x02,

0x99, 0xA5, 0xE7, 0xA5, 0x99,

0x1C, 0x2A, 0x49, 0x2A, 0x1C,

0x4C, 0x72, 0x01, 0x72, 0x4C,

0x30, 0x4A, 0x4D, 0x4D, 0x30,

0x30, 0x48, 0x78, 0x48, 0x30,

0xBC, 0x62, 0x5A, 0x46, 0x3D,

0x3E, 0x49, 0x49, 0x49, 0x00,

0x7E, 0x01, 0x01, 0x01, 0x7E,

0x2A, 0x2A, 0x2A, 0x2A, 0x2A,

0x44, 0x44, 0x5F, 0x44, 0x44,

0x40, 0x51, 0x4A, 0x44, 0x40,

0x40, 0x44, 0x4A, 0x51, 0x40,

0x00, 0x00, 0xFF, 0x01, 0x03,

0xE0, 0x80, 0xFF, 0x00, 0x00,

0x08, 0x08, 0x6B, 0x6B, 0x08,

0x36, 0x12, 0x36, 0x24, 0x36,

0x06, 0x0F, 0x09, 0x0F, 0x06,

0x00, 0x00, 0x18, 0x18, 0x00,

0x00, 0x00, 0x10, 0x10, 0x00,

0x30, 0x40, 0xFF, 0x01, 0x01,

0x00, 0x1F, 0x01, 0x01, 0x1E,

0x00, 0x19, 0x1D, 0x17, 0x12,

0x00, 0x3C, 0x3C, 0x3C, 0x3C,

0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP

};

#endif // FONT5X7_H


Edited by TulsA-10

" I'm gonna have to be taking your car today. See I have some top secret clown business that supersedes any plans that you might have for this here vehicle."

Link to comment
Share on other sites

  • 3 weeks later...

Caution Lights Panel, random blinking LED

 

Dear all,

 

first of all: i am totally new to the forums and i love the quality of the discussions!

 

i am experiencing the very same issue and was able to pin it down to a Arduino hardware/software problem:

- no LED connected at all

- MAX487 as in the tutorial

 

it depends how many LED functions are declared:

 

#define DCSBIOS_RS485_SLAVE 1
#define TXENABLE_PIN 2
#include "DcsBios.h"

DcsBios::LED clC1(0x10d4, 0x0100, 13);
DcsBios::LED clA1(0x10d4, 0x0001, 31);
DcsBios::LED clA2(0x10d4, 0x0002, 32);
DcsBios::LED clA3(0x10d4, 0x0004, 33);
DcsBios::LED clA4(0x10d4, 0x0008, 34);
DcsBios::LED clB1(0x10d4, 0x0010, 27);
DcsBios::LED clB2(0x10d4, 0x0020, 28);
//DcsBios::LED clB3(0x10d4, 0x0040, 29);

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

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

-> works as expected

 

#define DCSBIOS_RS485_SLAVE 1
#define TXENABLE_PIN 2
#include "DcsBios.h"

DcsBios::LED clC1(0x10d4, 0x0100, 13);
DcsBios::LED clA1(0x10d4, 0x0001, 31);
DcsBios::LED clA2(0x10d4, 0x0002, 32);
DcsBios::LED clA3(0x10d4, 0x0004, 33);
DcsBios::LED clA4(0x10d4, 0x0008, 34);
DcsBios::LED clB1(0x10d4, 0x0010, 27);
DcsBios::LED clB2(0x10d4, 0x0020, 28);
DcsBios::LED clB3(0x10d4, 0x0040, 29);

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

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

 

-> LED 13 (onboard) blinks randomly

(it doesn't depend on which LED functions i define; just if the number is more than 7 i get that random behavior)

just that i have mentioned it: it all works perfectly when i connect the board directly via USB instead of RS487.

 

so, i assume it is a performance issue of the ArduinoMEGA board while processing the RS487 stream.

 

did anyone see that already and has a solution for it? are there more powerful Arduino boards with enough I/O for connecting the Caution Lights Panel anyone has experience with?

Link to comment
Share on other sites

Dear all,

 

first of all: i am totally new to the forums and i love the quality of the discussions!

 

i am experiencing the very same issue and was able to pin it down to a Arduino hardware/software problem:

- no LED connected at all

- MAX487 as in the tutorial

 

it depends how many LED functions are declared:

 

Have you tried an Uno or Nano?

 

The analogue outputs can be used for digital, so you can still reserve 0,1, and 2 for the RS485.

define them as "A0", "A1", etc.

Test that, though - I know they can be used with arduino digitalWrite while DCS-BIOS is running, but I've not tried using them directly for DCS-BIOS outputs.

Link to comment
Share on other sites

many thanks for your input - it actually works with the Nano:

#define DCSBIOS_RS485_SLAVE 1
#define TXENABLE_PIN 2
#include "DcsBios.h"

DcsBios::LED clC1(0x10d4, 0x0100, 13);
DcsBios::LED clA1(0x10d4, 0x0001, 3);
DcsBios::LED clA2(0x10d4, 0x0002, 4);
DcsBios::LED clA3(0x10d4, 0x0004, 5);
DcsBios::LED clA4(0x10d4, 0x0008, 6);
DcsBios::LED clB1(0x10d4, 0x0010, 7);
DcsBios::LED clB2(0x10d4, 0x0020, 8);
DcsBios::LED clB3(0x10d4, 0x0040, 9);
DcsBios::LED clB4(0x10d4, 0x0080, 10);
DcsBios::LED clC2(0x10d4, 0x0200, 11);
DcsBios::LED clC3(0x10d4, 0x0400, 12);
DcsBios::LED clC4(0x10d4, 0x0800, 14);
DcsBios::LED clD1(0x10d4, 0x1000, 15);
DcsBios::LED clD2(0x10d4, 0x2000, 16);
DcsBios::LED clD3(0x10d4, 0x4000, 17);
DcsBios::LED clD4(0x10d4, 0x8000, 18);
DcsBios::LED clE1(0x10d6, 0x0001, 17);
DcsBios::LED clE2(0x10d6, 0x0002, 19);
DcsBios::LED clE3(0x10d6, 0x0004, 20);
DcsBios::LED clE4(0x10d6, 0x0008, 21);
void setup() {
 DcsBios::setup();
}

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

 

No random blinking of the internal LED. -> Isue SOLVED!

 

So, i guess i can get it to work with 3 Nano. However, it would interest me why it doesn't work with the Mega. Anyone has an idea?

Link to comment
Share on other sites

I've been struggling with a similar problem for the last couple of days. It only seems to happen with quite complex instruments (for me Ka50 PVI800, lots of buttons, LEDs, 7 seg displays etc)

 

Only occurs over RS485, not serial

 

I think I've tracked it down to a slight issue in the Arduino lib, specifically DcsBiosNgRS485Slave.cpp.inc. (not DcsBiosNgRS485Master.cpp.inc thanks doubleup)

 

case RX_WAIT_DATA:

rxtx_len--;

if (rx_datatype == RXDATA_DCSBIOS_EXPORT) {

parser.processCharISR©;

}

if (rxtx_len == 0) {

state = RX_WAIT_CHECKSUM;

}

 

The rx ISR has a section where a new byte is sent off to be processed. However, the ISR is reentrant, meaning that if a new byte is received before the previous one is processed, that too is added to the process queue.

The problem is that when the end of the message occurs, and the various export stream listeners are busy updating, the CRC byte can be received. And because the checking for the end of message relies on processCharISR returning, so it can check the rxtx_len and set to state to RX_WAIT_CHECKSUM, (it hasn't yet, still busy), the CRC also gets sent off to processCharISR, and the end of message is missed. rxtx_len is now 255, so now the next 255 'random' bytes get added to the incoming stream, resulting in some very weird updates.

 

The solution is to check and set the state correctly before processing the byte. ie swap the order of the 2 if statements in the RX_WAIT_DATA case.

 

case RX_WAIT_DATA:

rxtx_len--;

if (rxtx_len == 0) {

state = RX_WAIT_CHECKSUM;

}

if (rx_datatype == RXDATA_DCSBIOS_EXPORT) {

parser.processCharISR©;

}

 

Now, when the checksum byte comes in, it's correctly handled, even if processCharISR and processChar haven't finished yet.

 

This does the trick with RS485 for me. It's now rock solid. Perhaps try the above and see if it helps?


Edited by BoboBear
Wrong file
Link to comment
Share on other sites

I've been struggling with a similar problem for the last couple of days. It only seems to happen with quite complex instruments (for me Ka50 PVI800, lots of buttons, LEDs, 7 seg displays etc)

 

Only occurs over RS485, not serial

 

I think I've tracked it down to a slight issue in the Arduino lib, specifically DcsBiosNgRS485Master.cpp.inc.

 

case RX_WAIT_DATA:

rxtx_len--;

if (rx_datatype == RXDATA_DCSBIOS_EXPORT) {

parser.processCharISR©;

}

if (rxtx_len == 0) {

state = RX_WAIT_CHECKSUM;

}

 

The rx ISR has a section where a new byte is sent off to be processed. However, the ISR is reentrant, meaning that if a new byte is received before the previous one is processed, that too is added to the process queue.

The problem is that when the end of the message occurs, and the various export stream listeners are busy updating, the CRC byte can be received. And because the checking for the end of message relies on processCharISR returning, so it can check the rxtx_len and set to state to RX_WAIT_CHECKSUM, (it hasn't yet, still busy), the CRC also gets sent off to processCharISR, and the end of message is missed. rxtx_len is now 255, so now the next 255 'random' bytes get added to the incoming stream, resulting in some very weird updates.

 

The solution is to check and set the state correctly before processing the byte. ie swap the order of the 2 if statements in the RX_WAIT_DATA case.

 

case RX_WAIT_DATA:

rxtx_len--;

if (rxtx_len == 0) {

state = RX_WAIT_CHECKSUM;

}

if (rx_datatype == RXDATA_DCSBIOS_EXPORT) {

parser.processCharISR©;

}

 

Now, when the checksum byte comes in, it's correctly handled, even if processCharISR and processChar haven't finished yet.

 

This does the trick with RS485 for me. It's now rock solid. Perhaps try the above and see if it helps?

 

this exactly did the trick! only thing: one needs to update the code in DcsBiosNgRS485Slave.cpp.inc ; but that's just a detail.

 

it's so great this community! with that little change i don't have to redo the 48 LED connections :-)

Link to comment
Share on other sites

  • 3 months later...

All, after months and months of not being able to get even one RS485 device working, despite it working before then suddenly stopping, I have finally been able to make it work again.

 

It was not my wiring, circuits, chips or in fact any of the hardware at all that was causing the problem. Vlad333 on another post indicated recently that his stuff stopped working too, and that updating the Arduino IDE programmer (which forms part of the Arduino IDE program suit) resolved his problems.

 

Today, using the same hardware that had refused to work, I simply updated the Arduino IDE, reflashed the Arduino Mega master and Nano slave, and it just worked first time. No hassles, no issues, it just works. Finally! I had in my previous posts questioned whether it was a software issue, as no matter how hard I tried I could not see any fault in my hardware. I was wondering if the PC I was using for gaming was at fault, well it seems my suspicions where in the right area.

 

So for anyone like me that has found RS485 to be an enigma wrapped in an enema (sic), before you do anything else, make sure you have the latest version of the Arduino IDE, it can save you a lot of pain

 

Les

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Greetings to all and thank you for a most interesting post and conversation, I have been building some panels and getting up to speed with DCS-bios but now the time has come to go the "full monty" as they say and move from Mega's to RS485 Bus, maybe.......

 

I have some questions around the setup.

 

1. It was mentioned that you couldn't use a Mega as a Slave, this would seem to be an ideal solution due to the large number of output pins, is this still correct as of 2021?

1a. Can anyone explain as to why this is the case, as I have seen Uno's used as masters and slave in other IOT projects? is it specifically a 2560 mega issue?

2. In early post there is a picture from Han via Blue73 (I think)  around his left, right and front panels and all the nano's (4) used for Front, by my reckoning there aren't enough outputs available to run all the DDI/MPCD buttons and the combined switches etc, are you using mega's or something else for them?

3. Even using Nano's It seems to me that its going to be quite complicated and you are going to have the larger panels run by multiple nano's, I assume people find this ok?

4. Are there any other considerations around the USB use of Mega's as this always seemed to make more practicality to me as a mega still has approximately the same number of pins as 4 nano's? The only downside appears to be the USB requirements.

 

5. Slightly off topic, has anyone considered using the i-pac4 boards as an alternative, mind you they are a premium board along with associated costs.? but they appear to overcome

issues with USB bus. https://www.ultimarc.com/control-interfaces/i-pacs/i-pac4-board/

 

Regards to all and thanks for any replies.

Link to comment
Share on other sites

I cannot answer all your questions, but a few:

 

You can use a mega as a slave, although people seem to have problems with certain brands. Sadly i dont know which. My chinese megas work fine.

 

For DCS-BIOS over rs485 you need a mega for the master because it has 4 UARTS (one for the usb connection and one up to three for the rs485 busses), whereas the nanos and unos only have 1.

 

You can use more buttons on a nano if you use a button matrix. This works best with momentary pushbuttons. I think there is a way to use latched switches in a matrix but i did not figure out how.

 

As a dedicated tinkerer i like the low-cost of arduino clones and prefer pro-micros with mmjoy2 and shift registers over expensive boards for generic input devices. I just build a huey collective with this.

 

My a-10 cockpit contains 25 nanos and 6 megas as slaves and one mega as master with three rs-485 busses, one for the left console, one for the right console and one for the front panel.

Link to comment
Share on other sites

You are on the right track.

 

1. Megas can absolutely be used as slaves  .

 

As for the limited Nano pins there are several techniques that were used:

I2C bus, 74HC165 shift registers for inputs and 74HC595 SRs for output,Resistance ladders on analog channels clincrease number of possible inputs quite a bit. 

Anton.

 

My pit build thread .

Simple and cheap UFC project

Link to comment
Share on other sites

@crash test pilot and @agrasyuk - Greetings from down under (Australia) thanks for your prompt replies, really good to hear that others are experimenting and pushing the boundaries.

I am going to setup a Mega master and slave and see how things go, my goal is to keep the number of modules as low as possible and to organise them in a logical way. 

 

The Hornet Left and Right consoles seem pretty straight forward, but I'll have to think about the best way to divide up the Centre Console..... perhaps along similar lines, left side DDI's, Centre UFC/MPCD and Right Side instruments, not sure of the full number required, but I would think the whole cockpit could be done with maybe 6-7 megas?.... that might work.

 

Mega's can be had for about $15 AUD these days and Nano's are about $10, so a Mega would appear better value.... but for now I'll get a test rig setup, thanks again..... 🙂

 

Link to comment
Share on other sites

  • 2 months later...

Mr.Burns, try and look at this; https://easyeda.com/qrethus/arduino-nano-and-max487-chip-with-female-rj45-connector

I don't know who did it but there is a good chance he is here on the forum.

 

Alternatively talk to Tekkx. He might still be doing his breakout boards; 

In his signature there is a link for his hardware solution.

 

If you want to DIY then I suggest using the prototype PCB I used in the opening post; https://www.ebay.com/itm/Prototype-PCB-8-5-x-20cm-Universal-Matrix-Printed-Circuit-Board-Arduino-AVR/402615276324?_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D20160908105057%26meid%3D3e96f2c703cc4326b9c3c8210869fd83%26pid%3D100675%26rk%3D2%26rkt%3D15%26mehot%3Dnone%26sd%3D124513653639%26itm%3D402615276324%26pmt%3D1%26noa%3D1%26pg%3D2380057&_trksid=p2380057.c100675.m4236&_trkparms=pageci%3A108f0def-9a25-11eb-9356-a6bbe5552638|parentrq%3Abce6f0351780a7b21ce9e076fff7f5ce|iid%3A1

 

That way you don't have to solder directly on the pins for the MAX487 socket.

 

cheers

Solo

  • Like 1
Link to comment
Share on other sites

13 hours ago, Mr_Burns said:

Sorry about this, I was saying I struggle to make the RS485 board to use multiple Arduinos, does anyone know if they are made professionally by anyone?

 


might not meet the "professionally" requirement, but these are usable. how many do you need?

2v2a93P79xUHnUD.jpg


Edited by agrasyuk

Anton.

 

My pit build thread .

Simple and cheap UFC project

Link to comment
Share on other sites

They look awesome, thats the MAX487 chip inbetween VIN and TX1?

 

How do you sequence them?

 

Will need to work out how many, do you just get the boards and install the pins or can you get them ready made?

 

I really dont want to ask anyone to solder for me unless I am paying for it and they enjoy it or need it!

@agrasyuk


Edited by Mr_Burns
Link to comment
Share on other sites

32 minutes ago, Mr_Burns said:

They look awesome, thats the MAX487 chip inbetween VIN and TX1?

 

How do you sequence them?

 

Will need to work out how many, do you just get the boards and install the pins or can you get them ready made?

 

I really dont want to ask anyone to solder for me unless I am paying for it and they enjoy it or need it!

@agrasyuk

 

Yes. It's MAX485 in this particular instance, it will take 487 or course just the same. the R and the C are optional, works without them just fine in my case (for now)
I'm not sure what you mean by sequencing. all the boards sit on same bus, like the diagrams in post #2 show. 

I order arduino nano's, I order those PCBs , I solder the chip, the sockets and the headers.

I can supply you with the bare interface boards and you can solder everything yourself. if you need help I can solder, I'm not ecstatic about doing soldering jobs, but I don't hate 'em either.

 

 

PS,
Next step is getting away from those arduino nano's and making PCB for the Atmel microprocessor directly. I will get to it eventually. maybe 🙂 

Anton.

 

My pit build thread .

Simple and cheap UFC project

Link to comment
Share on other sites

  • Recently Browsing   0 members

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