Jump to content

DCS-BIOS over RS485


Hansolo

Recommended Posts

On 7/28/2022 at 9:29 AM, No1sonuk said:

I powered my 487s with 5V from the arduino regulators.

Connected to the 5V pin means it gets power no matter how you power the arduino.

As for connecting DCS-BIOS: I regularly connect and disconnect USB-connected arduinos with no issues while a mission is running. I use the Flightpanels fork.  I don't know if the connection problems are related to the Hub version.

Thanks, i was considering that as well. If i read the datasheet correctly the MAX487CLA draws about 0.5mW so i guess it should be fine to power it like that. 

Link to comment
Share on other sites

On 7/28/2022 at 9:29 AM, No1sonuk said:

I powered my 487s with 5V from the arduino regulators.

Connected to the 5V pin means it gets power no matter how you power the arduino.

As for connecting DCS-BIOS: I regularly connect and disconnect USB-connected arduinos with no issues while a mission is running. I use the Flightpanels fork.  I don't know if the connection problems are related to the Hub version.

Im just starting out with DCS-BIOS, is the Flightpanels fork better? I’m building my own hardware, not using any off the shelf. 
 

Also, is anyone using DCS BIOS with all 3 RS485 buses at once? Im planning to use 1 bus per console and the third for the main instrument panel and saw an old post that its untested with more than 2. 


Edited by maciekish
Link to comment
Share on other sites

On 7/28/2022 at 10:29 AM, No1sonuk said:

I powered my 487s with 5V from the arduino regulators.

Connected to the 5V pin means it gets power no matter how you power the arduino.

As for connecting DCS-BIOS: I regularly connect and disconnect USB-connected arduinos with no issues while a mission is running. I use the Flightpanels fork.  I don't know if the connection problems are related to the Hub version.

How do you connect an Arduino to the Flightpanels fork? There seems to be no COM port settings... The page that talks about connecting your own Arduinos mentions connect-serial-port.cmd but there is no such file anywhere.


Edited by maciekish
Link to comment
Share on other sites

1 hour ago, maciekish said:

How do you connect an Arduino to the Flightpanels fork? There seems to be no COM port settings... The page that talks about connecting your own Arduinos mentions connect-serial-port.cmd but there is no such file anywhere.

 

It's in the dcs-bios-master\Programs folder

Link to comment
Share on other sites

44 minutes ago, No1sonuk said:

It's in the dcs-bios-master\Programs folder

dcs-bios-master as in the downloaded zip file? I have no Programs folder in there. Can you give a full path please? I know it wont be the same on my box but it will make it easier to locate. Thanks

Link to comment
Share on other sites

1 hour ago, maciekish said:

dcs-bios-master as in the downloaded zip file? I have no Programs folder in there. Can you give a full path please? I know it wont be the same on my box but it will make it easier to locate. Thanks

On my computer, that is the full path - I have DCS on a separate SSD.  E:\dcs-bios-master\Programs
Get the zip from here:
https://github.com/DCSFlightpanels/dcs-bios
There's an installation guide here:
https://github.com/DCSFlightpanels/dcs-bios/blob/master/Scripts/DCS-BIOS/doc/DCS-BIOS-FLIGHTPANELS_Install Guide.pdf

Link to comment
Share on other sites

7 minutes ago, No1sonuk said:

On my computer, that is the full path - I have DCS on a separate SSD.  E:\dcs-bios-master\Programs
Get the zip from here:
https://github.com/DCSFlightpanels/dcs-bios
There's an installation guide here:
https://github.com/DCSFlightpanels/dcs-bios/blob/master/Scripts/DCS-BIOS/doc/DCS-BIOS-FLIGHTPANELS_Install Guide.pdf

Im an idiot, i was using the wrong release. Found it now - thank you. 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

All, looking at my rig, most of the left console could be done either with a bodnar board or Arduinos. There are some OLED panels and the BCD switches that will need Arduinos though, so i was looking at using a Mega to drive all of it. I believe that Megas can be used as slaves on an RS485 network.  However there would be quite a few connections to make and it would be tricky to make tidy wiring for all of it to connect to just one mega. It would be impossible for me to make one PCB for all of it, I think the best I could do would be three, with one Arduino on each

Maybe three Uno boards would be better but I am not sure whether they can be used as slaves. They have enough pin connections to be able to do the job and drive the OLEDs but there's no point if they can't be used as slaves for the RS485 network 

