Jump to content

My ARC-164 with Arduino, and it uses DCS-Bios.


Recommended Posts

This is my short album for some pics of my radio:

https://imgur.com/a/HIs1K

 

Here is the code I use to make the switches work. NOTE, I did not set the zero swithc, load, cover, status, test display or volume (I plan on doing the volume though). My wires aren't in any special order because I cable clustered them. I think I need to tidy it up a bit better, but it all works though.

 


#define DCSBIOS_IRQ_SERIAL
#include "DcsBios.h"
#include <LedControl.h>
/* This code is used on the Arduino Mega */

namespace DcsBios { /*  This is the begining of the code for the new switch class for the UHF Preset Select switch  */
 class Switch20Pos : PollingInput {
   private:
     const char* msg_;
     char pinA_;
     char pinB_;
     char pinC_;
     char pinD_;
     char pinE_;
     char lastState_;
     char readState() {
/*  set pin numbers:  */
const int switchPin1 = A1; // the number of the switch’s pin
const int switchPin2 = A2; 
const int switchPin3 = A3; 
const int switchPin4 = A4; 
const int switchPin5 = A5;
/*  set variables:  */
int switchState1 = 0; // variable for reading the switch’s status
int switchState2 = 0; 
int switchState3 = 0; 
int switchState4 = 0; 
int switchState5 = 0;
switchState1 = digitalRead(switchPin1);
switchState2 = digitalRead(switchPin2);
switchState3 = digitalRead(switchPin3);
switchState4 = digitalRead(switchPin4);
switchState5 = digitalRead(switchPin5);
    /*Channel*/                  /*Logic Table*/ 
       /*01*/   if (((switchState1 && switchState2 && switchState3 && switchState4) == HIGH ) && (switchState5 == LOW))    return 1;
       /*02*/   if (((switchState1 && switchState3 && switchState4) == HIGH ) && ((switchState2 or switchState5 ) == LOW)) return 2;
       /*03*/   if (((switchState1 && switchState3 && switchState4 && switchState5) == HIGH) && (switchState2 == LOW))     return 3;
       /*04*/   if (((switchState1 && switchState4 && switchState5) == HIGH) && ((switchState2 or switchState3)== LOW))    return 4;
       /*05*/   if (((switchState1 && switchState4) == HIGH) && ((switchState2 or switchState3 or switchState5)== LOW))    return 5;
       /*06*/   if (((switchState1 && switchState2 && switchState4) == HIGH) && ((switchState3 or switchState5)== LOW))    return 6;
       /*07*/   if (((switchState1 && switchState2 && switchState4 && switchState5) == HIGH) && (switchState3 == LOW))     return 7;
       /*08*/   if (((switchState2 && switchState4 && switchState5) == HIGH) && ((switchState1 or switchState3)== LOW))    return 8;
       /*09*/   if (((switchState2 && switchState4) == HIGH) && ((switchState1 or switchState3 or switchState5)== LOW))    return 9; 
       /*10*/   if ((switchState4 == HIGH) && ((switchState1 or switchState2 or switchState3 or switchState5)== LOW))      return 10;
       /*11*/   if (((switchState4 && switchState5)== HIGH) && ((switchState1 or switchState2 or switchState3)== LOW))     return 11;
       /*12*/   if (((switchState3 && switchState4 && switchState5)== HIGH) && ((switchState1 or switchState2)== LOW))     return 12;
       /*13*/   if (((switchState3 && switchState4)== HIGH) && ((switchState1 or switchState2 or switchState5)== LOW))     return 13;
       /*14*/   if (((switchState2 && switchState3 && switchState4)== HIGH) && ((switchState1 or switchState5)== LOW))     return 14;
       /*15*/   if (((switchState2 && switchState3 && switchState4 && switchState5)== HIGH) && (switchState1 == LOW))      return 15;
          
       
       return 00;
     }
     void pollInput() {
       char state = readState();
       if (state != lastState_) {
         if (state == 0)
           if (tryToSendDcsBiosMessage(msg_, "0"))
             lastState_ = state;
         if (state == 1)
           if (tryToSendDcsBiosMessage(msg_, "1"))
             lastState_ = state;
         if (state == 2)
           if (tryToSendDcsBiosMessage(msg_, "2"))
             lastState_ = state;
         if (state == 3)
           if (tryToSendDcsBiosMessage(msg_, "3"))
             lastState_ = state;
         if (state == 4)
           if (tryToSendDcsBiosMessage(msg_, "4"))
             lastState_ = state;
         if (state == 5)
           if (tryToSendDcsBiosMessage(msg_, "5"))
             lastState_ = state;
         if (state == 6)
           if (tryToSendDcsBiosMessage(msg_, "6"))
             lastState_ = state;
         if (state == 7)
           if (tryToSendDcsBiosMessage(msg_, "7"))
             lastState_ = state;
         if (state == 8)
           if (tryToSendDcsBiosMessage(msg_, "8"))
             lastState_ = state;
         if (state == 9)
           if (tryToSendDcsBiosMessage(msg_, "9"))
             lastState_ = state;
         if (state == 10)
           if (tryToSendDcsBiosMessage(msg_, "10"))
             lastState_ = state;
         if (state == 11)
           if (tryToSendDcsBiosMessage(msg_, "11"))
             lastState_ = state;
         if (state == 12)
           if (tryToSendDcsBiosMessage(msg_, "12"))
             lastState_ = state;
         if (state == 13)
           if (tryToSendDcsBiosMessage(msg_, "13"))
             lastState_ = state;
         if (state == 14)
           if(tryToSendDcsBiosMessage(msg_, "14"))
             lastState_ = state;
         if (state == 15)
           if (tryToSendDcsBiosMessage(msg_, "15"))
             lastState_ = state;
         if (state == 16)
           if (tryToSendDcsBiosMessage(msg_, "16"))
             lastState_ = state;
         if (state == 17)
           if (tryToSendDcsBiosMessage(msg_, "17"))
             lastState_ = state;
         if (state == 18)
           if (tryToSendDcsBiosMessage(msg_, "18"))
             lastState_ = state;
         if (state == 19)
           if(tryToSendDcsBiosMessage(msg_, "19"))
             lastState_ = state;
             
       
       }
     }
   public:
     Switch20Pos(const char* msg, char pinA, char pinB, char pinC, char pinD, char pinE) {
       msg_ = msg;
       pinA_ = pinA;
       pinB_ = pinB;
       pinC_ = pinC;
       pinD_ = pinD;
       pinE_ = pinE;
       
       pinMode(pinA_, INPUT_PULLUP);
       pinMode(pinB_, INPUT_PULLUP);
       pinMode(pinC_, INPUT_PULLUP);
       pinMode(pinD_, INPUT_PULLUP);
       pinMode(pinE_, INPUT_PULLUP);
       
       lastState_ = readState();
     }
 };
}  /* This concludes the code for the new 20 position switch for the UHF Preset Selector Switch */





