Add Support SDR Receiver and improve ATT

This commit is contained in:
phdlee 2018-04-07 21:32:01 +09:00
parent 23f1b7cd5c
commit 689cfda09e
3 changed files with 99 additions and 11 deletions

View File

@ -611,6 +611,34 @@ void WriteEEPRom_FT817(byte fromType)
Serial.write(ACK); Serial.write(ACK);
} }
const byte anlogPinIndex[6] = {A0, A1, A2, A3, A6, A7};
//Read ADC Value by uBITX Manager Software
void ReadADCValue(void)
{
//ADC MAP for uBITX
int readedADCValue;
//5BYTES
//CAT_BUFF[0] [1] [2] [3] [4] //4 COMMAND
//0 READ ADDRESS
readedADCValue = analogRead(anlogPinIndex[CAT_BUFF[0]]);
CAT_BUFF[0] = readedADCValue >> 8;
CAT_BUFF[1] = readedADCValue;
SendCatData(2);
Serial.write(ACK);
}
void SetIFSValue(void)
{
//Set IFShift Value
isIFShift = CAT_BUFF[0];
ifShiftValue = CAT_BUFF[1] + CAT_BUFF[2] * 256;
setFrequency(frequency);
SetCarrierFreq();
updateLine2Buffer(1); //option, perhap not need
Serial.write(ACK);
}
//void CatRxStatus(byte fromType) //void CatRxStatus(byte fromType)
void CatRxStatus(void) //for remove warning void CatRxStatus(void) //for remove warning
{ {
@ -768,6 +796,14 @@ void Check_Cat(byte fromType)
WriteEEPRom_FT817(fromType); WriteEEPRom_FT817(fromType);
break; break;
case 0xDD: //Read uBITX ADC Data
ReadADCValue(); //Call by uBITX Manager Program
break;
case 0xDE: //IF-Shift Control by CAT
SetIFSValue(); //
break;
case 0xE7 : //Read RX Status case 0xE7 : //Read RX Status
CatRxStatus(); CatRxStatus();
break; break;

View File

@ -10,7 +10,9 @@
//#define UBITX_DISPLAY_LCD2404P //24 x 04 LCD //#define UBITX_DISPLAY_LCD2404P //24 x 04 LCD
//#define UBITX_DISPLAY_LCD2404I //I2C type 24 x 04 LCD //#define UBITX_DISPLAY_LCD2404I //I2C type 24 x 04 LCD
//#define ENABLE_FACTORYALIGN //Compile Option
#define ENABLE_FACTORYALIGN
#define ENABLE_ADCMONITOR //Starting with Version 1.07, you can read ADC values directly from uBITX Manager. So this function is not necessary.
/** /**
@ -145,7 +147,12 @@ int count = 0; //to generally count ticks, loops, etc
#define CW_SIDETONE 24 #define CW_SIDETONE 24
#define CW_SPEED 28 #define CW_SPEED 28
//AT328 has 1KBytes EEPROM //KD8CEC EEPROM MAP
#define ADVANCED_FREQ_OPTION1 240 //Bit0: use IFTune_Value, Bit1 : use Stored enabled SDR Mode, Bit2 : dynamic sdr frequency
#define IF1_CAL 241
#define ENABLE_SDR 242
#define SDR_FREQUNCY 243
#define CW_CAL 252 #define CW_CAL 252
#define VFO_A_MODE 256 #define VFO_A_MODE 256
#define VFO_B_MODE 257 #define VFO_B_MODE 257
@ -327,10 +334,11 @@ unsigned char txFilter = 0; //which of the four transmit filters are in use
boolean modeCalibrate = false;//this mode of menus shows extended menus to calibrate the oscillators and choose the proper boolean modeCalibrate = false;//this mode of menus shows extended menus to calibrate the oscillators and choose the proper
//beat frequency //beat frequency
byte advancedFreqOption1; //255 : Bit0: use IFTune_Value, Bit1 : use Stored enabled SDR Mode, Bit2 : dynamic sdr frequency
byte attLevel = 0; //ATT : RF Gain Control (Receive) <-- IF1 Shift, 0 : Off, ShiftValue is attLevel * 100; attLevel 150 = 15K byte attLevel = 0; //ATT : RF Gain Control (Receive) <-- IF1 Shift, 0 : Off, ShiftValue is attLevel * 100; attLevel 150 = 15K
char if1TuneValue = 0; //0 : OFF, IF1 + if1TuneValue * 100; // + - 12500; char if1TuneValue = 0; //0 : OFF, IF1 + if1TuneValue * 100; // + - 12500;
byte sdrModeOn = 0; //SDR MODE ON / OFF byte sdrModeOn = 0; //SDR MODE ON / OFF
unsigned long SDR_Center_Freq = 32000000; unsigned long SDR_Center_Freq; //DEFAULT Frequency : 32000000
unsigned long beforeIdle_ProcessTime = 0; //for check Idle time unsigned long beforeIdle_ProcessTime = 0; //for check Idle time
byte line2DisplayStatus = 0; //0:Clear, 1 : menu, 1: DisplayFrom Idle, byte line2DisplayStatus = 0; //0:Clear, 1 : menu, 1: DisplayFrom Idle,
@ -501,12 +509,30 @@ void setFrequency(unsigned long f){
setTXFilters(f); setTXFilters(f);
unsigned long appliedCarrier = ((cwMode == 0 ? usbCarrier : cwmCarrier) + (isIFShift && (inTx == 0) ? ifShiftValue : 0)); unsigned long appliedCarrier = ((cwMode == 0 ? usbCarrier : cwmCarrier) + (isIFShift && (inTx == 0) ? ifShiftValue : 0));
long if1AdjustValue = ((inTx == 0) ? (attLevel * 200) : 0) + (if1TuneValue * 50); //if1Tune RX, TX Enabled, ATT : only RX Mode long if1AdjustValue = ((inTx == 0) ? (attLevel * 100) : 0) + (if1TuneValue * 100); //if1Tune RX, TX Enabled, ATT : only RX Mode
if (sdrModeOn && (inTx == 0)) //IF SDR if (sdrModeOn && (inTx == 0)) //IF SDR
{ {
si5351bx_setfreq(2, 44999500 + if1AdjustValue + f); //Fixed Frequency SDR (Default Frequency : 32Mhz, available change sdr Frequency by uBITX Manager)
si5351bx_setfreq(1, 44999500 + if1AdjustValue + SDR_Center_Freq + 2390); //Dynamic Frequency is for SWL without cat
//Offset Frequency + Mhz,
//Example : Offset Frequency : 30Mhz and current Frequncy is 7.080 => 37.080Mhz
// Offset Frequency : 30Mhz and current Frequncy is 14.074 => 34.074Mhz
//Dynamic Frequency
//if (advancedFreqOption1 & 0x04 != 0x00)
// if1AdjustValue += (f % 10000000);
si5351bx_setfreq(2, 44991500 + if1AdjustValue + f);
si5351bx_setfreq(1, 44991500
+ if1AdjustValue
+ SDR_Center_Freq
+ ((advancedFreqOption1 & 0x04) == 0x00 ? 0 : (f % 10000000))
+ 2390);
/*
si5351bx_setfreq(2, 44999500 + f);
si5351bx_setfreq(1, 44999500 + SDR_Center_Freq + 2390);
*/
} }
else else
{ {
@ -880,7 +906,7 @@ void initSettings(){
printLineF(1, F("Init EEProm...")); printLineF(1, F("Init EEProm..."));
//initial all eeprom //initial all eeprom
for (unsigned int i = 32; i < 1024; i++) //protect Master_cal, usb_cal for (unsigned int i = 64; i < 1024; i++) //protect Master_cal, usb_cal
EEPROM.write(i, 0); EEPROM.write(i, 0);
//Write Firmware ID //Write Firmware ID
@ -1033,6 +1059,25 @@ void initSettings(){
isIFShift = ifShiftValue != 0; isIFShift = ifShiftValue != 0;
} }
//Advanced Freq control
EEPROM.get(ADVANCED_FREQ_OPTION1, advancedFreqOption1);
//use Advanced Frequency Control
if (advancedFreqOption1 & 0x01 != 0x00)
{
EEPROM.get(IF1_CAL, if1TuneValue);
//Stored Enabled SDR Mode
if (advancedFreqOption1 & 0x02 != 0x00)
{
EEPROM.get(ENABLE_SDR, sdrModeOn);
}
}
EEPROM.get(SDR_FREQUNCY, SDR_Center_Freq);
if (SDR_Center_Freq == 0)
SDR_Center_Freq = 32000000;
//default Value (for original hardware) //default Value (for original hardware)
if (cwAdcSTFrom >= cwAdcSTTo) if (cwAdcSTFrom >= cwAdcSTTo)
{ {

View File

@ -290,6 +290,7 @@ void menuCHMemory(int btn, byte isMemoryToVfo){
//Analog pin monitoring with CW Key and function keys connected. //Analog pin monitoring with CW Key and function keys connected.
//by KD8CEC //by KD8CEC
#ifdef ENABLE_ADCMONITOR
void menuADCMonitor(int btn){ void menuADCMonitor(int btn){
int adcPinA0 = 0; //A0(BLACK, EncoderA) int adcPinA0 = 0; //A0(BLACK, EncoderA)
int adcPinA1 = 0; //A1(BROWN, EncoderB) int adcPinA1 = 0; //A1(BROWN, EncoderB)
@ -359,6 +360,7 @@ void menuADCMonitor(int btn){
menuClearExit(0); menuClearExit(0);
} }
#endif
//VFO Toggle and save VFO Information, modified by KD8CEC //VFO Toggle and save VFO Information, modified by KD8CEC
void menuVfoToggle(int btn) void menuVfoToggle(int btn)
@ -467,6 +469,7 @@ void menuSDROnOff(int btn)
printLineF2(F("[ON]")); printLineF2(F("[ON]"));
} }
EEPROM.put(ENABLE_SDR, sdrModeOn);
setFrequency(frequency); setFrequency(frequency);
menuClearExit(500); menuClearExit(500);
} }
@ -954,14 +957,14 @@ void menuATTSetup(int btn){
char needApplyChangeValue = 1; char needApplyChangeValue = 1;
if (!btn){ if (!btn){
if (isIFShift == 1) if (attLevel != 0)
printLineF2(F("ATT Change?")); printLineF2(F("ATT Change?"));
else else
printLineF2(F("ATT On?")); printLineF2(F("ATT On?"));
} }
else else
{ {
attLevel = getValueByKnob(5, attLevel, 0, 200, 5, "ATT", 2); //2 : (SetFrequency), targetValue, minKnobValue, maxKnobValue, stepSize attLevel = getValueByKnob(5, attLevel, 0, 250, 5, "ATT", 2); //2 : (SetFrequency), targetValue, minKnobValue, maxKnobValue, stepSize
delay_background(500, 0); //for check Long Press function key delay_background(500, 0); //for check Long Press function key
if (btnDown() || attLevel == 0) if (btnDown() || attLevel == 0)
@ -1229,7 +1232,7 @@ void doMenu(){
btnState = btnDown(); btnState = btnDown();
if (i > 0){ if (i > 0){
if (modeCalibrate && select + i < 240) if (modeCalibrate && select + i < 250)
select += i; select += i;
else if (!modeCalibrate && select + i < 150) else if (!modeCalibrate && select + i < 150)
select += i; select += i;
@ -1306,10 +1309,14 @@ void doMenu(){
case 21 : case 21 :
menuSetupKeyType(btnState); menuSetupKeyType(btnState);
break; break;
#ifdef ENABLE_ADCMONITOR
case 22 : case 22 :
menuADCMonitor(btnState); menuADCMonitor(btnState);
break; break;
case 23 : case 23 :
#else
case 22 :
#endif
menuTxOnOff(btnState, 0x01); //TX OFF / ON menuTxOnOff(btnState, 0x01); //TX OFF / ON
break; break;
default : default :