So where can I find a list for compatibility for using as RS485 slaves so I can select the right Arduino?

 

Cheers 

Les

Link to comment
Share on other sites

The Megas are used as masters as they have more than one hardware UART, so the main one is used for the USB interface, and a second one is used for the RS485 network.
Unos, Nanos, etc. have only one hardware UART, and can be used as slaves on an RS485 network.
Unos and Nanos are electronically very similar, and the only programming differences relate to the different IO pin numbers and types available, so yes, Unos CAN be used as RS 485 slave devices.

Link to comment
Share on other sites

I think, that he wanted to know if Megas instead of Nanos/Unos could be used as slaves. I haven't tried that yet.

 

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

17 hours ago, Vinc_Vega said:

I think, that he wanted to know if Megas instead of Nanos/Unos could be used as slaves. I haven't tried that yet.

 

Regards, Vinc

 

He wrote "Maybe three Uno boards would be better but I am not sure whether they can be used as slaves."

To my mind, that's asking if Unos can be used as slaves. Particularly as the original examples in this thread are Nanos.

Link to comment
Share on other sites

Yes, basically it would good to know what can be used as slaves so that I can optimise the use of them. The more powerful arduinos can be used for multiple devices and inputs,  but clearly if they can't be used as slaves it renders them useless. I have some unos and a couple of megas in my box of bits

Cheers

Les

Link to comment
Share on other sites

Great, thanks! I'm hoping to be able to rationalise the devices to cut down on the sheer volume and numbers of wires, and in time go back to the ones I did on the right console to improve that. As you go further along with all this, you look back and realise that what seemed a good solution at the time is actually a long way from ideal, with the result that sometimes it takes me a while to work out how I wired something up.

It didn't help when I had that period during which the RS485 network refused to work and let me to make some fundamental changes to the design process; now I can correct that

Vinc has indicated a rather nice setup for the digital clock and standby attitude indicator using ESP32 devices, but apparently they do not support RS485. If I end up using it (very likely considering how good it looks) then I will need to use USB so anything that can be pushed to RS485 will help free up resources.  When I used just USB for all the gauges the lag and data refresh speed was appalling 

Cheers

Les

Link to comment
Share on other sites

Switches don't take up much time, but analogue devices take a while to read and convert the result, so it might help to separate gauge drivers from input devices. 
It might also help to split the gauges over a few devices, particularly if they're stepper driven.
Servo-driven gauges can be run from PWM outputs and/or dedicated drivers that can cut the Arduino processor overhead dramatically compared to stepper driving.

Link to comment
Share on other sites

Thanks - no gauges or analogue devices on the left console so at least that simplifies things there. Now you mentioned it, I remember that having an OLED display plus a guage running from a nano resulted in huge lag, basically made it unworkable.

As for the servo operated device, I may try that to see if it helps with the movement of the pointer for a couple of the gauges. Most don't move much when in operation, but some are more dynamic and I was always less than happy at the rather jerky movement. Maybe this is a way round it

Cheers

Les

Link to comment
Share on other sites

  • 4 weeks later...

Hi guys of the DCSBIOS church!

 

I have spent several days rigging an authentic YaDRO radio frequency selector to run in DCSBIOS. I used port registers and based it on another sketch I had helps with from @132nd.Hansolo some years ago. The sketch runs and I can use the mode knob, the volume (on a pot), and the squelch. But the frequency change dials are not active in DCS. However, SOCAT is showing all the correct numbers for 1MHz, 100KHz, and 10KHz. 1KHz and 100Hz are not working yet… So, any idea why it shows in SOCAT but not in sim?  Also, I have it running on RS485 network, but tested first as a serial, where the same issue arises.

Its frustrating, because its not a hardware issue. If I rewrite the code to check input from the device, the connections are all good. A similar sketch for ARK-15 and R-836 both work. So I am left wondering whether the issue is in DCS-BIOS and its communication with DCS. 

/*
  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_IRQ_SERIAL */
#define DCSBIOS_RS485_SLAVE 47

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

#include <DcsBios.h>

#include <timer.h>


Timer tm;

int DCS_valueDial_1; // JADRO 1MHZ Knob
int DCS_valueDial_2; // JADRO 100KHZ Knob
int DCS_valueDial_3; // JADRO 10KHZ Knob
int DCS_valueDial_4; // JADRO 1KHZ Knob
int DCS_valueDial_5; // JADRO 100HZ Knob

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