// inputs: DIN pin, CLK pin, LOAD pin. number of chips
LedControl lc = LedControl(9, 11, 10, 1); /* These are on the PWM output on the Mega, it's okay to use them */
// lc.setChar(0, 6, 3, false);
//lc.setChar(0, 7, 2, false);
void onUhfFrequencyChange(char* newValue) { /*UHF display*/

  /* 0,1 = first MAX2719, digit to writ to on MAX2719 output; [0] is the first digit DCS transmits for the display */
 
  lc.setChar(0,1,newValue[0], false); /*DIGIT 1 "0,1"  should have been digit "0,0" but I soldered to wrong max2719 pin for digit 1 instead of digit 0 on the chip. */
  lc.setChar(0,2,newValue[1], false);
  lc.setChar(0,3,newValue[2], true);
  lc.setChar(0,4,newValue[2], false);
  lc.setChar(0,4,newValue[4], false);
  lc.setChar(0,5,newValue[5], false);
  lc.setChar(0,6,newValue[6], false);
}
DcsBios::StringBuffer<7> uhfFrequencyBuffer(0x1180, onUhfFrequencyChange); /*Channel presets*/

void onUhfPresetChange(char* newValue) {
  
  lc.setChar(0,7,newValue[0], false);
  lc.setChar(0,0,newValue[1], false); /*I just wrote the code to reuse digit 0 on the MAX2719 chip for the UHF Preset channel selector instead */
}
DcsBios::StringBuffer<2> uhfPresetBuffer(0x1188, onUhfPresetChange);