DcsBios::Potentiometer pltJadroVol("PLT_JADRO_VOL", A0);

DcsBios::Switch2Pos pltJadroTest("PLT_JADRO_TEST", 41);

DcsBios::Switch2Pos pltJadroSquelch("PLT_JADRO_SQUELCH", A4);

DcsBios::Switch3Pos pltJadroModul("PLT_JADRO_MODUL", A3, A2);

/////////////////////////

void onPltJadro1mChange(unsigned int newValue) {
    DCS_valueDial_1 = newValue;
}
DcsBios::IntegerBuffer pltJadro1mBuffer(0x69f8, 0x000f, 0, onPltJadro1mChange);

void onPltJadro100kChange(unsigned int newValue) {
    DCS_valueDial_2 = newValue;
}
DcsBios::IntegerBuffer pltJadro100kBuffer(0x69f8, 0x00f0, 4, onPltJadro100kChange);

void onPltJadro10kChange(unsigned int newValue) {
    DCS_valueDial_3 = newValue;
}
DcsBios::IntegerBuffer pltJadro10kBuffer(0x69f8, 0x0f00, 8, onPltJadro10kChange);

void onPltJadro1kChange(unsigned int newValue) {
    DCS_valueDial_4 = newValue;
}
DcsBios::IntegerBuffer pltJadro1kBuffer(0x69f8, 0xf000, 12, onPltJadro1kChange);

void onPltJadro100hChange(unsigned int newValue) {
    DCS_valueDial_5 = newValue;
}
DcsBios::IntegerBuffer pltJadro100hBuffer(0x69fc, 0x0f00, 8, onPltJadro100hChange);

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

  DDRC = B00000000; // DIAL 1 1MHZ
  PORTC = B00111111; // DIAL 1 Sets (digital 8-13) with internal pull up
  DDRK = B00000000; // DIAL 2 100KHZ(digital 8-13) as inputs
  PORTK = B00011111; // Sets (digital 8-13) with internal pull up
  DDRA = B00000000; // DIAL 3 10KHZ(digital 8-13) as inputs
  PORTA = B00011111; // Sets (digital 8-13) with internal pull up
  DDRL = B00000000; // DIAL 4 1KHZ
  PORTL = B00111111; // DIAL 1 Sets (digital 8-13) with internal pull up
  DDRB = B00000000; // DIAL 5 100HZ
  PORTB = B00111111; // DIAL 5 Sets (digital 8-13) with internal pull up

  
 tm.startTimer(1000, setDials);
 
}

// JADRO 1MHZ Knob//////////////////////
int inputDial_1()
{
  int valueDial_1;
  
  if (PINC == B00010110) {
    valueDial_1 = 2;
  }

  if (PINC == B00001100) {
    valueDial_1 = 3;
  }

  if (PINC == B00010100) {
    valueDial_1 = 4;
  }

  if (PINC == B00000110) {
    valueDial_1 = 5;
  }

  if (PINC == B00001010) {
    valueDial_1 = 6;
  }

  if (PINC == B00000011) {
    valueDial_1 = 7;
  }

  if (PINC == B00000101) {
    valueDial_1 = 8;
  }

  if (PINC == B00010001) {
    valueDial_1 = 9;
  }

  if (PINC == B00010010) {
    valueDial_1 = 10;
  }

   return valueDial_1;  
}

////////END OF 1MHZ knob


// JADRO 100KHZ Knob//////////////////////
int inputDial_2()
{
  int valueDial_2;

  if (PINK == B00010010) {
    valueDial_2 = 1;
  }

  if (PINK == B00011000) {
    valueDial_2 = 2;
  }

  if (PINK == B00010110) {
    valueDial_2 = 3;
  }

  if (PINK == B00001100) {
    valueDial_2 = 4;
  }

  if (PINK == B00010100) {
    valueDial_2 = 5;
  }

  if (PINK == B00000110) {
    valueDial_2 = 6;
  }

  if (PINK == B00001010) {
    valueDial_2 = 7;
  }

  if (PINK == B00000011) {
    valueDial_2 = 8;
  }

  if (PINK == B00000101) {
    valueDial_2 = 9;
  }

  if (PINK == B00010001) {
    valueDial_2 = 10;
  }

   return valueDial_2;  
}

////////END OF 100KHZ knob

// JADRO 10KHZ Knob//////////////////////
int inputDial_3()
{
  int valueDial_3;

  if (PINA == B00010010) {
    valueDial_3 = 1;
  }

  if (PINA == B00011000) {
    valueDial_3 = 2;
  }

  if (PINA == B00010110) {
    valueDial_3 = 3;
  }

  if (PINA == B00001100) {
    valueDial_3 = 4;
  }

  if (PINA == B00010100) {
    valueDial_3 = 5;
  }

  if (PINA == B00000110) {
    valueDial_3 = 6;
  }

  if (PINA == B00001010) {
    valueDial_3 = 7;
  }

  if (PINA == B00000011) {
    valueDial_3 = 8;
  }

  if (PINA == B00000101) {
    valueDial_3 = 9;
  }

  if (PINA == B00010001) {
    valueDial_3 = 10;
  }

   return valueDial_3;  
}

////////END OF 10KHZ knob

// JADRO 1KHZ Knob//////////////////////
int inputDial_4()
{
  int valueDial_4;

  if (PINL == B00010010) {
    valueDial_4 = 1;
  }

  if (PINL == B00011000) {
    valueDial_4 = 2;
  }

  if (PINL == B00010110) {
    valueDial_4 = 3;
  }

  if (PINL == B00001100) {
    valueDial_4 = 4;
  }

  if (PINL == B00010100) {
    valueDial_4 = 5;
  }

  if (PINL == B00000110) {
    valueDial_4 = 6;
  }

  if (PINL == B00001010) {
    valueDial_4 = 7;
  }

  if (PINL == B00000011) {
    valueDial_4 = 8;
  }

  if (PINL == B00000101) {
    valueDial_4 = 9;
  }

  if (PINL == B00010001) {
    valueDial_4 = 10;
  }

   return valueDial_4;  
}

////////END OF 1KHZ knob

// JADRO 100 HZ Knob//////////////////////
int inputDial_5()
{
  int valueDial_5;

  if (PINB == B00010010) {
    valueDial_5 = 1;
  }

  if (PINB == B00011000) {
    valueDial_5 = 2;
  }

  if (PINB == B00010110) {
    valueDial_5 = 3;
  }

  if (PINB == B00001100) {
    valueDial_5 = 4;
  }

  if (PINB == B00010100) {
    valueDial_5 = 5;
  }

  if (PINB == B00000110) {
    valueDial_5 = 6;
  }

  if (PINB == B00001010) {
    valueDial_5 = 7;
  }

  if (PINB == B00000011) {
    valueDial_5 = 8;
  }

  if (PINB == B00000101) {
    valueDial_5 = 9;
  }

  if (PINB == B00010001) {
    valueDial_5 = 10;
  }

   return valueDial_5;  
}

////////END OF 100 HZ knob


void loop() {
  DcsBios::loop();
    tm.runTimers(); 
}