void onUhfPresetSelChange(char* newValue) {



}
DcsBios::StringBuffer<2> uhfPresetSelStrBuffer(0x1176, onUhfPresetSelChange);


/* ******VALIDATED LINE INCLUDING PINS, I soldered the pins and plugged them in randomly. Use serial monitor to see which ones are wired where. ****** */ 
const byte uhf10mhzSelPins[10] = {38, 40, 34, 42, 36, 46, 52, 50, 44, 48,}; 
DcsBios::SwitchMultiPos uhf10mhzSel("UHF_10MHZ_SEL", uhf10mhzSelPins, 10);

/* ******VALIDATED LINE INCLUDING PINS****** */ 
const byte uhf1mhzSelPins[10] = {37, 53, 47, 45, 49, 43, 51, 39, 41, 35};
DcsBios::SwitchMultiPos uhf1mhzSel("UHF_1MHZ_SEL", uhf1mhzSelPins, 10);

/* ******VALIDATED LINE INCLUDING PINS****** */ 
const byte uhfPoint1mhzSelPins[10] = {31, 26, 29, 27, 22, 30, 25, 24, 28, 23,};
DcsBios::SwitchMultiPos uhfPoint1mhzSel("UHF_POINT1MHZ_SEL", uhfPoint1mhzSelPins, 10);

/* ******VALIDATED LINE INCLUDING PINS****** */ 
DcsBios::Switch3Pos uhfTTone("UHF_T_TONE", A10, A9);

/*!!!!!!!!!!!!!!! not not NOT not NOT VALIDATED */ 
const byte uhf100mhzSelPins[3] = {5, 6, 7};
DcsBios::SwitchMultiPos uhf100mhzSel("UHF_100MHZ_SEL", uhf100mhzSelPins, 3);

/* ******VALIDATED LINE INCLUDING PINS****** */ 
const byte uhfPoint25SelPins[4] = {2, 8, 4, 3};
DcsBios::SwitchMultiPos uhfPoint25Sel("UHF_POINT25_SEL", uhfPoint25SelPins, 4);

const byte uhfFunctionPins[4] = {17, 14, 16, 15};
DcsBios::SwitchMultiPos uhfFunction("UHF_FUNCTION", uhfFunctionPins, 4);

DcsBios::Switch3Pos uhfMode("UHF_MODE",  20, 19);

DcsBios::Switch2Pos uhfSquelch("UHF_SQUELCH", A8);

DcsBios::Switch20Pos uhfPresetSel("UHF_PRESET_SEL", A1, A2, A3, A4, A5);

void setup() {
 DcsBios::setup();
 //This initializes the MAX7219 and gets it ready of use:
 lc.shutdown(0,false); //turn on the display
 lc.setIntensity(0,8);//set the brightness 
 lc.clearDisplay(0); //clear the display 
}


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

 

Also, if you look closely, I broke the traces on the PCB.


Edited by Trounce
adding extra comment
Link to comment
Share on other sites

About the code above, it seems that my preset selector switch might be busted, so I can only get 15 working channels out of it. Pin 4 always seems to be shorted to ground, so I can only get 16 bits of data 0-15 instead of the full 32 bits. Meh, 15 channels is completely usable and I'm happy.

 

Hardware: Arduino Mega (knockoff). Max2719 (for Common Cathode LED display) with resistor of 30K, two parallel capacitors of 10uF and 10nF.

I got the LED's displays from ebay. They are 3 digit displays common cathode.

The windows with the original display had to be slightly filed to accommodate these LED displays, but careful and slow filing with a jewelers file will do the trick nicely.


Edited by Trounce
Link to comment
Share on other sites

Thanks for the details.

I see you have directly interfaced into the rotary selectors and switches, even the preset channel selector, instead of using the male JP1 & 2 connectors.

The preset selector is an hexadecimal BCD selector switch: http://www.electro-nc.com/products/mmpindex.shtml You need the true table to make it work the 20 positions.

 

I'll try to make it work through the original connectors before soldering into the real part.

Cheers

Link to comment
Share on other sites

  • Recently Browsing   0 members

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