void setDials(int timer){
  
  // Check and adjust selector dial 1MHZ
  if (DCS_valueDial_1 != inputDial_1()) {  
   
    
    if ( inputDial_1() == 2) {
      sendDcsBiosMessage("PLT_JADRO_1M", "2");
    }
    if ( inputDial_1() == 3) {
      sendDcsBiosMessage("PLT_JADRO_1M", "3");
    }
    if ( inputDial_1() == 4) {
      sendDcsBiosMessage("PLT_JADRO_1M", "4");
    }
    if ( inputDial_1() ==5) {
      sendDcsBiosMessage("PLT_JADRO_1M", "5");
    }
    if ( inputDial_1() == 6) {
      sendDcsBiosMessage("PLT_JADRO_1M", "6");
    }
    if ( inputDial_1() == 7) {
      sendDcsBiosMessage("PLT_JADRO_1M", "7");
    }
    if ( inputDial_1() == 8) {
      sendDcsBiosMessage("PLT_JADRO_1M", "8");
    }
    if ( inputDial_1() == 9) {
      sendDcsBiosMessage("PLT_JADRO_1M", "9");
    }
    if ( inputDial_1() == 10) {
      sendDcsBiosMessage("PLT_JADRO_1M", "10");
    }
    
  }


// Check and adjust selector dial 2 100KHZ
  if (DCS_valueDial_2 != inputDial_2()) {  

   
    if ( inputDial_2() == 1) {
      sendDcsBiosMessage("PLT_JADRO_100K", "0");
    }
    if ( inputDial_2() == 2) {
      sendDcsBiosMessage("PLT_JADRO_100K", "1");
    }
    if ( inputDial_2() == 3) {
      sendDcsBiosMessage("PLT_JADRO_100K", "2");
    }
    if ( inputDial_2() == 4) {
      sendDcsBiosMessage("PLT_JADRO_100K", "3");
    }
    if ( inputDial_2() == 5) {
      sendDcsBiosMessage("PLT_JADRO_100K", "4");
    }
    if ( inputDial_2() == 6) {
      sendDcsBiosMessage("PLT_JADRO_100K", "5");
    }
    if ( inputDial_2() == 7) {
      sendDcsBiosMessage("PLT_JADRO_100K", "6");
    }
    if ( inputDial_2() == 8) {
      sendDcsBiosMessage("PLT_JADRO_100K", "7");
    }
    if ( inputDial_2() == 9) {
      sendDcsBiosMessage("PLT_JADRO_100K", "8");
    }
    if ( inputDial_2() == 10) {
      sendDcsBiosMessage("PLT_JADRO_100K", "9");
    }
    
    
  }

  // Check and adjust selector dial 3 10 KHZ
  if (DCS_valueDial_3 != inputDial_3()) {  

   
    if ( inputDial_3() == 1) {
      sendDcsBiosMessage("PLT_JADRO_10K", "0");
    }
    if ( inputDial_3() == 2) {
      sendDcsBiosMessage("PLT_JADRO_10K", "1");
    }
    if ( inputDial_3() == 3) {
      sendDcsBiosMessage("PLT_JADRO_10K", "2");
    }
    if ( inputDial_3() == 4) {
      sendDcsBiosMessage("PLT_JADRO_10K", "3");
    }
    if ( inputDial_3() == 5) {
      sendDcsBiosMessage("PLT_JADRO_10K", "4");
    }
    if ( inputDial_3() == 6) {
      sendDcsBiosMessage("PLT_JADRO_10K", "5");
    }
    if ( inputDial_3() == 7) {
      sendDcsBiosMessage("PLT_JADRO_10K", "6");
    }
    if ( inputDial_3() == 8) {
      sendDcsBiosMessage("PLT_JADRO_10K", "7");
    }
    if ( inputDial_3() == 9) {
      sendDcsBiosMessage("PLT_JADRO_10K", "8");
    }
    if ( inputDial_3() == 10) {
      sendDcsBiosMessage("PLT_JADRO_10K", "9");
    }
    
    
  }

  // Check and adjust selector dial 4 1KHZ
  if (DCS_valueDial_4 != inputDial_4()) {  

   
    if ( inputDial_4() == 1) {
      sendDcsBiosMessage("PLT_JADRO_1K", "0");
    }
    if ( inputDial_4() == 2) {
      sendDcsBiosMessage("PLT_JADRO_1K", "1");
    }
    if ( inputDial_4() == 3) {
      sendDcsBiosMessage("PLT_JADRO_1K", "2");
    }
    if ( inputDial_4() == 4) {
      sendDcsBiosMessage("PLT_JADRO_1K", "3");
    }
    if ( inputDial_4() == 5) {
      sendDcsBiosMessage("PLT_JADRO_1K", "4");
    }
    if ( inputDial_4() == 6) {
      sendDcsBiosMessage("PLT_JADRO_1K", "5");
    }
    if ( inputDial_4() == 7) {
      sendDcsBiosMessage("PLT_JADRO_1K", "6");
    }
    if ( inputDial_4() == 8) {
      sendDcsBiosMessage("PLT_JADRO_1K", "7");
    }
    if ( inputDial_4() == 9) {
      sendDcsBiosMessage("PLT_JADRO_1K", "8");
    }
    if ( inputDial_4() == 10) {
      sendDcsBiosMessage("PLT_JADRO_1K", "9");
    }
    
    
  }

  // Check and adjust selector dial 5 100 HZ
  if (DCS_valueDial_5 != inputDial_5()) {  

   
    if ( inputDial_5() == 1) {
      sendDcsBiosMessage("PLT_JADRO_100H", "0");
    }
    if ( inputDial_5() == 2) {
      sendDcsBiosMessage("PLT_JADRO_100H", "1");
    }
    if ( inputDial_5() == 3) {
      sendDcsBiosMessage("PLT_JADRO_100H", "2");
    }
    if ( inputDial_5() == 4) {
      sendDcsBiosMessage("PLT_JADRO_100H", "3");
    }
    if ( inputDial_5() == 5) {
      sendDcsBiosMessage("PLT_JADRO_100H", "4");
    }
    if ( inputDial_5() == 6) {
      sendDcsBiosMessage("PLT_JADRO_100H", "5");
    }
    if ( inputDial_5() == 7) {
      sendDcsBiosMessage("PLT_JADRO_100H", "6");
    }
    if ( inputDial_5() == 8) {
      sendDcsBiosMessage("PLT_JADRO_100H", "7");
    }
    if ( inputDial_5() == 9) {
      sendDcsBiosMessage("PLT_JADRO_100H", "8");
    }
    if ( inputDial_5() == 10) {
      sendDcsBiosMessage("PLT_JADRO_100H", "9");
    }
    
    
  }
}

 

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

2 hours ago, molevitch said:

Hi guys of the DCSBIOS church!

 

I have spent several days rigging an authentic YaDRO radio frequency selector to run in DCSBIOS. I used port registers and based it on another sketch I had helps with from @132nd.Hansolo some years ago. The sketch runs and I can use the mode knob, the volume (on a pot), and the squelch. But the frequency change dials are not active in DCS. However, SOCAT is showing all the correct numbers for 1MHz, 100KHz, and 10KHz. 1KHz and 100Hz are not working yet… So, any idea why it shows in SOCAT but not in sim?  Also, I have it running on RS485 network, but tested first as a serial, where the same issue arises.

Its frustrating, because its not a hardware issue. If I rewrite the code to check input from the device, the connections are all good. A similar sketch for ARK-15 and R-836 both work. So I am left wondering whether the issue is in DCS-BIOS and its communication with DCS. 

The returned variables from your port reads (valueDial_1, etc) are unique, so you could make them global and reduce the read cycles - each of your "if" statements in setDials reads the port.
You could read the port once, convert the input combination to a number,  then compare the global variable to the value from DCS and send the correction if it's different.

e.g.

Assign global variables:

int valueDial_1;
int valueDial_2;
int valueDial_3;
int valueDial_4;
int valueDial_5;

Then inputDial_1 becomes:

// JADRO 1MHZ Knob//////////////////////
void inputDial_1()
{
  int valueDial = PINC; // temporary int for port conversion
  
  if (valueDial == B00010110) {
    valueDial_1 = 2;  // Set the global variable
  }

  if (valueDial == B00001100) {
    valueDial_1 = 3;
  }

  if (valueDial == B00010100) {
    valueDial_1 = 4;
  }

  if (valueDial == B00000110) {
    valueDial_1 = 5;
  }

  if (valueDial == B00001010) {
    valueDial_1 = 6;
  }

  if (valueDial == B00000011) {
    valueDial_1 = 7;
  }

  if (valueDial == B00000101) {
    valueDial_1 = 8;
  }

  if (valueDial == B00010001) {
    valueDial_1 = 9;
  }

  if (valueDial == B00010010) {
    valueDial_1 = 10;
  }

}

////////END OF 1MHZ knob

Set the other dial globals in the same way.
Then the beginning of setDials becomes this:

void setDials(int timer){

  inputDial_1();  // Read the dials
  inputDial_2();
  inputDial_3();
  inputDial_4();
  inputDial_5();
  
  // Check and adjust selector dial 1MHZ
  if (DCS_valueDial_1 != valueDial_1) {    // use the global variables
       
    if ( valueDial_1 == 2) {
      sendDcsBiosMessage("PLT_JADRO_1M", "2");
    }
    if ( valueDial_1 == 3) {
      sendDcsBiosMessage("PLT_JADRO_1M", "3");
    }
    if ( valueDial_1 == 4) {
      sendDcsBiosMessage("PLT_JADRO_1M", "4");
    }
    if ( valueDial_1 ==5) {
      sendDcsBiosMessage("PLT_JADRO_1M", "5");
    }
    if ( valueDial_1 == 6) {
      sendDcsBiosMessage("PLT_JADRO_1M", "6");
    }
    if ( valueDial_1 == 7) {
      sendDcsBiosMessage("PLT_JADRO_1M", "7");
    }
    if ( valueDial_1 == 8) {
      sendDcsBiosMessage("PLT_JADRO_1M", "8");
    }
    if ( valueDial_1 == 9) {
      sendDcsBiosMessage("PLT_JADRO_1M", "9");
    }
    if ( valueDial_1 == 10) {
      sendDcsBiosMessage("PLT_JADRO_1M", "10");
    }
    
//  And so on...

Primarily, only programme one of the dials first.  Get that working, then move onto the next.  There's no point putting all five dials' code in if you have to keep changing it to get it going.
Do one.  Fix it, then write the others.
  


 

Link to comment
Share on other sites

Thank you @No1sonuk! I am no Arduino code expert, and mostly get by with simple stuff. As I say, Hansolo helped me with this, and the method works perfectly for ARK-15 and R-863. I managed to get my head around the port register thing, and the whole soldering/wiring thing, (I am an artist/designer/fabricator by trade…) but getting coding logic and efficiency down proves challenging!

I totally agree with your “Do one. Fix it” method. But I had started with a full sketch which I thought simply needed a few codes, numbers and messages changing…. WRONG!

I will take a look at your suggestions today and tell you how it goes. 

Thank you!


Edited by molevitch
  • Like 1

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

6 minutes ago, No1sonuk said:

It's possible it might be the port reading that is the issue.

Also, the switch wiring combinations are odd. I'd have thought they'd be some form of binary coded decimal or somesuch. Do you have a part number for a switch?

Hi No1sonuk,

Thanks again for your kind help with this. 

Part number for the switch.... This is a piece of Soviet era tech, using a mixture of clockwork dials and cogs, in combination with some analogue switch mechanisms. There are 6 contacts and a common. These contacts are individual switches on/off, up/down, live/dead, (pick your definition!), depending on the brass contacts on the wheel turned by turning the dial. Think wind up clockwork music box...Those 7 brass springs (inside the red box) are used to output a 6 digit binary code. Hence my numbers like 00010110. These outputs have been read by multimeter for continuity by pin. Each switch set per dial uses the same codes thankfully, outputting a number 0-9. In the case of the 1MHz dial, there is an extra switch set (far right in pic) which has only 2 pins, and is mechanically driven by the clockwork to give a 0 or 10, to roll from 2 MHz up to 17MHz. 

So, in terms of port reading, I sort of expect it to work, as a very similar system is used in the (also authentic soviet) ARC-15 and R-863 channel selector. All mechanical clockwork with brass pins and analogue switches. 

I coulda stripped out all the stuff in the back and rigged up some rotary encoders, but I love all the original artistry and engineering in the back, plus it retains the feel and sound of the clicks etc.

I ran a test sketch using the Arduino pins as simple inputs, not as port register, and I get correct outputs, eg (pseudo) {Increase 1MHz by 1, (pin) A0}. And as I say, in SOCAT the correct numbers are showing in the stream of data, but not going to DCS....

jadro back.jpg

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

34 minutes ago, No1sonuk said:

It's possible it might be the port reading that is the issue.

Also, the switch wiring combinations are odd. I'd have thought they'd be some form of binary coded decimal or somesuch. Do you have a part number for a switch?

Also, looking into the DCS-BIOS Mi-24P.lua, I see that the lines for the ARC-15 dials and the JADRO dials use different switch types.

defineFixedStepTumb("PLT_JADRO_100K", 50, 3007, 436, 0.1, {0, 1}, {-0.1, 0.1}, {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}, "Jadro-1I", "PILOT Jadro-1I Frequency 100KHz")
defineMultipositionSwitch("PLT_ARC_FREQ_R_100", 47, 3007, 464, 18, 1/17, "ARC-15 PLT", "PILOT ARC-15 Right Frequency 100KHz")

Maybe this has an impact on the sketch...?


 

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

14 minutes ago, molevitch said:

I ran a test sketch using the Arduino pins as simple inputs, not as port register, and I get correct outputs, eg (pseudo) {Increase 1MHz by 1, (pin) A0}. And as I say, in SOCAT the correct numbers are showing in the stream of data, but not going to DCS....

 

Ah, OK.  So if the expected DCS-BIOS messages are being sent, it might be the control reference messages to DCS conversions themselves are wrong.  That might be a DCS_BIOS script coding issue, and I don't know it works.
Which version of DCS-BIOS are you using?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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