Ejemplo n.º 1
0
        public void RunCalFWCRXLevel()
        {
            double      vfoa = console.VFOAFreq;
            double      vfob = console.VFOBFreq;
            HiPerfTimer t1   = new HiPerfTimer();

            t1.Start();
            Band[]  bands      = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f };

            for (int i = 0; i < band_freqs.Length; i++)
            {
                bool do_band = false;
                switch (bands[i])
                {
                case Band.B160M: do_band = chk160.Checked; break;

                case Band.B80M: do_band = chk80.Checked; break;

                case Band.B60M: do_band = chk60.Checked; break;

                case Band.B40M: do_band = chk40.Checked; break;

                case Band.B30M: do_band = chk30.Checked; break;

                case Band.B20M: do_band = chk20.Checked; break;

                case Band.B17M: do_band = chk17.Checked; break;

                case Band.B15M: do_band = chk15.Checked; break;

                case Band.B12M: do_band = chk12.Checked; break;

                case Band.B10M: do_band = chk10.Checked; break;

                case Band.B6M: do_band = chk6.Checked; break;
                }

                if (do_band)
                {
                    progress.SetPercent(0.0f);
                    Invoke(new MethodInvoker(progress.Show));
                    Application.DoEvents();
                    console.VFOAFreq = band_freqs[i];
                    console.VFOBFreq = band_freqs[i];
                    console.CalibrateLevel(-24.0f, band_freqs[i], progress);
                    if (progress.Text == "")
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }
            }
            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;
            btnCalRXLevelAllBands.BackColor = SystemColors.Control;
            grpAllBands.Enabled             = true;
            t1.Stop();
            Debug.WriteLine("RX Level Timer: " + t1.Duration);
        }
Ejemplo n.º 2
0
        } // btneepromread1_click

        private void btnTune_Click(object sender, EventArgs e)
        {
            if (txtTune.Text == "")
            {
                return;
            }

            double freq;
            bool   b = double.TryParse(txtTune.Text, out freq);

            if (!b)
            {
                return;
            }

            uint ftw = (uint)(Math.Pow(2.0, 32) * freq * 2 / 384.0);

            HiPerfTimer t1 = new HiPerfTimer();

            t1.Start();

            int val = USBHID.SetFreqTW(ftw);

            t1.Stop();
            Debug.WriteLine("Tune: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 3
0
        private void btnEEWrite_Click(object sender, EventArgs e)
        {
            ushort offset    = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber);
            byte   num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber);

            if (num_bytes > txtData.Text.Length / 2)
            {
                MessageBox.Show("Error: Not enough data");
                return;
            }

            byte[] data = new byte[num_bytes];
            for (int i = 0; i < num_bytes; i++)
            {
                data[i] = byte.Parse(txtData.Text.Substring(i * 2, 2), NumberStyles.HexNumber);
            }

            HiPerfTimer t1 = new HiPerfTimer();

            t1.Start();

            int val;

            //fixed(byte* ptr = &data[0])
            val = Flex1500.WriteEEPROM(offset, data);

            t1.Stop();
            Debug.WriteLine("EEWrite: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 4
0
        private void btnEERead_Click(object sender, EventArgs e)
        {
            ushort offset    = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber);
            byte   num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber);

            byte[] data;

            HiPerfTimer t1 = new HiPerfTimer();

            t1.Start();

            int val;

            val = Flex1500.ReadEEPROM(offset, num_bytes, out data);

            t1.Stop();

            txtEERead.Text = "";
            for (int i = 0; i < num_bytes; i++)
            {
                txtEERead.Text += data[i].ToString("X").PadLeft(2, '0');
            }

            Debug.WriteLine("EERead: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 5
0
        private void CalFWCPABridge()
        {
            double      vfoa = console.VFOAFreq;
            double      vfob = console.VFOBFreq;
            HiPerfTimer t1   = new HiPerfTimer();

            t1.Start();
            Band[]  bands      = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f };
            for (int i = 0; i < band_freqs.Length; i++)
            {
                bool do_band = false;
                switch (bands[i])
                {
                case Band.B160M: do_band = chk160.Checked; break;

                case Band.B80M: do_band = chk80.Checked; break;

                case Band.B60M: do_band = chk60.Checked; break;

                case Band.B40M: do_band = chk40.Checked; break;

                case Band.B30M: do_band = chk30.Checked; break;

                case Band.B20M: do_band = chk20.Checked; break;

                case Band.B17M: do_band = chk17.Checked; break;

                case Band.B15M: do_band = chk15.Checked; break;

                case Band.B12M: do_band = chk12.Checked; break;

                case Band.B10M: do_band = chk10.Checked; break;

                case Band.B6M: do_band = chk6.Checked; break;
                }

                if (do_band)
                {
                    console.VFOAFreq = band_freqs[i];
                    console.CalibratePABridge(progress);
                    if (progress.Text == "")
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }
            }
            console.VFOAFreq         = vfoa;
            console.VFOBFreq         = vfob;
            btnCalPABridge.BackColor = SystemColors.Control;
            grpAllBands.Enabled      = true;
            btnCalPABridge.Enabled   = true;
        }
Ejemplo n.º 6
0
        private void btnGPIOWrite3_Click(object sender, EventArgs e)
        {
            HiPerfTimer t1 = new HiPerfTimer();

            t1.Start();

            byte b;
            int  val = USBHID.ReadGPIO(out b);

            t1.Stop();
            Debug.WriteLine("GPIO3: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
            txtGPIOResult.Text = b.ToString("X");
        }
Ejemplo n.º 7
0
        private void btnGPIOWrite1_Click(object sender, EventArgs e)
        {
            byte b = byte.Parse(txtGPIOByte.Text, NumberStyles.HexNumber);

            HiPerfTimer t1 = new HiPerfTimer();

            t1.Start();

            int val = USBHID.WriteGPIO(b);

            t1.Stop();
            Debug.WriteLine("GPIO1: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 8
0
        /*private bool WriteTWBoundary(double freq, bool xref, uint ee_offset)
         * {
         *  double clock = 384.0;
         *  if(xref) clock = 400.0;
         *
         *  uint tw = (uint)(Math.Pow(2.0, 32) * freq * 2 / clock);
         *  tw = SwapBytes(tw);
         *
         *  uint check_tw = 0;
         *  int count = 0;
         *  do
         *  {
         *      count++;
         *      Flex1500.WriteTRXEEPROMUint(ee_offset, tw);
         *      Thread.Sleep(10);
         *      Flex1500.ReadTRXEEPROMUint(ee_offset, out check_tw);
         *  } while(check_tw != tw && count < 10);
         *
         *  if(count == 10) return false;
         *  else return true;
         * }*/

        private void btnI2CWrite1_Click(object sender, EventArgs e)
        {
            byte addr = byte.Parse(txtI2CAddr.Text, NumberStyles.HexNumber);
            byte b1   = byte.Parse(txtI2CByte1.Text, NumberStyles.HexNumber);

            HiPerfTimer t1 = new HiPerfTimer();

            t1.Start();

            int val = USBHID.WriteI2CValue(addr, b1);

            t1.Stop();
            Debug.WriteLine("I2C1: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 9
0
        /*
         * private void PTT(bool state)
         * {
         *  if (state)
         *  {
         *      butPTT.BackColor = Color.GreenYellow;
         *  }
         *  else
         *  {
         *      butPTT.BackColor = SystemColors.Control;
         *  }
         * }
         *
         * private void FlexPTT(bool state)
         * {
         *  if (state)
         *  {
         *      butFlexPTT.BackColor = Color.GreenYellow;
         *  }
         *  else
         *  {
         *      butFlexPTT.BackColor = SystemColors.Control;
         *  }
         * }
         *
         * private void Dash(bool state)
         * {
         *  if (state)
         *  {
         *      butDash.BackColor = Color.GreenYellow;
         *  }
         *  else
         *  {
         *      butDash.BackColor = SystemColors.Control;
         *  }
         *  ToggleTones();
         * }
         *
         * private void Dot(bool state)
         * {
         *  if (state)
         *  {
         *      butDot.BackColor = Color.GreenYellow;
         *  }
         *  else
         *  {
         *      butDot.BackColor = SystemColors.Control;
         *  }
         *  ToggleTones();
         * }
         *
         * private void ToggleTones()
         * {
         *  if (tone1 == 350.0f)
         *  {
         *      tone1 = 941.0f;
         *      tone2 = 1209.0f;
         *  }
         *  else
         *  {
         *      tone1 = 350.0f;
         *      tone2 = 440.0f;
         *  }
         * }
         */
        private void btnWrite_Click(object sender, EventArgs e)
        {
            uint op = uint.Parse(txtOpcode.Text);
            uint p1 = uint.Parse(txtParam1.Text, NumberStyles.HexNumber);
            uint p2 = uint.Parse(txtParam2.Text, NumberStyles.HexNumber);

            HiPerfTimer t1 = new HiPerfTimer();

            t1.Start();

            int val = Flex1500.WriteOp((USBHID.Opcode)op, p1, p2);

            t1.Stop();
            Debug.WriteLine("WriteOp: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 10
0
        private void btnI2CRead_Click(object sender, EventArgs e)
        {
            byte addr = byte.Parse(txtI2CAddr.Text, NumberStyles.HexNumber);
            byte b1   = byte.Parse(txtI2CByte1.Text, NumberStyles.HexNumber);
            byte b2;

            HiPerfTimer t1 = new HiPerfTimer();

            t1.Start();

            int val = USBHID.ReadI2CValue(addr, b1, out b2);

            t1.Stop();
            Debug.WriteLine("I2C Read: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
            txtI2CResult.Text = b2.ToString("X").PadLeft(2, '0');
        }
Ejemplo n.º 11
0
        private void btnEEReadFloat_Click(object sender, EventArgs e)
        {
            ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber);
            //byte num_bytes = 4;

            HiPerfTimer t1 = new HiPerfTimer();

            t1.Start();

            int val;

            byte[] temp = new byte[4];
            val = Flex1500.ReadEEPROM((ushort)offset, 4, out temp);
            float f = BitConverter.ToSingle(temp, 0);

            t1.Stop();

            txtEERead.Text = f.ToString("f6");

            Debug.WriteLine("EERead Float: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 12
0
        public void KeyThread()
        {
            //SetThreadAffinity(1);
            bool extkey_dash, extkey_dot, keyprog;

            do
            {
                DttSP.KeyerStartedWait();
                for (; DttSP.KeyerRunning();)
                {
                    keyprog = false;
                    timer.Start();
                    DttSP.PollTimerWait();
                    switch (primary_conn_port)
                    {
                    case "SDR":
                        byte b = hw.StatusPort();
                        extkey_dash = ((b & (byte)StatusPin.Dash) != 0);
                        extkey_dot  = ((b & (byte)StatusPin.Dot) != 0);
                        break;

                    case "Radio":
                        extkey_dot  = fwc_dot;
                        extkey_dash = fwc_dash;
                        break;

                    default:                             // COM port
                        extkey_dash = sp.CtsHolding;
                        extkey_dot  = sp.DsrHolding;
                        break;
                    }

                    // handle CWX
                    if (!extkey_dash && !extkey_dot)
                    {
                        if (memoryptt)
                        {
                            //console ptt on
                            keyprog    = true;
                            extkey_dot = extkey_dash = memorykey;
                        }
                        else
                        {
                            //console ptt off
                            keyprog = false;
                        }
                    }

                    if (!extkey_dash && !extkey_dot)                     // don't override primary
                    {
                        switch (secondary_conn_port)
                        {
                        case "None":
                            break;

                        case "CAT":
                            switch (secondary_ptt_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = siolisten.SIO.isDSR();
                                }
                                else
                                {
                                    extkey_dot = siolisten.SIO.isCTS();
                                }
                                break;

                            case KeyerLine.DTR:                                     // look at DSR since we are on the other side of the null modem cable
                                keyerptt = siolisten.SIO.isDSR();
                                //										extkey_dot = System.Convert.ToByte(sp2.CtsHolding);
                                break;

                            case KeyerLine.RTS:                                     // look at CTS since we are on the other side of the null modem cable
                                keyerptt = siolisten.SIO.isCTS();
                                //										extkey_dash  = System.Convert.ToByte(sp2.DsrHolding);
                                break;
                            }

                            switch (secondary_key_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = siolisten.SIO.isDSR();
                                }
                                else
                                {
                                    extkey_dot = siolisten.SIO.isCTS();
                                }
                                break;

                            case KeyerLine.DTR:                                     // look at DSR since we are on the other side of the null modem cable
                                extkey_dot = siolisten.SIO.isDSR();
                                //										Debug.WriteLine("extkey_dot: "+extkey_dot);
                                break;

                            case KeyerLine.RTS:                                     // look at CTS since we are on the other side of the null modem cable
                                extkey_dash = siolisten.SIO.isCTS();
                                break;
                            }

                            //								if (extkey_dash || extkey_dot)
                            //									keyprog = true;
                            //								else keyprog = false;
                            //								//Debug.WriteLine("keyprog: "+keyprog);
                            break;

#if false
                        // wjtFIXME!! - merged from KD5TFD's HPSDR 1.6.3 tree - sr xmit
                        case "BB-PTT":
                            Console c = Console.getConsole();


                            if ((extkey_dash == 0) && (extkey_dot == 0))                           // don't override primary
                            {
                                switch (secondary_ptt_line)
                                {
                                case KeyerLine.NONE:
                                    if (sp2dotkey)
                                    {
                                        extkey_dash = System.Convert.ToByte(c.serialPTT.isDSR());
                                    }
                                    else
                                    {
                                        extkey_dot = System.Convert.ToByte(c.serialPTT.isCTS());
                                    }
                                    break;

                                case KeyerLine.DTR:                                         // look at DSR since we are on the other side of the null modem cable
                                    keyerptt = c.serialPTT.isDSR();
                                    //										extkey_dot = System.Convert.ToByte(sp2.CtsHolding);
                                    break;

                                case KeyerLine.RTS:                                         // look at CTS since we are on the other side of the null modem cable
                                    keyerptt = c.serialPTT.isCTS();
                                    //										extkey_dash  = System.Convert.ToByte(sp2.DsrHolding);
                                    break;
                                }

                                switch (secondary_key_line)
                                {
                                case KeyerLine.NONE:
                                    if (sp2dotkey)
                                    {
                                        extkey_dash = System.Convert.ToByte(c.serialPTT.isDSR());
                                    }
                                    else
                                    {
                                        extkey_dot = System.Convert.ToByte(c.serialPTT.isCTS());
                                    }
                                    break;

                                case KeyerLine.DTR:                                         // look at DSR since we are on the other side of the null modem cable
                                    extkey_dot = System.Convert.ToByte(c.serialPTT.isDSR());
                                    //										Debug.WriteLine("extkey_dot: "+extkey_dot);
                                    break;

                                case KeyerLine.RTS:                                         // look at CTS since we are on the other side of the null modem cable
                                    extkey_dash = System.Convert.ToByte(c.serialPTT.isCTS());
                                    break;
                                }

                                if ((extkey_dash + extkey_dot) != 0)
                                {
                                    keyprog = 1;
                                }
                                else
                                {
                                    keyprog = 0;
                                }
                                //								Debug.WriteLine("keyprog: "+keyprog);
                            }
                            else
                            {
                                keyprog = 0;
                            }
                            break;
#endif

                        default:                                 // comm port
                            switch (secondary_ptt_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = sp2.DsrHolding;
                                }
                                else
                                {
                                    extkey_dot = sp2.CtsHolding;
                                }
                                break;

                            case KeyerLine.DTR:                                     // look at DSR since we are on the other side of the null modem cable
                                keyerptt = sp2.DsrHolding;
                                break;

                            case KeyerLine.RTS:                                     // look at CTS since we are on the other side of the null modem cable
                                keyerptt = sp2.CtsHolding;
                                break;
                            }

                            switch (secondary_key_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = sp2.DsrHolding;
                                }
                                else
                                {
                                    extkey_dot = sp2.CtsHolding;
                                }
                                break;

                            case KeyerLine.DTR:                                     // look at DSR since we are on the other side of the null modem cable
                                extkey_dot = sp2.DsrHolding;
                                //										Debug.WriteLine("extkey_dot: "+extkey_dot);
                                break;

                            case KeyerLine.RTS:                                     // look at CTS since we are on the other side of the null modem cable
                                extkey_dash = sp2.CtsHolding;
                                break;
                            }

                            break;
                        }
                        if (extkey_dash || extkey_dot)
                        {
                            keyprog = true;
                        }
                        else
                        {
                            keyprog = false;
                        }
                        //Debug.WriteLine("keyprog: "+keyprog);
                    }
                    timer.Stop();
                    msdel = (float)timer.DurationMsec;
                    //Debug.WriteLine("Dash: "+extkey_dash+" Dot: "+extkey_dot);
                    DttSP.KeyValue(msdel, extkey_dash, extkey_dot, keyprog);
                }
            } while(threads_running);
        }
Ejemplo n.º 13
0
        private void btnTune_Click(object sender, EventArgs e)
        {
            if (txtTune.Text == "") return;

            double freq;
            bool b = double.TryParse(txtTune.Text, out freq);
            if (!b) return;

            uint ftw = (uint)(Math.Pow(2.0, 32) * freq*2 / 384.0);

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            int val = USBHID.SetFreqTW(ftw);

            t1.Stop();
            Debug.WriteLine("Tune: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 14
0
        public void RunCalFWCRXImage()
        {
            test_rx_image = "RX Image Test: Passed";

            if (!console.PowerOn)
            {
                console.PowerOn = true;
                Thread.Sleep(500);
            }

            if (console.VFOSync)
                console.VFOSync = false;

            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;

            int tx_low = console.TXFilterLow;
            console.TXFilterLow = 100;

            int tx_high = console.TXFilterHigh;
            console.TXFilterHigh = 200;

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            float[] band_freqs = { 1.85f, 3.75f, 5.357f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f };
            for (int i = 0; i < band_freqs.Length; i++)
            {
                float rejection_tol = 80.0f;	// rejection from worst to null
                float floor_tol = 10.0f;		// from null to noise floor

                if (console.CurrentModel == Model.FLEX3000 &&
                    FWCEEPROM.TRXRev >> 8 < 6) // before rev G
                {
                    switch (bands[i])
                    {
                        case Band.B160M:
                        case Band.B80M:
                        case Band.B60M:
                            rejection_tol = 77.0f;
                            break;
                    }
                }

                bool do_band = false;
                switch (bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M:
                        {
                            if (console.CurrentRegion == FRSRegion.US) { do_band = ck60.Checked; break; }
                            else
                            {
                                lstDebug.Items.Insert(0, "RX Image - " + BandToString(bands[i]) + ": Result OK");
                                continue;
                            }
                        }
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M: do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if (do_band)
                {
                    p.SetPercent(0.0f);
                    Invoke(new MethodInvoker(p.Show));
                    Application.DoEvents();
                    console.VFOAFreq = band_freqs[i] + 2 * console.IFFreq;
                    console.VFOBFreq = band_freqs[i];
                    bool b = console.CalibrateRXImage(band_freqs[i], p, true);
                    
                    if (!b || console.rx_image_rejection[(int)bands[i]] < rejection_tol ||
                        console.rx_image_from_floor[(int)bands[i]] > floor_tol)
                    {
                        if (!test_rx_image.StartsWith("RX Image Test: Failed ("))
                            test_rx_image = "RX Image Test: Failed (";
                        test_rx_image += BandToString(bands[i]) + ",";
                        btnRXImage.BackColor = Color.Red;
                        lstDebug.Items.Insert(0, "RX Image - " + BandToString(bands[i]) + ": Failed ("
                            + console.rx_image_rejection[(int)bands[i]].ToString("f1") + ", "
                            + console.rx_image_from_floor[(int)bands[i]].ToString("f1") + ")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "RX Image - " + BandToString(bands[i]) + ": Passed ("
                            + console.rx_image_rejection[(int)bands[i]].ToString("f1") + ", "
                            + console.rx_image_from_floor[(int)bands[i]].ToString("f1") + ")");
                    }

                    if (p.Text == "")
                    {
                        if (console.CurrentModel == Model.FLEX1500 && !b &&
                            console.rx_image_rejection[(int)bands[i]] == 0.0f &&
                            console.rx_image_from_floor[(int)bands[i]] == 100.0f)
                            MessageBox.Show("Error finding Signal.  Double check Sig Gen cabling.",
                                "Error: Signal Not Found",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                        break;
                    }

                    Thread.Sleep(500);
                }
            }

            console.TXFilterLow = tx_low;
            console.TXFilterHigh = tx_high;

            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;
            if (test_rx_image.StartsWith("RX Image Test: Failed ("))
                test_rx_image = test_rx_image.Substring(0, test_rx_image.Length - 1) + ")";
            toolTip1.SetToolTip(btnRXImage, test_rx_image);

            t1.Stop();
            Debug.WriteLine("RX Image Timer: " + t1.Duration);

            string path = console.AppDataPath + "\\Tests";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            bool file_exists = File.Exists(path + "\\rx_image.csv");
            StreamWriter writer = new StreamWriter(path + "\\rx_image.csv", true);
            if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, "
                                  + "160m gain, 160m phase, 160m rejection, 160m noise distance, "
                                  + "80m gain, 80m phase, 80m rejection, 80m noise distance, "
                                  + "60m gain, 60m phase, 60m rejection, 60m noise distance, "
                                  + "40m gain, 40m phase, 40m rejection, 40m noise distance, "
                                  + "30m gain, 30m phase, 30m rejection, 30m noise distance, "
                                  + "20m gain, 20m phase, 20m rejection, 20m noise distance, "
                                  + "17m gain, 17m phase, 17m rejection, 17m noise distance, "
                                  + "15m gain, 15m phase, 15m rejection, 15m noise distance, "
                                  + "12m gain, 12m phase, 12m rejection, 12m noise distance, "
                                  + "10m gain, 10m phase, 10m rejection, 10m noise distance, "
                                  + "6m gain, 6m phase, 6m rejection, 6m noise distance");

            string serial = "";
            switch (console.CurrentModel)
            {
                case Model.FLEX5000:
                case Model.FLEX3000:
                    serial = FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial);
                    break;
                case Model.FLEX1500:
                    serial = HIDEEPROM.SerialToString(HIDEEPROM.SerialNumber);
                    break;
            }

            writer.Write(console.CurrentModel.ToString() + ","
                + serial + ","
                + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ","
                + console.Text + ",");
            for (int i = 0; i < bands.Length; i++)
            {
                writer.Write(console.rx1_image_gain_table[(int)bands[i]].ToString("f11") + ",");
                writer.Write(console.rx1_image_phase_table[(int)bands[i]].ToString("f11") + ",");
                writer.Write(console.rx_image_rejection[(int)bands[i]].ToString("f1") + ",");
                writer.Write(console.rx_image_from_floor[(int)bands[i]].ToString("f1") + ",");
            }
            writer.WriteLine("");
            writer.Close();

            path += "\\RX Image";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            string model = "";
            switch (console.CurrentModel)
            {
                case Model.FLEX5000:
                    model = "F5K" + "_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial);
                    break;
                case Model.FLEX3000:
                    model = "F3K" + "_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial);
                    break;
                case Model.FLEX1500:
                    model = "F1.5K" + "_" + HIDEEPROM.SerialToString(HIDEEPROM.SerialNumber);
                    break;
            }
            writer = new StreamWriter(path + "\\rx_image_" + model + ".csv");
            writer.WriteLine("Band, Gain, Phase, Rejection, Noise Distance");
            for (int i = 0; i < bands.Length; i++)
            {
                writer.Write(BandToString(bands[i]) + ",");
                writer.Write(console.rx1_image_gain_table[(int)bands[i]].ToString("f11") + ",");
                writer.Write(console.rx1_image_phase_table[(int)bands[i]].ToString("f11") + ",");
                writer.Write(console.rx_image_rejection[(int)bands[i]].ToString("f1") + ",");
                writer.WriteLine(console.rx_image_from_floor[(int)bands[i]].ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving RX Image data to EEPROM...");
            byte gain_sum = 0, phase_sum = 0;
            switch (console.CurrentModel)
            {
                case Model.FLEX5000:
                case Model.FLEX3000:
                    FWCEEPROM.WriteRXImage(console.rx1_image_gain_table, console.rx1_image_phase_table, out gain_sum, out phase_sum);
                    break;
                case Model.FLEX1500:
                    HIDEEPROM.WriteRXImage(console.rx1_image_gain_table, console.rx1_image_phase_table, out gain_sum, out phase_sum);
                    break;
            }
            console.rx1_image_gain_checksum = gain_sum;
            console.rx1_image_phase_checksum = phase_sum;
            console.SyncCalDateTime();
            lstDebug.Items[0] = "Saving RX Image data to EEPROM...done";

            grpGeneral.Enabled = true;
            grpReceiver.Enabled = true;
            grpTransmitter.Enabled = true;
            grpIO.Enabled = true;
        }
Ejemplo n.º 15
0
        public bool CalibrateRX2Image(float freq, Progress progress, bool suppress_errors)
        {
            if(!fwc_init || current_model != Model.FLEX5000 || !FWCEEPROM.RX2OK) return false;

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            HiPerfTimer t2 = new HiPerfTimer();

            string gain_string = "";
            string phase_string = "";
            float tol = 10.0f;
            float phase_step = 1.0f;
            float gain_step = 10.0f;
            float phase_index = 0;
            float gain_index = 0;
            float global_min_phase = 0;
            float global_min_gain = 0;
            float global_min_value = float.MaxValue;
            bool progressing = true;
            int gain_dir = -1;
            int phase_dir = 1;
            int gain_count = 1;
            int phase_count = 1;
            int wrong_direction_count;
            int switch_direction_count;
            string index_string;
            string val_string;

            // Setup Rig for Image Null Cal
            bool ret_val = false;
            calibration_running = true;

            if(!chkPower.Checked)
            {
                if(!suppress_errors)
                {
                    MessageBox.Show("Power must be on in order to calibrate RX Image.", "Power Is Off",
                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                calibration_running = false;
                progress.Text = "";
                return false;
            }

            double vfoa = VFOAFreq;
            double vfob = VFOBFreq;

            bool spur_red = chkSR.Checked;					// save current spur reduction setting
            chkSR.Checked = false;							// turn spur reduction off

            bool rx2_sr = chkRX2SR.Checked;
            chkRX2SR.Checked = false;

            //bool rx_only = SetupForm.RXOnly;				// save RX Only Setting
            //SetupForm.RXOnly = true;

            bool polyphase = SetupForm.Polyphase;			// save current polyphase setting
            SetupForm.Polyphase = false;					// disable polyphase

            int dsp_buf_size = SetupForm.DSPPhoneRXBuffer;		// save current DSP buffer size
            SetupForm.DSPPhoneRXBuffer = 4096;					// set DSP Buffer Size to 4096

            bool rx2 = rx2_enabled;
            RX2Enabled = true;

            string display_mode = comboDisplayMode.Text;
            comboDisplayMode.Text = "Spectrum";

            bool avg = chkDisplayAVG.Checked;		// save current average state
            chkDisplayAVG.Checked = true;

            DSPMode dsp_mode = rx1_dsp_mode;			// save current dsp mode
            DSPMode dsp2_mode = rx2_dsp_mode;			// save current dsp mode

            RX1DSPMode = DSPMode.DSB;					// set dsp mode to DSB
            RX2DSPMode = DSPMode.DSB;					// set dsp mode to DSB

            int filt1_low = RX1FilterLow;
            int filt1_high = RX1FilterHigh;
            Filter filter1 = rx1_filter;					// save current filter

            int filt2_low = RX1FilterLow;
            int filt2_high = RX1FilterHigh;
            Filter filter2 = rx1_filter;					// save current filter

            /*PreampMode preamp = rx1_preamp_mode;		// save current preamp setting
            RX1PreampMode = PreampMode.HIGH;			// set preamp to high*/
            FWC.SetRX2Preamp(true);
            Thread.Sleep(50);

            //bool duplex = full_duplex;
            //FullDuplex = true;

            VFOAFreq = freq;
            Thread.Sleep(50);
            FWC.SetTest(true);
            Thread.Sleep(50);
            FWC.SetGen(true);
            Thread.Sleep(50);
            FWC.SetSig(true);
            Thread.Sleep(50);
            FWC.SetQSE(false);
            Thread.Sleep(50);

            VFOBFreq = freq+2*(float)if_freq;				// set frequency to passed value + 2*IF

            UpdateRX1Filters(-5000, 5000);
            UpdateRX2Filters(-5000, 5000);

            FWCAnt rx2_antenna = RX2Ant;
            RX2Ant = FWCAnt.RX1TAP;

            DisableAllFilters();
            DisableAllModes();
            VFOLock = true;
            comboPreamp.Enabled = false;
            comboDisplayMode.Enabled = false;

            //int retval = 0;
            progress.SetPercent(0.0f);

            radio.GetDSPRX(1, 0).RXCorrectIQPhase = -400.0f;
            radio.GetDSPRX(1, 0).RXCorrectIQGain = -500.0f;

            float[] a = new float[Display.BUFFER_SIZE];

            Thread.Sleep(200);
            float sum = 0.0f;
            int peak_bin = -1;
            float max_signal = float.MinValue;

            for(int i=0; i<5; i++)
            {
                calibration_mutex.WaitOne();
                fixed(float* ptr = &a[0])
                    DttSP.GetSpectrum(2, ptr);// get the spectrum values
                calibration_mutex.ReleaseMutex();
                Thread.Sleep(50);
            }

            for(int i=0; i<5; i++)
            {
                calibration_mutex.WaitOne();
                fixed(float* ptr = &a[0])
                    DttSP.GetSpectrum(2, ptr);// get the spectrum values
                calibration_mutex.ReleaseMutex();

                /*for(int j=0; i==4 && j<Display.BUFFER_SIZE; j++)
                {
                    if(a[j] > max_signal)
                    {
                        max_signal = a[j];
                        peak_bin = j;
                    }
                }*/
                max_signal = a[2048];
                peak_bin = 2048;

                for(int j=1948; j<2148; j++) // TODO: Fix limits for 48/96kHz
                {
                    if(j<2040 || j > 2055)
                        sum += a[j];
                }
                Thread.Sleep(50);
            }
            float noise_floor = (sum / 925.0f);
            float worst_image = max_signal;
            Debug.WriteLine("noise_floor: "+noise_floor.ToString("f6")+" peak_bin: "+peak_bin);

            if(max_signal < noise_floor + 30.0)
            {
                if(!suppress_errors)
                {
                    MessageBox.Show("Image not found (max signal < noise floor + 30dB).  Please try again.\n"+
                        DateTime.Now.ToShortTimeString(),
                        "Image Not Found",
                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                calibration_running = false;
                //progress.Text = "";
                goto end;
            }

            radio.GetDSPRX(1, 0).RXCorrectIQPhase = 0.0f;
            radio.GetDSPRX(1, 0).RXCorrectIQGain = 0.0f;

            while(progressing)
            {
                // find minimum of the peak signal over
                // the range of Gain settings

                float start = 0.0f;
                float min_signal = float.MaxValue;
                max_signal = float.MinValue;
                wrong_direction_count = switch_direction_count = 0;
                bool first_time = true;

                t2.Start();
                index_string = "";
                val_string = "";
                gain_string += (gain_count+","+gain_dir+","+gain_step.ToString("f6")+"\n");
                // start at the global min and try to walk in one direction -- if wrong, turn around
                for(float i=global_min_gain; i >= -500.0 && i <= 500.0; i+=(gain_step*gain_dir))
                {
                    radio.GetDSPRX(1, 0).RXCorrectIQGain = i;				//set gain slider
                    Thread.Sleep(200);

                    sum = 0.0f;
                    int num_avg = 2;
                    if(gain_step <= 0.01) num_avg = 4;
                    for(int j=0; j<num_avg; j++)
                    {
                        calibration_mutex.WaitOne();
                        fixed(float* ptr = &a[0])
                            DttSP.GetSpectrum(2, ptr);// get the spectrum values
                        sum += a[peak_bin];
                        calibration_mutex.ReleaseMutex();
                        if(j<num_avg-1) Thread.Sleep(50);
                    }
                    sum /= num_avg;
                    a[peak_bin] = sum;

                    index_string += i.ToString("f4")+",";
                    val_string += a[peak_bin].ToString("f4")+",";

                    if(a[peak_bin] < min_signal)			// if image is less than minimum
                    {
                        min_signal = a[peak_bin];			// save new minimum
                        gain_index = i;						// save phase index
                        if(min_signal < global_min_value)
                        {
                            global_min_value = min_signal;
                            global_min_gain = gain_index;
                        }
                    }

                    // cal complete condition
                    if(min_signal < noise_floor+6.0f)
                    {
                        progressing = false;
                        break;
                    }

                    if(first_time)
                    {
                        first_time = false;
                        start = a[peak_bin];
                        max_signal = a[peak_bin];
                    }
                    else
                    {
                        if(a[peak_bin] > max_signal && a[peak_bin] > start+1.0)
                        {
                            max_signal = a[peak_bin];
                            wrong_direction_count++; Debug.Write("W");
                            if(wrong_direction_count > 1)
                            {
                                wrong_direction_count = 0;
                                if(++switch_direction_count > 1)
                                {
                                    // handle switched direction twice
                                    if(gain_step >= 0.1) gain_step /= 6.0f;
                                    else gain_step /= 2.0f;
                                    gain_dir *= -1;
                                    Debug.WriteLine("gain exit dir - gain_step:"+gain_step.ToString("f4")+"  distance:"+(global_min_value-noise_floor).ToString("f1"));
                                    break;
                                }

                                min_signal = start;
                                max_signal = start;
                                gain_dir *= -1;
                                i = global_min_gain;
                            }
                        }
                        else
                        {
                            if(min_signal > noise_floor + 20.0) tol = 3.0f;
                            else tol = 5.0f;
                            if (min_signal < start-3.0 && a[peak_bin] > min_signal + tol)
                            {
                                if(gain_step > 0.1) gain_step /= 8.0f;
                                else gain_step /= 2.0f;
                                gain_dir *= -1;
                                Debug.WriteLine("gain thresh - gain_step:"+gain_step.ToString("f4")+"  distance:"+(global_min_value-noise_floor).ToString("f1"));
                                break;
                            }
                        }
                    }

                    if(!progress.Visible) goto end;
                    else
                    {
                        t1.Stop();
                        if(t1.Duration > 90.0)
                        {
                            /*MessageBox.Show("RX Image Reject Calibration Failed.  Values have been returned to previous settings.\n"+
                                DateTime.Now.ToShortTimeString(),
                                "RX Image Failed",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);*/
                            goto end;
                        }
                        else progress.SetPercent((float)(t1.Duration/90.0));
                    }
                }

                t2.Stop();
                Debug.WriteLine("t2 gain("+gain_count+++"): "+t2.Duration);
                if(gain_count < 6)
                {
                    gain_string += (index_string+"\n");
                    gain_string += (val_string+"\n\n");
                }

                radio.GetDSPRX(1, 0).RXCorrectIQGain = global_min_gain;			//set gain slider to min found

                if(!progressing) break;

                // find minimum of the peak signal over
                // the range of Phase settings
                min_signal = float.MaxValue;
                max_signal = float.MinValue;
                wrong_direction_count = switch_direction_count = 0;
                first_time = true;

                t2.Start();
                index_string = "";
                val_string = "";
                phase_string += (phase_count+","+phase_dir+","+phase_step.ToString("f3")+"\n");
                for(float i=global_min_phase; i >= -400.0 && i <= 400.0; i+=(phase_step*phase_dir))
                {
                    radio.GetDSPRX(1, 0).RXCorrectIQPhase = i;				// phase slider
                    Thread.Sleep(200);

                    sum = 0.0f;
                    int num_avg = 2;
                    if(phase_step <= 0.01) num_avg = 4;
                    for(int j=0; j<num_avg; j++)
                    {
                        calibration_mutex.WaitOne();
                        fixed(float* ptr = &a[0])
                            DttSP.GetSpectrum(2, ptr);// get the spectrum values
                        sum += a[peak_bin];
                        calibration_mutex.ReleaseMutex();
                        if(j<num_avg-1) Thread.Sleep(50);
                    }
                    sum /= num_avg;
                    a[peak_bin] = sum;

                    index_string += i.ToString("f4")+",";
                    val_string += a[peak_bin].ToString("f4")+",";

                    if(a[peak_bin] < min_signal)			// if image is less than minimum
                    {
                        min_signal = a[peak_bin];			// save new minimum
                        phase_index = i;					// save phase index
                        if(min_signal < global_min_value)
                        {
                            global_min_value = min_signal;
                            global_min_phase = phase_index;
                        }
                    }

                    // cal complete condition
                    if(min_signal < noise_floor+6.0f)
                    {
                        progressing = false;
                        break;
                    }

                    if(first_time)
                    {
                        first_time = false;
                        start = a[peak_bin];
                        max_signal = a[peak_bin];
                    }
                    else
                    {
                        if(a[peak_bin] > max_signal && a[peak_bin] > start+1.0)
                        {
                            max_signal = a[peak_bin];
                            wrong_direction_count++;Debug.Write("W");
                            if(wrong_direction_count > 1)
                            {
                                wrong_direction_count = 0;
                                if(++switch_direction_count > 1)
                                {
                                    // handle switched direction twice
                                    if(phase_step >= 0.1) phase_step /= 6.0f;
                                    else phase_step /= 2.0f;
                                    phase_dir *= -1;
                                    Debug.WriteLine("phase exit dir - phase_step:"+phase_step.ToString("f4")+"  distance:"+(global_min_value-noise_floor).ToString("f1"));
                                    break;
                                }

                                min_signal = start;
                                max_signal = start;
                                phase_dir *= -1;
                                i = global_min_phase;
                            }
                        }
                        else
                        {
                            if(min_signal > noise_floor + 20.0) tol = 3.0f;
                            else tol = 5.0f;
                            if (min_signal < start-3.0 && a[peak_bin] > min_signal + tol)
                            {
                                if(phase_step >= 0.1) phase_step /= 6.0f;
                                else phase_step /= 2.0f;
                                phase_dir *= -1;
                                Debug.WriteLine("phase exit thresh - phase_step:"+phase_step.ToString("f4")+"  distance:"+(global_min_value-noise_floor).ToString("f1"));
                                break;
                            }
                        }
                    }

                    if(!progress.Visible) goto end;
                    else
                    {
                        t1.Stop();
                        if(t1.Duration > 90.0)
                        {
                            /*MessageBox.Show("RX Image Reject Calibration Failed.  Values have been returned to previous settings.\n"+
                                DateTime.Now.ToShortTimeString(),
                                "RX Image Failed",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);*/
                            goto end;
                        }
                        else progress.SetPercent((float)(t1.Duration/90.0));
                    }
                }

                t2.Stop();
                Debug.WriteLine("t2 phase("+phase_count+++"): "+t2.Duration);

                if(phase_count < 6)
                {
                    phase_string += (index_string+"\n");
                    phase_string += (val_string+"\n\n");
                }

                radio.GetDSPRX(1, 0).RXCorrectIQPhase = global_min_phase;			//set phase slider to min found

                if(!progressing) break;
            }

            // Finish the algorithm and reset the values
            ret_val = true;
            end:
                StreamWriter writer = new StreamWriter(Application.StartupPath+"\\rx_image.csv");
            writer.Write(gain_string+"\n");
            writer.Write(phase_string);
            writer.Close();
            if(!progress.Visible) progress.Text = "";
            else
            {
                rx2_image_gain_table[(int)rx2_band] = (float)radio.GetDSPRX(1, 0).RXCorrectIQGain;
                rx2_image_phase_table[(int)rx2_band] = (float)radio.GetDSPRX(1, 0).RXCorrectIQPhase;
            }
            progress.Hide();
            calibration_running = false;

            rx_image_rejection[(int)rx2_band] = worst_image - global_min_value;
            rx_image_from_floor[(int)rx2_band] = global_min_value - noise_floor;

            FWC.SetTest(false);
            Thread.Sleep(50);
            FWC.SetGen(false);
            Thread.Sleep(50);
            FWC.SetSig(false);
            Thread.Sleep(50);

            EnableAllFilters();
            EnableAllModes();
            VFOLock = false;
            //FullDuplex = duplex;
            FWC.SetRX2Preamp(false);
            Thread.Sleep(50);
            comboDisplayMode.Enabled = true;

            chkSR.Checked = spur_red;							// restore spur reduction setting
            chkRX2SR.Checked = rx2_sr;
            //RX1PreampMode = preamp;							// restore preamp mode
            comboDisplayMode.Text = display_mode;				// restore display mode
            //SetupForm.RXOnly = rx_only;						// restore RX Only setting
            RX1DSPMode = dsp_mode;							// restore dsp mode
            RX2DSPMode = dsp2_mode;							// restore dsp mode
            RX1Filter = filter1;								// restore filter
            if(filter1 == Filter.VAR1 || filter1 == Filter.VAR2)
                UpdateRX1Filters(filt1_low, filt1_high);
            RX2Filter = filter2;
            if(filter2 == Filter.VAR1 || filter2 == Filter.VAR2)
                UpdateRX2Filters(filt2_low, filt2_high);

            VFOAFreq = vfoa;								// restore frequency
            txtVFOAFreq_LostFocus(this, EventArgs.Empty);
            VFOBFreq = vfob;
            RX2Enabled = rx2;
            RX2Ant = rx2_antenna;
            chkDisplayAVG.Checked = avg;						// restore average state
            SetupForm.DSPPhoneRXBuffer = dsp_buf_size;				// restore DSP Buffer Size
            SetupForm.Polyphase = polyphase;					// restore polyphase

            t1.Stop();
            //MessageBox.Show(t1.Duration.ToString());
            Debug.WriteLine("timer: "+t1.Duration);
            return ret_val;
        }
Ejemplo n.º 16
0
        public void RunCalFWCRXLevel()
        {
            float[] offset_avg = {-59.3f, -60.5f, -61.1f, -61.4f, -60.8f, -60.5f, -60.0f, -59.5f, -59.5f, -59.5f, -59.6f};
            float[] preamp_avg = {-13.4f, -7.0f, -13.3f, -13.6f, -14.0f, -14.0f, -14.0f, -13.8f, -13.8f, -13.8f, -13.7f};
            float offset_tol = 2.5f;	// maximum distance from the average value
            float preamp_tol = 1.5f;

            test_rx_level = "RX Level Test: Passed";
            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B6M, Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M };
            float[] band_freqs = { 50.11f, 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f };

            for(int i=0; i<band_freqs.Length; i++)
            {
                bool do_band = false;
                switch(bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M: do_band = ck60.Checked; break;
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M:	do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if(do_band)
                {
                    p.SetPercent(0.0f);
                    Invoke(new MethodInvoker(p.Show));
                    Application.DoEvents();
                    console.VFOAFreq = band_freqs[i];
                    console.VFOBFreq = band_freqs[i];
                    console.CalibrateLevel(-24.0f, band_freqs[i], p, true);
                    if(p.Text == "") break;

                    if(Math.Abs(console.GetRX1Level(bands[i], 0)-offset_avg[i]) > offset_tol ||
                        Math.Abs(console.GetRX1Level(bands[i], 1)-preamp_avg[i]) > preamp_tol)
                    {
                        btnRXLevel.BackColor = Color.Red;
                        if(!test_rx_level.StartsWith("RX Level Test: Failed ("))
                            test_rx_level = "RX Level Test: Failed (";
                        test_rx_level += BandToString(bands[i])+", ";
                        lstDebug.Items.Insert(0, "RX Level Test - "+BandToString(bands[i])+": Failed ("
                            +console.GetRX1Level(bands[i], 0).ToString("f1")+", "
                            +console.GetRX1Level(bands[i], 1).ToString("f1")+", "
                            +console.GetRX1Level(bands[i], 2).ToString("f1")+")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "RX Level Test - "+BandToString(bands[i])+": Passed ("
                            +console.GetRX1Level(bands[i], 0).ToString("f1")+", "
                            +console.GetRX1Level(bands[i], 1).ToString("f1")+", "
                            +console.GetRX1Level(bands[i], 2).ToString("f1")+")");
                    }

                    Thread.Sleep(500);
                }
            }

            if(test_rx_level.StartsWith("RX Level Test: Failed ("))
                test_rx_level = test_rx_level.Substring(0, test_rx_level.Length-2)+")";
            toolTip1.SetToolTip(btnRXLevel, test_rx_level);

            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;

            t1.Stop();
            Debug.WriteLine("RX Level Timer: "+t1.Duration);

            string path = Application.StartupPath+"\\Tests";
            if(!Directory.Exists(path))	Directory.CreateDirectory(path);
            bool file_exists = File.Exists(path+"\\rx_level.csv");
            StreamWriter writer = new StreamWriter(path+"\\rx_level.csv", true);
            if(!file_exists) writer.WriteLine("Serial Num, Date/Time, Version, "
                                 +"6m display offset, 6m preamp offset, 6m multimeter offset, "
                                 +"160m display offset, 160m preamp offset, 160m multimeter offset, "
                                 +"80m display offset, 80m preamp offset, 80m multimeter offset, "
                                 +"60m display offset, 60m preamp offset, 60m multimeter offset, "
                                 +"40m display offset, 40m preamp offset, 40m multimeter offset, "
                                 +"30m display offset, 30m preamp offset, 30m multimeter offset, "
                                 +"20m display offset, 20m preamp offset, 20m multimeter offset, "
                                 +"17m display offset, 17m preamp offset, 17m multimeter offset, "
                                 +"15m display offset, 15m preamp offset, 15m multimeter offset, "
                                 +"12m display offset, 12m preamp offset, 12m multimeter offset, "
                                 +"10m display offset, 10m preamp offset, 10m multimeter offset");
            writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial)+","
                +DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString()+","
                +console.Text+",");
            for(int i=0; i<bands.Length; i++)
            {
                for(int j=0; j<3; j++)
                {
                    writer.Write(console.GetRX1Level(bands[i], j).ToString("f1"));
                    if(i!=bands.Length-1 || j!=2) writer.Write(",");
                }
            }
            writer.WriteLine("");
            writer.Close();

            path += "\\RX Level";
            if(!Directory.Exists(path))	Directory.CreateDirectory(path);
            writer = new StreamWriter(path+"\\rx_level_"+FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial)+".csv");
            writer.WriteLine("Band, Display Offset, Preamp Offset, Multimeter Offset");
            for(int i=0; i<bands.Length; i++)
            {
                writer.Write(BandToString(bands[i])+",");
                writer.Write(console.GetRX1Level(bands[i], 0).ToString("f1")+",");
                writer.Write(console.GetRX1Level(bands[i], 1).ToString("f1")+",");
                writer.WriteLine(console.GetRX1Level(bands[i], 2).ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving Level data to EEPROM...");
            FWCEEPROM.WriteRXLevel(console.rx1_level_table);
            console.FLEX5000SyncCalDateTime();
            lstDebug.Items[0] = "Saving Level data to EEPROM...done";

            grpGeneral.Enabled = true;
            grpReceiver.Enabled = true;
            grpTransmitter.Enabled = true;
        }
Ejemplo n.º 17
0
        public void RunCalFWCTXCarrier()
        {
            float tol = -105.0f;
            test_tx_carrier = "TX Carrier Test: Passed";

            if (!console.PowerOn)
            {
                console.PowerOn = true;
                Thread.Sleep(500);
            }

            if (console.VFOSync)
                console.VFOSync = false;

            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;

            int tx_low = console.TXFilterLow;
            console.TXFilterLow = 100;

            int tx_high = console.TXFilterHigh;
            console.TXFilterHigh = 200;

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            double[] band_freqs = { 1.85, 3.75, 5.357, 7.15, 10.125, 14.175, 18.1, 21.300, 24.9, 28.4, 50.11 };
            for (int i = 0; i < band_freqs.Length; i++)
            {
                bool do_band = false;
                switch (bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M:
                        {
                            if (console.CurrentRegion == FRSRegion.US) { do_band = ck60.Checked; break; }
                            else
                            {
                                lstDebug.Items.Insert(0, "TX Carrier - " + BandToString(bands[i]) + ": Result OK");
                                continue;
                            }
                        }
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M: do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if (do_band)
                {
                    p.SetPercent(0.0f);
                    Invoke(new MethodInvoker(p.Show));
                    Application.DoEvents();
                    console.VFOAFreq = band_freqs[i];
                    console.VFOBFreq = band_freqs[i];
                    console.CalibrateTXCarrier(band_freqs[i], p, true);
                    //if(console.min_tx_carrier[(int)bands[i]] > tol) // try again
                    //	console.CalibrateTXCarrier(band_freqs[i], p, true);

                    if (p.Text == "") break;

                    if (console.min_tx_carrier[(int)bands[i]] > tol)
                    {
                        if (!test_tx_carrier.StartsWith("TX Carrier Test: Failed ("))
                            test_tx_carrier = "TX Carrier Test: Failed (";
                        test_tx_carrier += BandToString(bands[i]) + ",";
                        btnTXCarrier.BackColor = Color.Red;
                        lstDebug.Items.Insert(0, "TX Carrier - " + BandToString(bands[i]) + ": Failed ("
                            + console.min_tx_carrier[(int)bands[i]].ToString("f1") + ")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "TX Carrier - " + BandToString(bands[i]) + ": Passed ("
                            + console.min_tx_carrier[(int)bands[i]].ToString("f1") + ")");
                    }
                    Thread.Sleep(500);
                }
            }

            console.TXFilterLow = tx_low;
            console.TXFilterHigh = tx_high;

            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;

            if (test_tx_carrier.StartsWith("TX Carrier Test: Failed ("))
                test_tx_carrier = test_tx_carrier.Substring(0, test_tx_carrier.Length - 1) + ")";
            toolTip1.SetToolTip(btnTXCarrier, test_tx_carrier);

            t1.Stop();
            Debug.WriteLine("TX Carrier Timer: " + t1.Duration);

            string path = console.AppDataPath + "\\Tests";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            bool file_exists = File.Exists(path + "\\tx_carrier.csv");
            StreamWriter writer = new StreamWriter(path + "\\tx_carrier.csv", true);
            if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, "
                                  + "160m C0, 160m C1, 160m C2, 160m C3, 160m From Noise, "
                                  + "80m C0, 80m C1, 80m C2, 80m C3, 80m From Noise, "
                                  + "60m C0, 60m C1, 60m C2, 60m C3, 60m From Noise, "
                                  + "40m C0, 40m C1, 40m C2, 40m C3, 40m From Noise, "
                                  + "30m C0, 30m C1, 30m C2, 30m C3, 30m From Noise, "
                                  + "20m C0, 20m C1, 20m C2, 20m C3, 20m From Noise, "
                                  + "17m C0, 17m C1, 17m C2, 17m C3, 17m From Noise, "
                                  + "15m C0, 15m C1, 15m C2, 15m C3, 15m From Noise, "
                                  + "12m C0, 12m C1, 12m C2, 12m C3, 12m From Noise, "
                                  + "10m C0, 10m C1, 10m C2, 10m C3, 10m From Noise, "
                                  + "6m C0, 6m C1, 6m C2, 6m C3, 6m From Noise");
            writer.Write(console.CurrentModel.ToString() + ","
                + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ","
                + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ","
                + console.Text + ",");
            for (int i = 0; i < bands.Length; i++)
            {
                for (int j = 0; j < 4; j++)
                    writer.Write((console.tx_carrier_cal[Math.Round(band_freqs[i], 3)]>>8*(3-j)).ToString() + ",");
                writer.Write(console.min_tx_carrier[(int)bands[i]].ToString("f1") + ",");
            }
            writer.WriteLine("");
            writer.Close();

            path += "\\TX Carrier";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            string model = "";
            switch (console.CurrentModel)
            {
                case Model.FLEX3000: model = "F3K"; break;
                case Model.FLEX5000: model = "F5K"; break;
            }
            writer = new StreamWriter(path + "\\tx_carrier_" + model + "_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ".csv");
            writer.WriteLine("Band, C0, C1, C2, C3, From Noise");
            for (int i = 0; i < bands.Length; i++)
            {
                writer.Write(BandToString(bands[i]) + ",");
                for (int j = 0; j < 4; j++)
                    writer.Write((console.tx_carrier_cal[Math.Round(band_freqs[i], 3)] >> 8 * (3 - j)).ToString() + ",");
                writer.WriteLine(console.min_tx_carrier[(int)bands[i]].ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving Carrier data to EEPROM...");
            byte checksum;
            FWCEEPROM.WriteTXCarrier(console.tx_carrier_cal, out checksum);
            console.tx_carrier_checksum = checksum;
            console.SyncCalDateTime();
            lstDebug.Items[0] = "Saving Carrier data to EEPROM...done";

            grpGeneral.Enabled = true;
            grpReceiver.Enabled = true;
            grpTransmitter.Enabled = true;
            grpIO.Enabled = true;
        }
Ejemplo n.º 18
0
        private void btnEEWrite_Click(object sender, EventArgs e)
        {
            ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber);
            byte num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber);

            if (num_bytes > txtData.Text.Length / 2)
            {
                MessageBox.Show("Error: Not enough data");
                return;
            }

            byte[] data = new byte[num_bytes];
            for(int i=0; i<num_bytes; i++)
                data[i] = byte.Parse(txtData.Text.Substring(i*2, 2), NumberStyles.HexNumber);

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            int val;
            //fixed(byte* ptr = &data[0])
                val = Flex1500.WriteEEPROM(offset, data);

            t1.Stop();
            Debug.WriteLine("EEWrite: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 19
0
        private void btnEERead_Click(object sender, EventArgs e)
        {
            ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber);
            byte num_bytes = byte.Parse(txtNumBytes.Text, NumberStyles.HexNumber);
            byte[] data;

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            int val;
            val = Flex1500.ReadEEPROM(offset, num_bytes, out data);

            t1.Stop();

            txtEERead.Text = "";
            for (int i = 0; i < num_bytes; i++)
                txtEERead.Text += data[i].ToString("X").PadLeft(2, '0');
           
            Debug.WriteLine("EERead: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 20
0
        private void progressBarTuning()
        {
            float maxTuningTime_ms = 25000;
            float offset = 0;
            float multiplier = 1;
            bool slowDown = false;
            float percent = 0;
            HiPerfTimer t3 = new HiPerfTimer();
            t3.Start();

            Progress p = new Progress("ATU Tuning Progress");
            p.SetPercent(0.0f);
            console.Invoke(new MethodInvoker(p.Show));

            while (tuningDLL)// && t3.DurationMsec< maxTuningTime_ms*2)
            {
                t3.Stop();
                if (t3.DurationMsec > maxTuningTime_ms / 2 && slowDown == false)
                {
                    t3.Start();
                    offset = 0.5f;
                    multiplier = 2;
                    slowDown = true;
                }
                percent = offset + (float)t3.DurationMsec / (maxTuningTime_ms * multiplier);
                if (percent < .98)
                {
                    p.SetPercent(percent);
                }
                else
                {
                    p.SetPercent(.98f);
                }
                if (!p.Visible)
                {
                    abort = true;
                }
                Thread.Sleep(400);

            }
            p.SetPercent(1);
            Thread.Sleep(500);
            p.Hide();


        }
Ejemplo n.º 21
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            uint op = uint.Parse(txtOpcode.Text);
            uint p1 = uint.Parse(txtParam1.Text, NumberStyles.HexNumber);
            uint p2 = uint.Parse(txtParam2.Text, NumberStyles.HexNumber);

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            uint result;
            int val = Flex1500.ReadOp((USBHID.Opcode)op, p1, p2, out result);

            t1.Stop();

            Debug.WriteLine("ReadOp: "+val+"  ("+t1.DurationMsec.ToString("f2")+")");
            txtResult.Text = result.ToString();
        }
Ejemplo n.º 22
0
        private void TuneATU()
        {
            //console.FWCATUTuned();
            Debug.WriteLine("***Entering TuneATU()*****");
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            Thread t2 = new Thread(new ThreadStart(progressBarTuning));
            t2.Name = "ATU Progress Bar Thread";
            t2.IsBackground = true;
            t2.Priority = ThreadPriority.Normal;
            t2.Start();

            double start_swr = 99;
            int SLEEP_TIME = (int)udSleepTime.Value;
            int OFF_SLEEP = (int)udOffSleep.Value;
            int TUN_LVL = (int)udTunPower.Value;
            int old_power = console.TunePower;
            if (abort)
            {
                last_tune_result = TuneResult.TuneAborted;
                goto end;
            }

            string last_tune_result_string = last_tune_result.ToString();
            string version = console.getVersion();
            button1.Focus();


            try
            {
#if(!NO_NEW_ATU)

                ATUClass obj = new ATUClass();
                MemoryTune.Hide();
                console.TunePower = 10;
                //Thread.Sleep(OFF_SLEEP);
                // Audio_RadioVolumeSaved = Audio.RadioVolume;

                version = console.getVersion();
                ////////////***load atu profiles if ATU button is pressed first
                if (comboAntProfileName.Items.Count == 0)
                {
                    profileList = obj.Init(version, ref currentProfileName, true, ref high_swr,
                                  ref  high_swr_no_limit, ref  swr_thresh, ref  swr_retune_target);
                }
                else
                {
                    profileList = obj.Init(version, ref currentProfileName, false, ref high_swr, ref high_swr_no_limit,
                                           ref swr_thresh, ref swr_retune_target);
                }
                if (profileList.Count == 0 && comboAntProfileName.Items.Count == 0)
                {
                    currentProfileName = "Default Profile";
                    comboAntProfileName.Items.Add(currentProfileName);
                    comboAntProfileName.SelectedItem = currentProfileName;
                }
                else
                {
                    foreach (string s in profileList)
                    {
                        if (!comboAntProfileName.Items.Contains(s))
                        {
                            comboAntProfileName.Items.Add(s);
                        }
                    }
                    comboAntProfileName.SelectedItem = currentProfileName;  //last saved profile (from database)
                }
                ///////***


                obj.DoWork( (int)console.RX1Band,
                           autoMode,
                           ref high_swr,
                           ref high_swr_no_limit,
                           ref swr_retune_target,
                           ref swr_thresh,
                           force_retune,
                           ref currentProfileName,
                           ref deletedProfileList,
                           ref start_swr,
                           console.atu_tuning,
                           ref version,
                           ref SLEEP_TIME,
                           ref OFF_SLEEP,
                           ref TUN_LVL,
                           ref byp_swr,
                           ref tun_swr,
                           ref byp_fwd_pow,
                           ref tun_fwd_pow,
                           ref byp_ref_pow,
                           ref tun_ref_pow,
                           ref abort,
                           ref tuning,
                           console.VFOAFreq,
                           ref last_tune_result_string,
                           FWC.SetATUEnable,
                           FWC.SetHiZ,
                           SetL,
                           SetC,
                           getSWR,
                           console_TunePower,
                    //console_TunePower, 
                           Audio_RadioVolume,
                           ref Audio_RadioVolumeSaved,
                           console_TUN,
                           console_TUN,
                           rdBypass_Checked,
                           rdBypass_Checked,
                           rdTune_Checked,
                           rdTune_Checked,
                           setlblHiZ_Visible);

                //autoMode = false;
                if (start_swr == 99 && !rdBypass.Checked)
                {
                    MemoryTune.Show();
                }
#endif
            }

            catch (Exception)
            {

            }

            if (last_tune_result_string == "TuneSuccessful")
                last_tune_result = TuneResult.TuneSuccessful;
            else if (last_tune_result_string == "TuneOK")
                last_tune_result = TuneResult.TuneOK;
            else if (last_tune_result_string == "TuneFailedHighSWR")
                last_tune_result = TuneResult.TuneFailedHighSWR;
            else if (last_tune_result_string == "TuneAborted")
                last_tune_result = TuneResult.TuneAborted;
            else if (last_tune_result_string == "TunerNotNeeded")
                last_tune_result = TuneResult.TunerNotNeeded;
            else if (last_tune_result_string == "TuneFailedNoRF")
                last_tune_result = TuneResult.TuneFailedNoRF;
            else if (last_tune_result_string == "TuneAutoModeTune")
                last_tune_result = TuneResult.TuneAutoModeTune;
            else if (last_tune_result_string == "TuneAutoModeBypass")
                last_tune_result = TuneResult.TuneAutoModeBypass;

        end:

            t1.Stop();
            Debug.WriteLine("The SWR has been reduced to " + tun_swr + " from " + byp_swr + "(" + start_swr + ") in " + t1.Duration.ToString("f1") + " seconds");
            LogMessageToFile("****The SWR at " + console.VFOAFreq + " MHz has been reduced to " + tun_swr + " from " + byp_swr + "(" + start_swr + ") in " + t1.Duration.ToString("f1") + " seconds***");
            tuning = false;
            console.TUN = false;
            console.TunePower = old_power;
            rdTune.Checked = false;
            console.atu_tuning = false;
            abort = false;

            lblTime.Text = "Time: " + t1.Duration.ToString("f1");
            UpdateFeedbackNew();
            tuningDLL = false;
            autoMode = false;


        }
Ejemplo n.º 23
0
        private void Tune()
        {
            int fwd, rev;
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            //const int SLEEP_TIME = 300;
            int SLEEP_TIME = (int)udSleepTime.Value;
            double HIGH_SWR = (double)udHighSWR.Value;
            double swr_thresh = 1.1; // start at 1.1, switch to 1.5 after 5 sec.
            int OFF_SLEEP = (int)udOffSleep.Value;
            int MaxL = 256;
            int MaxC = 128;
            int TUN_LVL = (int)udTunPower.Value;

            console.atu_tuning = true;

            // check in bypass
            FWC.SetATUEnable(false);
            FWC.SetHiZ(false);
            Thread.Sleep(50);
            lblHiZ.Visible = false;
            int old_power = console.TunePower;
            console.TunePower = TUN_LVL;
            console.TUN = true;
            tuning = true;
            Thread.Sleep(500);
            if (abort)
            {
                last_tune_result = TuneResult.TuneAborted;
                goto end;
            }

            // if the match is good enough, then just leave it bypassed
            FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd;
            FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev;
            byp_fwd_pow = console.FWCPAPower(fwd);
            byp_ref_pow = console.FWCPAPower(rev) * console.atu_swr_table[(int)console.TXBand];
            byp_swr = SWR(fwd, rev);
            tun_swr = byp_swr;

            if (byp_fwd_pow < 1)
            {
                rdBypass.Checked = true;
                last_tune_result = TuneResult.TuneFailedNoRF;
                goto end;
            }

            if (byp_swr < swr_thresh)
            {
                rdBypass.Checked = true;
                last_tune_result = TuneResult.TunerNotNeeded;
                goto end;
            }
            else if (byp_swr > HIGH_SWR)
            {
                rdBypass.Checked = true;
                last_tune_result = TuneResult.TuneFailedHighSWR;
                goto end;
            }

            // check HiZ
            console.TunePower = 0;
            Thread.Sleep(OFF_SLEEP);
            FWC.SetATUEnable(true);
            Thread.Sleep(OFF_SLEEP);
            SetC(8);
            SetL(8);
            FWC.SetHiZ(false);
            console.TunePower = TUN_LVL;
            Thread.Sleep(SLEEP_TIME);
            if (abort)
            {
                last_tune_result = TuneResult.TuneAborted;
                goto end;
            }

            FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd;
            FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev;
            double lo_z_swr = SWR(fwd, rev);
            tun_swr = lo_z_swr;

            console.TunePower = 0;
            Thread.Sleep(OFF_SLEEP);
            FWC.SetHiZ(true);
            Thread.Sleep(OFF_SLEEP);
            console.TunePower = TUN_LVL;
            Thread.Sleep(SLEEP_TIME);
            if (abort)
            {
                last_tune_result = TuneResult.TuneAborted;
                goto end;
            }

            FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd;
            FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev;
            double hi_z_swr = SWR(fwd, rev);
            tun_swr = hi_z_swr;
            Debug.WriteLine("lo: " + lo_z_swr.ToString("f1") + "  hi: " + hi_z_swr.ToString("f1"));

            double min_swr = double.MaxValue;
            if (hi_z_swr < lo_z_swr)
            {
                lblHiZ.Visible = true;
                min_swr = hi_z_swr;
            }
            else
            {
                lblHiZ.Visible = false;
                console.TunePower = 0;
                Thread.Sleep(OFF_SLEEP);
                FWC.SetHiZ(false);
                Thread.Sleep(OFF_SLEEP);
                console.TunePower = TUN_LVL;
                min_swr = lo_z_swr;
            }

            tun_fwd_pow = console.FWCPAPower(console.pa_fwd_power);
            if (byp_fwd_pow < 1)
            {
                rdBypass.Checked = true;
                last_tune_result = TuneResult.TuneFailedLostRF;
                goto end;
            }

            if (min_swr < swr_thresh)
            {
                rdTune.Checked = false;
                last_tune_result = TuneResult.TuneSuccessful;
                goto end;
            }

            console.TunePower = 0;
            Thread.Sleep(OFF_SLEEP);
            SetL(0);
            SetC(0);
            Thread.Sleep(OFF_SLEEP);
            console.TunePower = TUN_LVL;
            Thread.Sleep(SLEEP_TIME);
            if (abort)
            {
                rdBypass.Checked = true;
                last_tune_result = TuneResult.TuneAborted;
                goto end;
            }

            int count = 0;
            int l_step = 8;
            int c_step = 8;
            int min_l = 0, L = 0;
            int min_c = 0, C = 0;
            int no_progress = 0;

            FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd;
            FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev;
            min_swr = SWR(fwd, rev);
            bool first_time = true;

            while (rdTune.Checked)
            {
                double start_swr = min_swr;
                while (L >= 0 && L <= MaxL && rdTune.Checked)
                {
                    if (!first_time) Thread.Sleep(SLEEP_TIME);
                    else first_time = false;
                    if (abort)
                    {
                        rdBypass.Checked = true;
                        last_tune_result = TuneResult.TuneAborted;
                        goto end;
                    }

                    t1.Stop();
                    if (t1.Duration > 5.0 && swr_thresh < 1.5)
                        swr_thresh = 1.5;
                    if (t1.Duration > 15.0) no_progress = 100;

                    FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd;
                    FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev;
                    tun_fwd_pow = console.FWCPAPower(fwd);
                    tun_ref_pow = console.FWCPAPower(rev) * console.atu_swr_table[(int)console.TXBand];
                    if (byp_fwd_pow < 1)
                    {
                        rdBypass.Checked = true;
                        last_tune_result = TuneResult.TuneFailedLostRF;
                        goto end;
                    }

                    tun_swr = SWR(fwd, rev);
                    Debug.WriteLine("swr (" + L + ", " + C + "): " + tun_swr.ToString("f1") + "  min: " + min_swr.ToString("f1") + "  start: " + start_swr.ToString("f1"));
                    if (tun_swr < swr_thresh)
                    {
                        rdTune.Checked = false;
                        last_tune_result = TuneResult.TuneSuccessful;
                        goto end;
                    }

                    if (tun_swr < min_swr)
                    {
                        min_swr = tun_swr;
                        min_l = L;
                    }

                    if (tun_swr > min_swr + 0.3)
                    {
                        l_step *= -1;
                        break;
                    }

                    if (count++ * Math.Abs(l_step) > 32 && min_swr >= start_swr - 0.05)
                        break;

                    if (!rdTune.Checked)
                        break;

                    console.TunePower = 0;
                    Thread.Sleep(OFF_SLEEP);
                    SetL(L += l_step);
                    Thread.Sleep(OFF_SLEEP);
                    console.TunePower = TUN_LVL;
                }

                console.TunePower = 0;
                Thread.Sleep(OFF_SLEEP);
                SetL(min_l);
                Thread.Sleep(OFF_SLEEP);
                console.TunePower = TUN_LVL;
                L = min_l;

                if (min_swr >= start_swr - 0.05)
                    no_progress++;

                if (no_progress > 6)
                {
                    rdTune.Checked = false;
                    last_tune_result = TuneResult.TuneOK;
                    goto end;
                }

                Debug.Write("C");

                count = 0;
                start_swr = min_swr;

                while (C >= 0 && C <= MaxC && rdTune.Checked)
                {
                    Thread.Sleep(SLEEP_TIME);
                    if (abort)
                    {
                        rdBypass.Checked = true;
                        last_tune_result = TuneResult.TuneAborted;
                        goto end;
                    }

                    t1.Stop();
                    if (t1.Duration > 5.0 && swr_thresh < 1.5)
                        swr_thresh = 1.5;
                    if (t1.Duration > 15.0) no_progress = 100;

                    FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd;
                    FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev;
                    tun_fwd_pow = console.FWCPAPower(fwd);
                    tun_ref_pow = console.FWCPAPower(rev) * console.atu_swr_table[(int)console.TXBand];
                    if (byp_fwd_pow < 1)
                    {
                        rdBypass.Checked = true;
                        last_tune_result = TuneResult.TuneFailedLostRF;
                        goto end;
                    }

                    tun_swr = SWR(fwd, rev);
                    Debug.WriteLine("swr (" + L + ", " + C + "): " + tun_swr.ToString("f1") + "  min: " + min_swr.ToString("f1") + "  start: " + start_swr.ToString("f1"));
                    if (tun_swr < swr_thresh)
                    {
                        rdTune.Checked = false;
                        last_tune_result = TuneResult.TuneSuccessful;
                        goto end;
                    }

                    if (tun_swr < min_swr)
                    {
                        min_swr = tun_swr;
                        min_c = C;
                    }

                    if (tun_swr > min_swr + 0.3)
                    {
                        c_step *= -1;
                        break;
                    }

                    if (count++ * Math.Abs(c_step) > 32 && min_swr >= start_swr - 0.05)
                        break;

                    if (!rdTune.Checked)
                        break;

                    console.TunePower = 0;
                    Thread.Sleep(OFF_SLEEP);
                    SetC(C += c_step);
                    Thread.Sleep(OFF_SLEEP);
                    console.TunePower = TUN_LVL;
                }

                console.TunePower = 0;
                Thread.Sleep(OFF_SLEEP);
                SetC(min_c);
                Thread.Sleep(OFF_SLEEP);
                console.TunePower = TUN_LVL;
                C = min_c;
                count = 0;

                if (min_swr >= start_swr - 0.05)
                    no_progress++;

                if (no_progress > 6)
                {
                    rdTune.Checked = false;
                    if (byp_swr > tun_swr)
                    {
                        last_tune_result = TuneResult.TuneOK;
                    }
                    else
                    {
                        last_tune_result = TuneResult.TuneFailedHighSWR;
                        rdBypass.Checked = true;
                    }
                    goto end;
                }

                if (Math.Abs(l_step) > 1) l_step /= 2;
                if (Math.Abs(c_step) > 1) c_step /= 2;

                Debug.Write("L");
            }

        end:
            switch (last_tune_result)
            {
                case TuneResult.TuneSuccessful:
                case TuneResult.TuneOK:
                    Thread.Sleep(SLEEP_TIME);
                    FWC.ReadPAADC(5, out fwd); console.pa_fwd_power = fwd;
                    FWC.ReadPAADC(4, out rev); console.pa_rev_power = rev;
                    tun_fwd_pow = console.FWCPAPower(fwd);
                    tun_ref_pow = console.FWCPAPower(rev) * console.atu_swr_table[(int)console.TXBand];
                    tun_swr = SWR(fwd, rev);

                    if (tun_swr > byp_swr)
                    {
                        last_tune_result = TuneResult.TunerNotNeeded;
                        rdBypass.Checked = true;
                    }
                    Thread.Sleep(100);
                    break;
            }
            //Debug.WriteLine("swr: "+swr.ToString("f1"));
            // cleanup
            tuning = false;
            console.TUN = false;
            console.TunePower = old_power;
            rdTune.Checked = false;
            console.atu_tuning = false;
            abort = false;

            //Invoke(new MethodInvoker(UpdateFeedback));
            UpdateFeedback();

            t1.Stop();
            lblTime.Text = "Time: " + t1.Duration.ToString("f1");
        }
Ejemplo n.º 24
0
        private void IORunAll()
        {
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            if (btnIOExtRef.Visible && btnIOExtRef.Enabled)
            {
                Invoke(new MethodInvoker(btnIOExtRef.PerformClick));
                Thread.Sleep(2000);
            }

            if (btnIOPwrSpkr.Visible && btnIOPwrSpkr.Enabled)
            {
                Invoke(new MethodInvoker(btnIOPwrSpkr.PerformClick));
                Thread.Sleep(3500);
            }

            if (btnIORCAInOut.Visible && btnIORCAInOut.Enabled)
            {
                Invoke(new MethodInvoker(btnIORCAInOut.PerformClick));
                Thread.Sleep(3000);
            }

            if (btnIOFWInOut.Visible && btnIOFWInOut.Enabled)
            {
                Invoke(new MethodInvoker(btnIOFWInOut.PerformClick));
                Thread.Sleep(5000);
            }

            if (btnIOHeadphone.Visible && btnIOHeadphone.Enabled)
            {
                Invoke(new MethodInvoker(btnIOHeadphone.PerformClick));
                Thread.Sleep(5000);
            }

            if (btnIODot.Visible && btnIODot.Enabled)
            {
                Invoke(new MethodInvoker(btnIODot.PerformClick));
                Thread.Sleep(2000);
            }

            if (btnIODash.Visible && btnIODash.Enabled)
            {
                Invoke(new MethodInvoker(btnIODash.PerformClick));
                Thread.Sleep(2000);
            }

            if (btnIORCAPTT.Visible && btnIORCAPTT.Enabled)
            {
                Invoke(new MethodInvoker(btnIORCAPTT.PerformClick));
                Thread.Sleep(1000);
            }

            if (btnIOFWPTT.Visible && btnIOFWPTT.Enabled)
            {
                Invoke(new MethodInvoker(btnIOFWPTT.PerformClick));
                Thread.Sleep(1000);
            }

            if (btnIOMicPTT.Visible && btnIOMicPTT.Enabled)
            {
                Invoke(new MethodInvoker(btnIOMicPTT.PerformClick));
                Thread.Sleep(1000);
            }

            if (btnIOMicUp.Visible && btnIOMicUp.Enabled)
            {
                Invoke(new MethodInvoker(btnIOMicUp.PerformClick));
                Thread.Sleep(1000);
            }

            if (btnIOMicDown.Visible && btnIOMicDown.Enabled)
            {
                Invoke(new MethodInvoker(btnIOMicDown.PerformClick));
                Thread.Sleep(1000);
            }

            if (btnIOMicFast.Visible && btnIOMicFast.Enabled)
            {
                Invoke(new MethodInvoker(btnIOMicFast.PerformClick));
                Thread.Sleep(1000);
            }

            btnIORunAll.BackColor = SystemColors.Control;
            btnIORunAll.Enabled = true;
            t1.Stop();
            MessageBox.Show("Run All Tests Time: " + ((int)(t1.Duration / 60)).ToString() + ":" + (((int)t1.Duration) % 60).ToString("00"));
        }
Ejemplo n.º 25
0
        private void IORunAll()
        {
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            Invoke(new MethodInvoker(btnIOExtRef.PerformClick));
            Thread.Sleep(2000);
            Invoke(new MethodInvoker(btnIOPwrSpkr.PerformClick));
            Thread.Sleep(3500);
            Invoke(new MethodInvoker(btnIORCAInOut.PerformClick));
            Thread.Sleep(3000);
            Invoke(new MethodInvoker(btnIOFWInOut.PerformClick));
            Thread.Sleep(3000);
            Invoke(new MethodInvoker(btnIOHeadphone.PerformClick));
            Thread.Sleep(5000);
            Invoke(new MethodInvoker(btnIODot.PerformClick));
            Thread.Sleep(500);
            Invoke(new MethodInvoker(btnIODash.PerformClick));
            Thread.Sleep(500);
            Invoke(new MethodInvoker(btnIORCAPTT.PerformClick));
            Thread.Sleep(1000);
            Invoke(new MethodInvoker(btnIOMicPTT.PerformClick));
            Thread.Sleep(1000);

            btnIORunAll.BackColor = SystemColors.Control;

            t1.Stop();
            MessageBox.Show("Run All Tests Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00"));
        }
Ejemplo n.º 26
0
        public void RunCalFWCTXCarrier()
        {
            float tol = -105.0f;
            test_tx_carrier = "TX Carrier Test: Passed";

            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f};
            for(int i=0; i<band_freqs.Length; i++)
            {
                bool do_band = false;
                switch(bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M: do_band = ck60.Checked; break;
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M:	do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if(do_band)
                {
                    p.SetPercent(0.0f);
                    Invoke(new MethodInvoker(p.Show));
                    Application.DoEvents();
                    console.VFOAFreq = band_freqs[i];
                    console.VFOBFreq = band_freqs[i];
                    console.CalibrateTXCarrier(band_freqs[i], p, true);
                    //if(console.min_tx_carrier[(int)bands[i]] > tol) // try again
                    //	console.CalibrateTXCarrier(band_freqs[i], p, true);

                    if(p.Text == "") break;

                    if(console.min_tx_carrier[(int)bands[i]] > tol)
                    {
                        if(!test_tx_carrier.StartsWith("TX Carrier Test: Failed ("))
                            test_tx_carrier = "TX Carrier Test: Failed (";
                        test_tx_carrier += BandToString(bands[i])+", ";
                        btnTXCarrier.BackColor = Color.Red;
                        lstDebug.Items.Insert(0, "TX Carrier - "+BandToString(bands[i])+": Failed ("
                            +console.min_tx_carrier[(int)bands[i]].ToString("f1")+")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "TX Carrier - "+BandToString(bands[i])+": Passed ("
                            +console.min_tx_carrier[(int)bands[i]].ToString("f1")+")");
                    }
                    Thread.Sleep(500);
                }
            }
            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;

            if(test_tx_carrier.StartsWith("TX Carrier Test: Failed ("))
                test_tx_carrier = test_tx_carrier.Substring(0, test_tx_carrier.Length-2)+")";
            toolTip1.SetToolTip(btnTXCarrier, test_tx_carrier);

            t1.Stop();
            Debug.WriteLine("TX Carrier Timer: "+t1.Duration);

            string path = Application.StartupPath+"\\Tests";
            if(!Directory.Exists(path))	Directory.CreateDirectory(path);
            bool file_exists = File.Exists(path+"\\tx_carrier.csv");
            StreamWriter writer = new StreamWriter(path+"\\tx_carrier.csv", true);
            if(!file_exists) writer.WriteLine("Serial Num, Date/Time, Version, "
                                 +"160m C0, 160m C1, 160m C2, 160m C3, 160m From Noise, "
                                 +"80m C0, 80m C1, 80m C2, 80m C3, 80m From Noise, "
                                 +"60m C0, 60m C1, 60m C2, 60m C3, 60m From Noise, "
                                 +"40m C0, 40m C1, 40m C2, 40m C3, 40m From Noise, "
                                 +"30m C0, 30m C1, 30m C2, 30m C3, 30m From Noise, "
                                 +"20m C0, 20m C1, 20m C2, 20m C3, 20m From Noise, "
                                 +"17m C0, 17m C1, 17m C2, 17m C3, 17m From Noise, "
                                 +"15m C0, 15m C1, 15m C2, 15m C3, 15m From Noise, "
                                 +"12m C0, 12m C1, 12m C2, 12m C3, 12m From Noise, "
                                 +"10m C0, 10m C1, 10m C2, 10m C3, 10m From Noise, "
                                 +"6m C0, 6m C1, 6m C2, 6m C3, 6m From Noise");
            writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial)+","
                +DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString()+","
                +console.Text+",");
            for(int i=0; i<bands.Length; i++)
            {
                for(int j=0; j<4; j++)
                    writer.Write(console.tx_carrier_table[(int)bands[i]][j].ToString()+",");
                writer.Write(console.min_tx_carrier[(int)bands[i]].ToString("f1")+",");
            }
            writer.WriteLine("");
            writer.Close();

            path += "\\TX Carrier";
            if(!Directory.Exists(path))	Directory.CreateDirectory(path);
            writer = new StreamWriter(path+"\\tx_carrier_"+FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial)+".csv");
            writer.WriteLine("Band, C0, C1, C2, C3, From Noise");
            for(int i=0; i<bands.Length; i++)
            {
                writer.Write(BandToString(bands[i])+",");
                for(int j=0; j<4; j++)
                    writer.Write(console.tx_carrier_table[(int)bands[i]][j].ToString()+",");
                writer.WriteLine(console.min_tx_carrier[(int)bands[i]].ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving Carrier data to EEPROM...");
            FWCEEPROM.WriteTXCarrier(console.tx_carrier_table);
            console.FLEX5000SyncCalDateTime();
            lstDebug.Items[0] = "Saving Carrier data to EEPROM...done";

            grpGeneral.Enabled = true;
            grpReceiver.Enabled = true;
            grpTransmitter.Enabled = true;
        }
Ejemplo n.º 27
0
        private void PostFenceTest()
        {
            if(!console.PowerOn)
            {
                p.Hide();
                MessageBox.Show("Power must be on to run this test.",
                    "Power not on",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                grpGeneral.Enabled = true;
                grpReceiver.Enabled = true;
                grpTransmitter.Enabled = true;
                btnPostFence.Enabled = true;
                return;
            }

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            test_post_fence = "Post Fence: ";

            console.VFOSplit = false;

            btnPLL_Click(this, EventArgs.Empty);
            Thread.Sleep(1000);

            btnGenBal_Click(this, EventArgs.Empty);
            Thread.Sleep(3000);

            btnGenPreamp_Click(this, EventArgs.Empty);
            Thread.Sleep(3000);

            btnCheckAll_Click(this, EventArgs.Empty);
            btnRXFilter_Click(this, EventArgs.Empty);
            while(true)
            {
                while(p.Visible) Thread.Sleep(2000);
                Thread.Sleep(2000);
                if(!p.Visible) break;
            }
            if(p.Text == "") goto end;

            btnClearAll_Click(this, EventArgs.Empty);
            ck20.Checked = true;
            btnTXImage_Click(this, EventArgs.Empty);
            while(true)
            {
                while(!btnTXImage.Enabled) Thread.Sleep(2000);
                Thread.Sleep(2000);
                if(btnTXImage.Enabled) break;
            }
            if(p.Text == "") goto end;

            if(btnPLL.BackColor == Color.Green &&
                btnGenBal.BackColor == Color.Green &&
                btnRXFilter.BackColor == Color.Green &&
                btnTXImage.BackColor == Color.Green)
            {
                btnPostFence.BackColor = Color.Green;
                test_post_fence += "Passed";
            }
            else
            {
                btnPostFence.BackColor = Color.Red;
                test_post_fence += "Failed";
            }

            end:
            p.Hide();
            FWC.SetFullDuplex(false);
            Thread.Sleep(50);
            grpGeneral.Enabled = true;
            grpReceiver.Enabled = true;
            grpTransmitter.Enabled = true;
            btnPostFence.Enabled = true;

            t1.Stop();
            MessageBox.Show("Post Fence Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00"));

            /*string test_verify_rx_level = "";
            string test_verify_rx_image = "";
            string test_verify_tx_image = "";
            string test_verify_tx_carrier = "";
            bool pass_rx_level = false;
            bool pass_rx_image = false;
            bool pass_tx_image = false;
            bool pass_tx_carrier = false;
            Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f};
            float[] a = new float[Display.BUFFER_SIZE];
            int counter = 0;

            bool spur_red = console.SpurReduction;
            console.SpurReduction = false;

            string display = console.DisplayModeText;
            console.DisplayModeText = "Spectrum";
            PreampMode preamp = console.RX1PreampMode;
            DSPMode dsp_mode = console.RX1DSPMode;
            Filter filter = console.RX1Filter;
            int rx_filt_high = console.RX1FilterHigh;
            int rx_filt_low = console.RX1FilterLow;
            int tx_filt_high = console.SetupForm.TXFilterHigh;
            int tx_filt_low = console.SetupForm.TXFilterLow;

            bool rit_on = console.RITOn;
            console.RITOn = false;
            bool xit_on = console.XITOn;
            console.XITOn = false;
            bool split = console.VFOSplit;

            int dsp_buf_size = console.SetupForm.DSPRXBufferSize;			// save current DSP buffer size
            console.SetupForm.DSPRXBufferSize = 4096;						// set DSP Buffer Size to 2048

            bool polyphase = console.SetupForm.Polyphase;				// save current polyphase setting
            console.SetupForm.Polyphase = false;						// disable polyphase

            int num_bands = 0;
            for(int i=0; i<band_freqs.Length; i++)
            {
                bool do_band = false;
                switch(bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M: do_band = ck60.Checked; break;
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M:	do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }
                if(do_band) num_bands++;
            }
            int total_counts = num_bands*(10+10+10+5);

            for(int i=0; i<bands.Length; i++)
            {
                bool do_band = false;
                switch(bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M: do_band = ck60.Checked; break;
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M:	do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if(do_band)
                {
                    // verify RX Level
                    FWC.SetTest(true);
                    FWC.SetSig(true);
                    FWC.SetGen(true);
                    FWC.SetTXMon(false);
                    FWC.SetFullDuplex(true);

                    console.VFOAFreq = band_freqs[i];
                    Thread.Sleep(50);
                    console.VFOBFreq = band_freqs[i];

                    console.RX1PreampMode = PreampMode.HIGH;
                    console.RX1DSPMode = DSPMode.DSB;
                    console.RX1Filter = Filter.VAR1;
                    console.RX1FilterLow = -500;
                    console.RX1FilterHigh = 500;
                    Thread.Sleep(750);

                    int peak_bin = -1;
                    console.calibration_mutex.WaitOne();
                    fixed(float* ptr = &a[0])
                        DttSP.GetSpectrum(0, ptr);
                    console.calibration_mutex.ReleaseMutex();
                    float max = float.MinValue;
                    for(int j=0; j<Display.BUFFER_SIZE; j++)
                    {
                        if(a[j] > max)
                        {
                            max = a[j];
                            peak_bin = j;
                        }
                    }

                    float sum_d = 0.0f;
                    for(int j=0; j<5; j++)
                    {
                        console.calibration_mutex.WaitOne();
                        fixed(float* ptr = &a[0])
                            DttSP.GetSpectrum(0, ptr);
                        console.calibration_mutex.ReleaseMutex();
                        sum_d += a[peak_bin];
                        if(j != 4) Thread.Sleep(100);
                        if(!p.Visible)
                        {
                            p.Text = "";
                            goto end;
                        }
                        p.SetPercent(++counter/(float)total_counts);
                    }
                    sum_d /= 5;
                    sum_d = sum_d + Display.DisplayCalOffset + Display.PreampOffset;

                    float sum_m = 0.0f;
                    DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                    Thread.Sleep(50);
                    for(int j=0; j<5; j++)
                    {
                        sum_m += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                        if(j != 4) Thread.Sleep(50);
                        if(!p.Visible)
                        {
                            p.Text = "";
                            goto end;
                        }
                        p.SetPercent(++counter/(float)total_counts);
                    }
                    sum_m /= 5;
                    sum_m = sum_m + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset;

                    pass_rx_level = (Math.Abs(-25.0 - sum_d) < 1.0f) && (Math.Abs(-25.0 - sum_m) < 1.0f);

                    if(pass_rx_level)
                    {
                        lstDebug.Items.Insert(0, "Verify RX Level "+BandToString(bands[i])+": Passed ("+sum_d.ToString("f1")+", "+sum_m.ToString("f1")+")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "Verify RX Level "+BandToString(bands[i])+": Failed ("+sum_d.ToString("f1")+", "+sum_m.ToString("f1")+")");
                        if(!test_verify_rx_level.StartsWith("RX Level Failed ("))
                            test_verify_rx_level = "RX Level Failed (";
                        test_verify_rx_level += BandToString(bands[i])+", ";
                        if(btnPostFence.BackColor != Color.Red)
                            btnPostFence.BackColor = Color.Red;
                    }

                    // verify RX Image
                    console.VFOSplit = true;
                    FWC.SetQSE(false);

                    console.VFOAFreq = band_freqs[i];
                    Thread.Sleep(50);
                    console.VFOBFreq = band_freqs[i];
                    Thread.Sleep(750);

                    float fundamental = 0.0f;
                    DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                    Thread.Sleep(50);
                    for(int j=0; j<5; j++)
                    {
                        fundamental += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                        if(j != 4) Thread.Sleep(50);
                        if(!p.Visible)
                        {
                            p.Text = "";
                            goto end;
                        }
                        p.SetPercent(++counter/(float)total_counts);
                    }
                    fundamental /= 5;
                    fundamental = fundamental + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset;

                    console.VFOAFreq = band_freqs[i]+2*console.IFFreq;
                    Thread.Sleep(500);

                    float image = 0.0f;
                    DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                    Thread.Sleep(50);
                    for(int j=0; j<5; j++)
                    {
                        image += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                        if(j != 4) Thread.Sleep(50);
                        if(!p.Visible)
                        {
                            p.Text = "";
                            goto end;
                        }
                        p.SetPercent(++counter/(float)total_counts);
                    }
                    image /= 5;
                    image = image + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset;

                    float rejection = fundamental - image;
                    pass_rx_image = (rejection >= 60.0f);

                    if(pass_rx_image)
                    {
                        lstDebug.Items.Insert(0, "Verify RX Image "+BandToString(bands[i])+": Passed ("+fundamental.ToString("f1")+", "+image.ToString("f1")+", "+rejection.ToString("f1")+")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "Verify RX Image "+BandToString(bands[i])+": Failed ("+fundamental.ToString("f1")+", "+image.ToString("f1")+", "+rejection.ToString("f1")+")");
                        if(!test_verify_rx_image.StartsWith("RX Image Failed ("))
                            test_verify_rx_image = "RX Image Failed (";
                        test_verify_rx_image += BandToString(bands[i])+", ";
                        if(btnPostFence.BackColor != Color.Red)
                            btnPostFence.BackColor = Color.Red;
                    }

                    console.VFOSplit = false;

                    // verify TX Image
                    console.FullDuplex = true;
                    Audio.TXInputSignal = Audio.SignalSource.SINE;
                    double last_scale = Audio.SourceScale;			// saved audio scale
                    Audio.SourceScale = 1.0;
                    double tone_freq = Audio.SineFreq1;				// save tone freq
                    Audio.SineFreq1 = 1500.0;						// set freq

                    int pwr = console.PWR;
                    console.PWR = 100;
                    Audio.RadioVolume = 0.200;

                    FWC.SetQSD(true);
                    FWC.SetQSE(true);
                    FWC.SetTR(true);
                    FWC.SetSig(true);
                    FWC.SetGen(false);
                    FWC.SetTest(true);
                    FWC.SetTXMon(false);

                    console.SetupForm.TXFilterLow = 300;
                    console.SetupForm.TXFilterHigh = 3000;

                    console.VFOAFreq = band_freqs[i];
                    Thread.Sleep(50);
                    console.VFOBFreq = band_freqs[i];
                    console.RX1DSPMode = DSPMode.USB;
                    console.UpdateFilters(300, 3000);
                    Thread.Sleep(750);

                    fundamental = 0.0f;
                    DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                    Thread.Sleep(50);
                    for(int j=0; j<5; j++)
                    {
                        fundamental += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                        if(j != 4) Thread.Sleep(50);
                        if(!p.Visible)
                        {
                            p.Text = "";
                            goto end;
                        }
                        p.SetPercent(++counter/(float)total_counts);
                    }
                    fundamental /= 5;
                    fundamental = fundamental + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset;

                    console.UpdateFilters(-1550, -1450);
                    Thread.Sleep(500);

                    image = 0.0f;
                    DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                    Thread.Sleep(50);
                    for(int j=0; j<5; j++)
                    {
                        image += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                        if(j != 4) Thread.Sleep(50);
                        if(!p.Visible)
                        {
                            p.Text = "";
                            goto end;
                        }
                        p.SetPercent(++counter/(float)total_counts);
                    }
                    image /= 5;
                    image = image + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset;

                    rejection = fundamental - image;

                    pass_tx_image = (rejection >= 60.0);

                    if(pass_tx_image)
                    {
                        lstDebug.Items.Insert(0, "Verify TX Image "+BandToString(bands[i])+": Passed ("+fundamental.ToString("f1")+", "+image.ToString("f1")+", "+rejection.ToString("f1")+")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "Verify TX Image "+BandToString(bands[i])+": Failed ("+fundamental.ToString("f1")+", "+image.ToString("f1")+", "+rejection.ToString("f1")+")");
                        if(!test_verify_tx_image.StartsWith("TX Image Failed ("))
                            test_verify_tx_image = "TX Image Failed (";
                        test_verify_tx_image += BandToString(bands[i])+", ";
                        if(btnPostFence.BackColor != Color.Red)
                            btnPostFence.BackColor = Color.Red;
                    }
                    Audio.TXInputSignal = Audio.SignalSource.RADIO;
                    Audio.SourceScale = last_scale;						// recall tone scale
                    Audio.SineFreq1 = tone_freq;						// recall tone freq
                    console.PWR = pwr;
                    FWC.SetTR(false);

                    // verify TX Carrier
                    FWC.SetQSD(true);
                    FWC.SetQSE(true);
                    FWC.SetSig(true);
                    FWC.SetGen(false);
                    FWC.SetTest(true);
                    FWC.SetTXMon(false);
                    Audio.TXInputSignal = Audio.SignalSource.SILENCE;

                    console.VFOAFreq = band_freqs[i];
                    console.VFOBFreq = band_freqs[i];
                    console.RX1DSPMode = DSPMode.DSB;
                    console.UpdateFilters(-500, 500);
                    Thread.Sleep(500);

                    float carrier = 0.0f;
                    DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                    Thread.Sleep(50);
                    for(int j=0; j<5; j++)
                    {
                        carrier += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.SIGNAL_STRENGTH);
                        if(j != 4) Thread.Sleep(50);
                        if(!p.Visible)
                        {
                            p.Text = "";
                            goto end;
                        }
                        p.SetPercent(++counter/(float)total_counts);
                    }
                    carrier /= 5;
                    carrier = carrier + console.MultiMeterCalOffset + console.PreampOffset + console.RXPathOffset;

                    pass_tx_carrier = (carrier <= -105.0);

                    if(pass_tx_carrier)
                    {
                        lstDebug.Items.Insert(0, "Verify TX Carrier "+BandToString(bands[i])+": Passed ("+carrier.ToString("f1")+")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "Verify TX Carrier "+BandToString(bands[i])+": Failed ("+carrier.ToString("f1")+")");
                        if(!test_verify_tx_carrier.StartsWith("TX Carrier Failed ("))
                            test_verify_tx_carrier = "TX Carrier Failed (";
                        test_verify_tx_carrier += BandToString(bands[i])+", ";
                        if(btnPostFence.BackColor != Color.Red)
                            btnPostFence.BackColor = Color.Red;
                    }

                    Audio.TXInputSignal = Audio.SignalSource.RADIO;
                }
            }

            if(!test_verify_rx_level.StartsWith("RX Level Failed ("))
                test_verify_rx_level = "RX Level Passed\n";
            else test_verify_rx_level = test_verify_rx_level.Substring(0, test_verify_rx_level.Length-2)+")\n";

            if(!test_verify_rx_image.StartsWith("RX Image Failed ("))
                test_verify_rx_image = "RX Image Passed\n";
            else test_verify_rx_image = test_verify_rx_image.Substring(0, test_verify_rx_image.Length-2)+")\n";

            if(!test_verify_tx_image.StartsWith("TX Image Failed ("))
                test_verify_tx_image = "TX Image Passed\n";
            else test_verify_tx_image = test_verify_tx_image.Substring(0, test_verify_tx_image.Length-2)+")\n";

            if(!test_verify_tx_carrier.StartsWith("TX Carrier Failed ("))
                test_verify_tx_carrier = "TX Carrier Passed\n";
            else test_verify_tx_carrier = test_verify_tx_carrier.Substring(0, test_verify_tx_carrier.Length-2)+")";

            test_post_fence = test_verify_rx_level + test_verify_rx_image + test_verify_tx_image + test_verify_tx_carrier;

            end:
                FWC.SetTest(false);
            FWC.SetTR(false);
            FWC.SetGen(false);
            FWC.SetSig(false);
            FWC.SetTXMon(false);
            FWC.SetFullDuplex(false);
            console.FullDuplex = false;
            console.SpurReduction = spur_red;
            console.DisplayModeText = display;
            console.RX1PreampMode = preamp;
            console.RX1DSPMode = dsp_mode;
            console.RX1Filter = filter;
            if(filter == Filter.VAR1 || filter == Filter.VAR2)
            {
                console.RX1FilterHigh = rx_filt_high;
                console.RX1FilterLow = rx_filt_low;
            }
            console.RITOn = rit_on;
            console.XITOn = xit_on;
            console.VFOSplit = split;
            console.SetupForm.DSPRXBufferSize = dsp_buf_size;				// set DSP Buffer Size to 2048
            console.SetupForm.Polyphase = polyphase;					// disable polyphase

            toolTip1.SetToolTip(btnPostFence, test_post_fence);

            p.Hide();
            FWC.SetFullDuplex(false);
            grpGeneral.Enabled = true;
            grpReceiver.Enabled = true;
            grpTransmitter.Enabled = true;
            btnPostFence.Enabled = true;

            t1.Stop();
            MessageBox.Show("Verify Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00"));
            */
        }
Ejemplo n.º 28
0
        public void CalTXCarrier()
        {
            float tol = -105.0f;
            test_tx_carrier = "TX Carrier Test: Passed";

            if (!console.PowerOn)
            {
                console.PowerOn = true;
                Thread.Sleep(500);
            }

            if (console.VFOSync)
                console.VFOSync = false;

            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;

            int tx_low = console.TXFilterLow;
            console.TXFilterLow = 100;

            int tx_high = console.TXFilterHigh;
            console.TXFilterHigh = 200;

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            List<double> band_freqs = new List<double>();

            band_freqs.Add(144.2);
            const int NUM_V_POINTS = 9;
            for (int i = 0; i < NUM_V_POINTS; i++)
                band_freqs.Add(144.0 + (148.0 - 144.0) / (NUM_V_POINTS-1) * i);

            band_freqs.Add(432.1);
            band_freqs.Add(432.2);
            const int NUM_U_POINTS = 41;
            for (int i = 0; i < NUM_U_POINTS; i++)
                band_freqs.Add(430.0 + (450.0 - 430.0) / (NUM_U_POINTS-1) * i);

            int begin = 0;
            if (!ck2m.Checked && ck70cm.Checked) // skip V freqs
                begin = NUM_V_POINTS + 1;

            int end = band_freqs.Count;
            if (ck2m.Checked && !ck70cm.Checked)
                end = NUM_V_POINTS + 1;
            else if (!ck2m.Checked && !ck70cm.Checked)
                end = 0;

            for (int i = begin; i < end; i++)
            {
                p.SetPercent(0.0f);
                Invoke(new MethodInvoker(p.Show));
                Application.DoEvents();
                console.VFOAFreq = band_freqs[i];
                console.VFOBFreq = band_freqs[i];
                console.CalibrateTXCarrier(band_freqs[i], p, true);
                //if(console.min_tx_carrier[(int)bands[i]] > tol) // try again
                //	console.CalibrateTXCarrier(band_freqs[i], p, true);

                if (p.Text == "") break;

                float min = console.tx_carrier_min;
                if (min > tol)
                {                    
                    if (!test_tx_carrier.StartsWith("TX Carrier: Failed ("))
                        test_tx_carrier = "TX Carrier: Failed (";
                    test_tx_carrier += band_freqs[i].ToString("f1") + ",";
                    btnTXCarrier.BackColor = Color.Red;
                    lstDebug.Items.Insert(0, "TX Carrier - " + band_freqs[i].ToString("f1") + ": Failed ("
                        + min.ToString("f1") + ")");
                }
                else
                {
                    lstDebug.Items.Insert(0, "TX Carrier - " + band_freqs[i].ToString("f1") + ": Passed ("
                        + min.ToString("f1") + ")");
                }
                Thread.Sleep(500);
            }

            console.TXFilterLow = tx_low;
            console.TXFilterHigh = tx_high;

            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;

            if (test_tx_carrier.StartsWith("TX Carrier Test: Failed ("))
                test_tx_carrier = test_tx_carrier.Substring(0, test_tx_carrier.Length - 1) + ")";

            t1.Stop();
            Debug.WriteLine("TX Carrier Timer: " + t1.Duration);

            string path = console.AppDataPath + "\\Tests";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            path += "\\TX Carrier";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);

            StreamWriter writer = new StreamWriter(path + "\\vu_tx_carrier_F5K_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ".csv");
            writer.WriteLine("Freq, C0, C1, C2, C3, From Noise");
            for (int i = 0; i < band_freqs.Count; i++)
            {
                writer.Write(band_freqs[i].ToString("f6") + ",");
                for (int j = 0; j < 4; j++)
                {
                    double key;
                    console.FindNearestKey(band_freqs[i], console.tx_carrier_cal, out key);
                    uint val = console.tx_carrier_cal[key];
                    writer.Write((val >> 8 * (3 - j)).ToString() + ",");
                    //writer.Write((console.tx_carrier_cal[Math.Round(band_freqs[i], 3)] >> 8 * (3 - j)).ToString() + ",");
                }
                //writer.WriteLine(console.min_tx_carrier[(int)bands[i]].ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving Carrier data to EEPROM...");
            byte checksum;
            FWCEEPROM.WriteTXCarrier(console.tx_carrier_cal, out checksum);
            console.tx_carrier_checksum = checksum;
            console.SyncCalDateTime();
            lstDebug.Items[0] = "Saving Carrier data to EEPROM...done";

            MessageBox.Show("TX Carrier Done: " + t1.Duration);

            btnLevel.Enabled = true;
            btnPA.Enabled = true;
            btnTXCarrier.Enabled = true;
        }
Ejemplo n.º 29
0
        private void RunSelectedTests()
        {
            bool rx2 = console.RX2Enabled;
            console.RX2Enabled = false;

            console.VFOSplit = false;
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            string start_bands = GetStringFromBands();

            #region Gen

            // run all general tests
            if(ckTestGenPLL.Checked)
            {
                Invoke(new MethodInvoker(btnPLL.PerformClick));
                Thread.Sleep(1000);
            }

            if(ckTestGenBal.Checked)
            {
                Invoke(new MethodInvoker(btnGenBal.PerformClick));
                Thread.Sleep(3000);
            }

            if(ckTestGenNoise.Checked)
            {
                Invoke(new MethodInvoker(btnNoise.PerformClick));
                Thread.Sleep(3000);
            }

            if(ckTestGenImpulse.Checked)
            {
                Invoke(new MethodInvoker(btnImpulse.PerformClick));
                Thread.Sleep(3000);
            }

            if(ckTestGenPreamp.Checked)
            {
                Invoke(new MethodInvoker(btnGenPreamp.PerformClick));
                Thread.Sleep(3000);
            }

            // re-run any Gen tests that failed
            if(ckTestGenPLL.Checked && btnPLL.BackColor != Color.Green)
            {
                Invoke(new MethodInvoker(btnPLL.PerformClick));
                Thread.Sleep(1000);
            }

            if(ckTestGenBal.Checked && btnGenBal.BackColor != Color.Green)
            {
                Invoke(new MethodInvoker(btnGenBal.PerformClick));
                Thread.Sleep(3000);
            }

            if(ckTestGenNoise.Checked && btnNoise.BackColor != Color.Green)
            {
                Invoke(new MethodInvoker(btnNoise.PerformClick));
                Thread.Sleep(3000);
            }

            if(ckTestGenImpulse.Checked && btnImpulse.BackColor != Color.Green)
            {
                Invoke(new MethodInvoker(btnImpulse.PerformClick));
                Thread.Sleep(3000);
            }

            if(ckTestGenPreamp.Checked && btnGenPreamp.BackColor != Color.Green)
            {
                Invoke(new MethodInvoker(btnGenPreamp.PerformClick));
                Thread.Sleep(3000);
            }

            if((ckTestGenPLL.Checked && btnPLL.BackColor != Color.Green) ||
                (ckTestGenBal.Checked && btnGenBal.BackColor != Color.Green) ||
                (ckTestGenPreamp.Checked && btnGenPreamp.BackColor != Color.Green))
                goto end;

            #endregion

            #region RX

            // run all RX tests
            if(ckTestRXFilter.Checked)
            {
                Invoke(new MethodInvoker(btnRXFilter.PerformClick));
                while(true)
                {
                    while(p.Visible) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(!p.Visible) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckTestRXLevel.Checked)
            {
                Invoke(new MethodInvoker(btnRXLevel.PerformClick));
                while(true)
                {
                    while(!btnRXLevel.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnRXLevel.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckTestRXImage.Checked)
            {
                Invoke(new MethodInvoker(btnRXImage.PerformClick));
                while(true)
                {
                    while(!btnRXImage.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnRXImage.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            // re-run any RX tests that failed
            if(ckTestRXFilter.Checked && btnRXFilter.BackColor != Color.Green)
            {
                SetBandFromString(toolTip1.GetToolTip(btnRXFilter));
                Invoke(new MethodInvoker(btnRXFilter.PerformClick));
                while(true)
                {
                    while(p.Visible) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(!p.Visible) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckTestRXLevel.Checked && btnRXLevel.BackColor != Color.Green)
            {
                SetBandFromString(toolTip1.GetToolTip(btnRXLevel));
                Invoke(new MethodInvoker(btnRXLevel.PerformClick));
                while(true)
                {
                    while(!btnRXLevel.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnRXLevel.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckTestRXImage.Checked && btnRXImage.BackColor != Color.Green)
            {
                SetBandFromString(toolTip1.GetToolTip(btnRXImage));
                Invoke(new MethodInvoker(btnRXImage.PerformClick));
                while(true)
                {
                    while(!btnRXImage.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnRXImage.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            // reset bands back to start
            SetBandFromString(start_bands);

            /*if((ckTestRXFilter.Checked && btnRXFilter.BackColor != Color.Green) ||
                (ckTestRXLevel.Checked && btnRXLevel.BackColor != Color.Green) ||
                (ckTestRXImage.Checked && btnRXImage.BackColor != Color.Green) ||
                (ckTestRXMDS.Checked && btnRXMDS.BackColor != Color.Green))
                goto end;*/

            #endregion

            #region TX

            // run all TX tests
            if(ckTestTXFilter.Checked)
            {
                Invoke(new MethodInvoker(btnTXFilter.PerformClick));
                while(true)
                {
                    while(p.Visible) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(!p.Visible) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckTestTXImage.Checked)
            {
                Invoke(new MethodInvoker(btnTXImage.PerformClick));
                while(true)
                {
                    while(!btnTXImage.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnTXImage.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckTestTXCarrier.Checked)
            {
                Invoke(new MethodInvoker(btnTXCarrier.PerformClick));
                while(true)
                {
                    while(!btnTXCarrier.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnTXCarrier.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            // re-run any TX tests that failed
            if(ckTestTXFilter.Checked && btnTXFilter.BackColor != Color.Green)
            {
                SetBandFromString(toolTip1.GetToolTip(btnTXFilter));
                Invoke(new MethodInvoker(btnTXFilter.PerformClick));
                while(true)
                {
                    while(p.Visible) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(!p.Visible) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckTestTXImage.Checked && btnTXImage.BackColor != Color.Green)
            {
                SetBandFromString(toolTip1.GetToolTip(btnTXImage));
                Invoke(new MethodInvoker(btnTXImage.PerformClick));
                while(true)
                {
                    while(!btnTXImage.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnTXImage.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckTestTXCarrier.Checked && btnTXCarrier.BackColor != Color.Green)
            {
                SetBandFromString(toolTip1.GetToolTip(btnTXCarrier));
                Invoke(new MethodInvoker(btnTXCarrier.PerformClick));
                while(true)
                {
                    while(!btnTXCarrier.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnTXCarrier.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            SetBandFromString(start_bands);

            #endregion

            end:
                btnRunSelectedTests.BackColor = SystemColors.Control;
            btnRunSelectedTests.Enabled = true;
            console.RX2Enabled = rx2;

            t1.Stop();
            MessageBox.Show("Run All Tests Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00"));
        }
Ejemplo n.º 30
0
        public void RunCalFWCTXImage()
        {
            float tol = -55.0f;
            test_tx_image = "TX Image Test: Passed";

            if (!console.PowerOn)
            {
                console.PowerOn = true;
                Thread.Sleep(500);
            }

            if (console.VFOSync)
                console.VFOSync = false;

            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            float[] band_freqs = { 1.85f, 3.75f, 5.357f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f };
            for (int i = 0; i < band_freqs.Length; i++)
            {
                bool do_band = false;
                switch (bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M:
                        {
                            if (console.CurrentRegion == FRSRegion.US) { do_band = ck60.Checked; break; }
                            else
                            {
                                lstDebug.Items.Insert(0, "TX Image - " + BandToString(bands[i]) + ": Result OK");
                                continue;
                            }
                        }
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M: do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if (do_band)
                {
                    p.SetPercent(0.0f);
                    Invoke(new MethodInvoker(p.Show));
                    Application.DoEvents();
                    console.VFOAFreq = band_freqs[i];
                    console.VFOBFreq = band_freqs[i];
                    console.CalibrateTXImage(band_freqs[i], p, true);
                    if (p.Text == "") break;

                    if (console.tx_image_rejection[(int)bands[i]] > tol)
                    {
                        if (!test_tx_image.StartsWith("TX Image Test: Failed ("))
                            test_tx_image = "TX Image Test: Failed (";
                        test_tx_image += BandToString(bands[i]) + ",";
                        btnTXImage.BackColor = Color.Red;
                        lstDebug.Items.Insert(0, "TX Image - " + BandToString(bands[i]) + ": Failed ("
                            + console.tx_image_rejection[(int)bands[i]].ToString("f1") + ")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "TX Image - " + BandToString(bands[i]) + ": Passed ("
                            + console.tx_image_rejection[(int)bands[i]].ToString("f1") + ")");
                    }

                    Thread.Sleep(500);
                }
            }
            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;

            t1.Stop();
            Debug.WriteLine("TX Image Timer: " + t1.Duration);

            if (test_tx_image.StartsWith("TX Image Test: Failed ("))
                test_tx_image = test_tx_image.Substring(0, test_tx_image.Length - 1) + ")";
            toolTip1.SetToolTip(btnTXImage, test_tx_image);

            string path = console.AppDataPath + "\\Tests";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            bool file_exists = File.Exists(path + "\\tx_image.csv");
            StreamWriter writer = new StreamWriter(path + "\\tx_image.csv", true);

            string serial = "";
            switch (console.CurrentModel)
            {
                case Model.FLEX5000:
                case Model.FLEX3000:
                    serial = FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial);
                    break;
                case Model.FLEX1500:
                    serial = HIDEEPROM.SerialToString(HIDEEPROM.SerialNumber);
                    break;
            }

            if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, "
                                  + "160m gain, 160m phase, 160m rejection, "
                                  + "80m gain, 80m phase, 80m rejection, "
                                  + "60m gain, 60m phase, 60m rejection, "
                                  + "40m gain, 40m phase, 40m rejection, "
                                  + "30m gain, 30m phase, 30m rejection, "
                                  + "20m gain, 20m phase, 20m rejection, "
                                  + "17m gain, 17m phase, 17m rejection, "
                                  + "15m gain, 15m phase, 15m rejection, "
                                  + "12m gain, 12m phase, 12m rejection, "
                                  + "10m gain, 10m phase, 10m rejection, "
                                  + "6m gain, 6m phase, 6m rejection, ");
            writer.Write(console.CurrentModel.ToString() + ","
                + serial + ","
                + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ","
                + console.Text + ",");
            for (int i = 0; i < bands.Length; i++)
            {
                writer.Write(console.tx_image_gain_table[(int)bands[i]].ToString("f3") + ",");
                writer.Write(console.tx_image_phase_table[(int)bands[i]].ToString("f3") + ",");
                writer.Write(console.tx_image_rejection[(int)bands[i]].ToString("f1") + ",");
            }
            writer.WriteLine("");
            writer.Close();

            path += "\\TX Image";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            string model = "";
            switch (console.CurrentModel)
            {
                case Model.FLEX3000: model = "F3K"; break;
                case Model.FLEX5000: model = "F5K"; break;
                case Model.FLEX1500: model = "F1.5K"; break;
            }
            writer = new StreamWriter(path + "\\tx_image_" + model + "_" + serial + ".csv");
            writer.WriteLine("Band, Gain, Phase, Rejection dBc");
            for (int i = 0; i < bands.Length; i++)
            {
                writer.Write(BandToString(bands[i]) + ",");
                writer.Write(console.tx_image_gain_table[(int)bands[i]].ToString("f3") + ",");
                writer.Write(console.tx_image_phase_table[(int)bands[i]].ToString("f3") + ",");
                writer.WriteLine(console.tx_image_rejection[(int)bands[i]].ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving TX Image data to EEPROM...");
            byte gain_sum = 0, phase_sum = 0;
            switch (console.CurrentModel)
            {
                case Model.FLEX5000:
                case Model.FLEX3000:
                    FWCEEPROM.WriteTXImage(console.tx_image_gain_table, console.tx_image_phase_table, out gain_sum, out phase_sum);
                    break;
                case Model.FLEX1500:
                    HIDEEPROM.WriteTXImage(console.tx_image_gain_table, console.tx_image_phase_table, out gain_sum, out phase_sum);
                    break;
            }
            console.tx_image_gain_checksum = gain_sum;
            console.tx_image_phase_checksum = phase_sum;
            console.SyncCalDateTime();
            lstDebug.Items[0] = "Saving TX Image data to EEPROM...done";

            grpGeneral.Enabled = true;
            grpReceiver.Enabled = true;
            grpTransmitter.Enabled = true;
            grpIO.Enabled = true;
        }
Ejemplo n.º 31
0
        unsafe private void KeyThread() // changes yt7pwr
        {
            try
            {
                int[] tmp     = new int[1];
                bool  tune_CW = false;

                //do
                {
                    DttSP.KeyerStartedWait();

                    while (runKeyer)
                    {
                        timer.Start();
                        DttSP.PollTimerWait();
                        CWMonitorState = DttSP.KeyerPlaying();

                        if (tuneCW && !tune_CW)
                        {
                            tune_CW = true;
                            secondary_keyer_dash = false;
                            secondary_keyer_dot  = true;
                        }
                        else if (!tuneCW && tune_CW)
                        {
                            tune_CW = false;
                            secondary_keyer_dash = false;
                            secondary_keyer_dot  = false;
                        }
                        else if (memoryptt)
                        {
                            //console ptt on
                            keyprog             = true;
                            secondary_keyer_dot = secondary_keyer_dash = memorykey;

                            if (console.CWMonitorEnabled)
                            {
                                if (console.CurrentModel == Model.LimeSDR)
                                {
                                }
                            }
                        }
                        else if (!tune_CW)
                        {
                            secondary_keyer_dash = false;
                            secondary_keyer_dot  = false;
                            keyprog = false;
                        }

                        if (enabled_secondary_keyer && (secondary_keyer_mox || ptt_bit_bang_enabled))
                        {
                            keyprog = false;

                            switch (secondary_conn_port)
                            {
                            case "None":
                                break;

                            default:     // comm port
                                if (sp2.IsOpen)
                                {
                                    switch (secondary_dot_line)
                                    {
                                    case KeyerLine.DSR:
                                        secondary_keyer_dot = sp2.DsrHolding;
                                        break;

                                    case KeyerLine.CTS:
                                        secondary_keyer_dot = sp2.CtsHolding;
                                        break;

                                    case KeyerLine.DCD:
                                        secondary_keyer_dot = sp2.CDHolding;
                                        break;

                                    case KeyerLine.NONE:
                                        secondary_keyer_dot = false;
                                        break;
                                    }
                                    switch (secondary_dash_line)
                                    {
                                    case KeyerLine.DSR:
                                        secondary_keyer_dash = sp2.DsrHolding;
                                        break;

                                    case KeyerLine.CTS:
                                        secondary_keyer_dash = sp2.CtsHolding;
                                        break;

                                    case KeyerLine.DCD:
                                        secondary_keyer_dash = sp2.CDHolding;
                                        break;

                                    case KeyerLine.NONE:
                                        secondary_keyer_dash = false;
                                        break;
                                    }
                                }
                                break;
                            }
                        }

                        if (enabled_primary_keyer && !secondary_keyer_mox && !memoryptt)
                        {
                            switch (primary_conn_port)
                            {
                            case "USB":
                            {
                                switch (console.CurrentModel)
                                {
                                case Model.LimeSDR:
                                {
                                    if (console.limeSDR.device != null && console.limeSDR.connected)
                                    {
                                        uint key = console.limeSDR.device.ReadKeyer();
                                        key = key & 0xc0;
                                        //Debug.Write("Keyer: " + key.ToString() + " \n");

                                        if (key == 0x40)
                                        {
                                            primary_keyer_dash = true;
                                            primary_keyer_dot  = false;
                                        }
                                        else if (key == 0x80)
                                        {
                                            primary_keyer_dot  = true;
                                            primary_keyer_dash = false;
                                        }
                                        else
                                        {
                                            primary_keyer_dot  = false;
                                            primary_keyer_dash = false;
                                        }
                                    }
                                    else
                                    {
                                        primary_keyer_dot  = false;
                                        primary_keyer_dash = false;
                                    }
                                }
                                break;
                                }
                            }
                            break;

                            default:
                                if (sp.IsOpen)
                                {
                                    keyprog = false;

                                    keyprog            = false;
                                    primary_keyer_dash = sp.CtsHolding;
                                    primary_keyer_dot  = sp.DsrHolding;

                                    if (dtr_cw_monitor && console.CWMonitorEnabled)
                                    {
                                        if (CWMonitorState)
                                        {
                                            CW_monitor(true);
                                        }
                                        else
                                        {
                                            CW_monitor(false);
                                        }
                                    }
                                }
                                break;
                            }
                        }

                        timer.Stop();
                        msdel = (float)timer.DurationMsec;
                        //msdel = (float)DttSP.TimerRead();
                        //Debug.Write(msdel.ToString() + "\n");

                        if (keyprog || secondary_keyer_mox || tune_CW || ptt_bit_bang_enabled)
                        {
                            //keyprog = false;
                            DttSP.KeyValue(msdel, secondary_keyer_dash, secondary_keyer_dot, keyprog);
                            keyprog = false;
                        }
                        else if (primary_keyer_mox)
                        {
                            DttSP.KeyValue(msdel, primary_keyer_dash, primary_keyer_dot, keyprog);
                        }
                        else if (enabled_primary_keyer && !secondary_keyer_mox && !memoryptt)
                        {
                            DttSP.KeyValue(msdel, primary_keyer_dash, primary_keyer_dot, keyprog);
                        }
                        else
                        {
                            DttSP.KeyValue(msdel, false, false, false);
                            primary_keyer_mox   = false;
                            secondary_keyer_mox = false;
                            keyprog             = false;
                        }
                    }
                }// while (true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in KeyThread!\n" + ex.ToString());
            }
        }
        public void RunCalFWCTXSpur()
        {
            float tol = -80.0f;
            test_tx_spur = "TX Spur Test: Passed";

            if (!console.PowerOn)
            {
                console.PowerOn = true;
                Thread.Sleep(500);
            }

            if (console.VFOSync)
                console.VFOSync = false;

            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;

            int tx_low = console.TXFilterLow;
            console.TXFilterLow = 100;

            int tx_high = console.TXFilterHigh;
            console.TXFilterHigh = 200;

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            float[] band_freqs = { 1.85f, 3.55f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f };
            for (int i = 0; i < band_freqs.Length; i++)
            {
                bool do_band = false;
                switch (bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M: do_band = ck60.Checked; break;
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M: do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if (do_band)
                {
                    progress.SetPercent(0.0f);
                    Invoke(new MethodInvoker(progress.Show));
                    Application.DoEvents();

                    console.VFOAFreq = band_freqs[i];
                    console.VFOBFreq = band_freqs[i];

                    console.CalTXSpur(band_freqs[i], progress);

                    if (progress.Text == "") break;

                    if (console.tx_spur_level[(int)bands[i]] > tol)
                    {
                        if (!test_tx_spur.StartsWith("TX Spur Test: Failed ("))
                            test_tx_spur = "TX Spur Test: Failed (";
                        test_tx_spur += BandToString(bands[i]) + ",";
                        btnTXSpur.BackColor = Color.Red;
                        lstDebug.Items.Insert(0, "TX Spur - " + BandToString(bands[i]) + ": Failed ("
                            + console.tx_spur_level[(int)bands[i]].ToString("f1") + ")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "TX Spur - " + BandToString(bands[i]) + ": Passed ("
                            + console.tx_spur_level[(int)bands[i]].ToString("f1") + ")");
                    }
                    Thread.Sleep(500);
                }
            }

            console.TXFilterLow = tx_low;
            console.TXFilterHigh = tx_high;

            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;

            if (test_tx_spur.StartsWith("TX Spur Test: Failed ("))
                test_tx_spur = test_tx_spur.Substring(0, test_tx_spur.Length - 1) + ")";
            toolTip1.SetToolTip(btnTXSpur, test_tx_spur);

            t1.Stop();
            Debug.WriteLine("TX Spur Timer: " + t1.Duration);

            string path = console.AppDataPath + "\\Tests";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            bool file_exists = File.Exists(path + "\\tx_spur.csv");
            StreamWriter writer = new StreamWriter(path + "\\tx_spur.csv", true);
            if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, "
                                  + "160m, 80m, 60m, 40m, 30m, 20m, 17m, 15m, 12m, 10m, 6m,");
            writer.Write(console.CurrentModel.ToString() + ","
                + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ","
                + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ","
                + console.Text + ",");
            for (int i = 0; i < bands.Length; i++)
            {
                writer.Write(console.tx_spur_level[(int)bands[i]].ToString("f1") + ",");
            }
            writer.WriteLine("");
            writer.Close();

            path += "\\TX Spur";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            string model = "";
            switch (console.CurrentModel)
            {
                case Model.FLEX5000: model = "F5K"; break;
            }
            writer = new StreamWriter(path + "\\tx_spur_" + model + "_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ".csv");
            writer.WriteLine("Band, dBc");
            for (int i = 0; i < bands.Length; i++)
            {
                writer.Write(BandToString(bands[i]) + ",");
                writer.WriteLine(console.tx_spur_level[(int)bands[i]].ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving Carrier data to EEPROM...");
            byte checksum;
            FWCEEPROM.WriteTXCarrier(console.tx_carrier_table, out checksum);
            console.tx_carrier_checksum = checksum;
            console.SyncCalDateTime();
            lstDebug.Items[0] = "Saving Carrier data to EEPROM...done";

            /*grpGeneral.Enabled = true;
            grpReceiver.Enabled = true;
            grpTransmitter.Enabled = true;*/
        }
Ejemplo n.º 33
0
        private void RunSel()
        {
            console.VFOSplit = false;
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            string start_bands = GetStringFromBands();

            #region Tests

            // run all general tests
            if(ckRunGenBal.Checked)
            {
                Invoke(new MethodInvoker(btnTestGenBal.PerformClick));
                Thread.Sleep(3000);
            }

            /*if(ckRunNoise.Checked)
            {
                Invoke(new MethodInvoker(btnTestNoise.PerformClick));
                Thread.Sleep(3000);
            }*/

            if(ckRunPreamp.Checked)
            {
                Invoke(new MethodInvoker(btnTestPreamp.PerformClick));
                Thread.Sleep(3000);
            }

            if(ckRunFilters.Checked)
            {
                Invoke(new MethodInvoker(btnTestFilters.PerformClick));
                while(true)
                {
                    while(p.Visible) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(!p.Visible) break;
                }
                if(p.Text == "") goto end;
            }

            // re-run any tests that failed
            if(ckRunGenBal.Checked && btnTestGenBal.BackColor != Color.Green)
            {
                Invoke(new MethodInvoker(btnTestGenBal.PerformClick));
                Thread.Sleep(3000);
            }

            /*if(ckRunNoise.Checked && btnTestNoise.BackColor != Color.Green)
            {
                Invoke(new MethodInvoker(btnTestNoise.PerformClick));
                Thread.Sleep(3000);
            }*/

            if(ckRunPreamp.Checked && btnTestPreamp.BackColor != Color.Green)
            {
                Invoke(new MethodInvoker(btnTestPreamp.PerformClick));
                Thread.Sleep(3000);
            }

            if(ckRunFilters.Checked && btnTestFilters.BackColor != Color.Green)
            {
                SetBandFromString(toolTip1.GetToolTip(btnTestFilters));
                Invoke(new MethodInvoker(btnTestFilters.PerformClick));
                while(true)
                {
                    while(p.Visible) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(!p.Visible) break;
                }
                if(p.Text == "") goto end;
            }

            // reset bands back to start
            SetBandFromString(start_bands);

            if((ckRunGenBal.Checked && btnTestGenBal.BackColor != Color.Green) ||
                (ckRunPreamp.Checked && btnTestPreamp.BackColor != Color.Green) ||
                (ckRunFilters.Checked && btnTestFilters.BackColor != Color.Green))
                goto end;

            #endregion

            #region Cal

            // run all calibrations
            if(ckCalLevel.Checked)
            {
                Invoke(new MethodInvoker(btnCalLevel.PerformClick));
                while(true)
                {
                    while(!btnCalLevel.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnCalLevel.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckCalImage.Checked)
            {
                Invoke(new MethodInvoker(btnCalImage.PerformClick));
                while(true)
                {
                    while(!btnCalImage.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnCalImage.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            // re-run any RX tests that failed
            if(ckCalLevel.Checked && btnCalLevel.BackColor != Color.Green)
            {
                SetBandFromString(toolTip1.GetToolTip(btnCalLevel));
                Invoke(new MethodInvoker(btnCalLevel.PerformClick));
                while(true)
                {
                    while(!btnCalLevel.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnCalLevel.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            if(ckCalImage.Checked && btnCalImage.BackColor != Color.Green)
            {
                SetBandFromString(toolTip1.GetToolTip(btnCalImage));
                Invoke(new MethodInvoker(btnCalImage.PerformClick));
                while(true)
                {
                    while(!btnCalImage.Enabled) Thread.Sleep(2000);
                    Thread.Sleep(2000);
                    if(btnCalImage.Enabled) break;
                }
                if(p.Text == "") goto end;
            }

            // reset bands back to start
            SetBandFromString(start_bands);

            /*if((ckTestRXFilter.Checked && btnRXFilter.BackColor != Color.Green) ||
                (ckTestRXLevel.Checked && btnRXLevel.BackColor != Color.Green) ||
                (ckTestRXImage.Checked && btnRXImage.BackColor != Color.Green) ||
                (ckTestRXMDS.Checked && btnRXMDS.BackColor != Color.Green))
                goto end;*/

            #endregion

            end:
                btnRunSel.BackColor = SystemColors.Control;
            btnRunSel.Enabled = true;

            t1.Stop();
            MessageBox.Show("Run Selected Time: "+((int)(t1.Duration/60)).ToString()+":"+(((int)t1.Duration)%60).ToString("00"));
        }
Ejemplo n.º 34
0
        public void CalRX2Level()
        {
            float[] offset_avg = {-55.7f, -55.8f, -56.1f, -57.6f, -55.1f, -56.0f, -55.9f, -56.3f, -55.4f, -55.8f, -55.0f};
            float[] offset_avg2 = {-62.6f, -61.5f, -61.8f, -62.8f, -61.9f, -61.9f, -61.3f, -60.8f, -60.7f, -61.4f, -60.7f};
            float[] preamp_avg = {-13.7f, -7.1f, -13.5f, -13.8f, -14.2f, -14.2f, -14.1f, -14.0f, -14.0f, -14.0f, -13.9f};
            float[] preamp_avg2 = {-12.4f, -3.8f, -14.0f, -15.1f, -12.9f, -13.4f, -14.6f, -15.6f, -14.7f, -14.0f, -14.1f};
            float offset_tol = 2.5f;	// maximum distance from the average value
            float preamp_tol = 1.5f;

            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;

            bool rx1_sr = console.SpurReduction;
            console.SpurReduction = false;

            bool rx2_sr = console.RX2SpurReduction;
            console.RX2SpurReduction = false;

            DSPMode dsp_mode = console.RX2DSPMode;
            console.RX2DSPMode = DSPMode.DSB;

            bool rit_on = console.RITOn;
            console.RITOn = false;

            bool rx2 = console.RX2Enabled;
            console.RX2Enabled = true;

            PreampMode preamp = console.RX1PreampMode;
            console.RX1PreampMode = PreampMode.OFF;

            PreampMode preamp2 = console.RX2PreampMode;
            console.RX2PreampMode = PreampMode.OFF;

            FWC.SetTest(true);
            Thread.Sleep(50);
            FWC.SetSig(true);
            Thread.Sleep(50);
            FWC.SetGen(true);
            Thread.Sleep(200);

            console.VFOAFreq = 14.2;
            console.VFOBFreq = 14.2;

            console.RX1PreampMode = PreampMode.OFF;
            console.RX2PreampMode = PreampMode.OFF;

            DSPMode dsp = console.RX1DSPMode;
            DSPMode dsp2 = console.RX2DSPMode;

            console.RX1DSPMode = DSPMode.DSB;
            console.RX2DSPMode = DSPMode.DSB;

            console.VFOAFreq = 14.2;
            console.VFOBFreq = 14.2;

            Filter filter = console.RX2Filter;
            int var_low = console.RX2FilterLow;
            int var_high = console.RX2FilterHigh;
            console.UpdateRX2Filters(-1000, 1000);

            Thread.Sleep(50);
            FWC.SetRX2Ant(6); // RX1 Tap
            Thread.Sleep(500);

            float rx1_adc = 0.0f;
            DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.ADC_REAL);
            Thread.Sleep(50);
            for(int j=0; j<5; j++)
            {
                rx1_adc += DttSP.CalculateRXMeter(0, 0, DttSP.MeterType.ADC_REAL);
                if(j != 4) Thread.Sleep(50);
            }
            rx1_adc /= 5;

            float rx2_adc = 0.0f;
            DttSP.CalculateRXMeter(2, 0, DttSP.MeterType.ADC_REAL);
            Thread.Sleep(50);
            for(int j=0; j<5; j++)
            {
                rx2_adc += DttSP.CalculateRXMeter(2, 0, DttSP.MeterType.ADC_REAL);
                if(j != 4) Thread.Sleep(50);
            }
            rx2_adc /= 5;

            console.RX1DSPMode = dsp;
            console.RX2DSPMode = dsp2;

            float res_offset = rx1_adc-rx2_adc;
            console.rx2_res_offset = res_offset;
            bool resistor = ((rx1_adc-rx2_adc)>4.0);
            Debug.WriteLine("resistor: "+resistor+" "+res_offset.ToString("f2"));

            test_rx2_level = "RX2 Level Test: Passed";
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B6M, Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M };
            float[] band_freqs = { 50.11f, 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f };

            for(int i=0; i<band_freqs.Length; i++)
            {
                bool do_band = false;
                switch(bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M: do_band = ck60.Checked; break;
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M:	do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if(do_band)
                {
                    p.SetPercent(0.0f);
                    Invoke(new MethodInvoker(p.Show));
                    Application.DoEvents();
                    console.VFOAFreq = band_freqs[i];
                    console.VFOBFreq = band_freqs[i];
                    console.CalibrateRX2Level(-24.0f, band_freqs[i], p, true);
                    if(p.Text == "") break;

                    float display_offset = console.GetRX2Level(bands[i], 0);
                    float preamp_offset = console.GetRX2Level(bands[i], 1);
                    float meter_offset = console.GetRX2Level(bands[i], 2);

                    if((resistor &&
                        ((Math.Abs(display_offset-offset_avg[i]) > offset_tol) ||
                        (Math.Abs(preamp_offset-preamp_avg[i]) > preamp_tol))) ||
                        (!resistor &&
                        ((Math.Abs(display_offset-offset_avg2[i]) > offset_tol) ||
                        (Math.Abs(preamp_offset-preamp_avg2[i]) > preamp_tol))))
                    {
                        btnCalLevel.BackColor = Color.Red;
                        if(!test_rx2_level.StartsWith("RX2 Level Test: Failed ("))
                            test_rx2_level = "RX2 Level Test: Failed (";
                        test_rx2_level += BandToString(bands[i])+", ";
                        lstDebug.Items.Insert(0, "RX2 Level Cal - "+BandToString(bands[i])+": Failed ("
                            +display_offset.ToString("f1")+", "
                            +preamp_offset.ToString("f1")+", "
                            +meter_offset.ToString("f1")+")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "RX2 Level Cal - "+BandToString(bands[i])+": Passed ("
                            +display_offset.ToString("f1")+", "
                            +preamp_offset.ToString("f1")+", "
                            +meter_offset.ToString("f1")+")");
                    }

                    Thread.Sleep(500);
                }
            }

            if(test_rx2_level.StartsWith("RX2 Level Test: Failed ("))
                test_rx2_level = test_rx2_level.Substring(0, test_rx2_level.Length-2)+")";
            toolTip1.SetToolTip(btnCalLevel, test_rx2_level);

            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;

            t1.Stop();
            Debug.WriteLine("RX Level Timer: "+t1.Duration);

            string path = Application.StartupPath+"\\Tests";
            if(!Directory.Exists(path))	Directory.CreateDirectory(path);
            bool file_exists = File.Exists(path+"\\rx2_level.csv");
            StreamWriter writer = new StreamWriter(path+"\\rx2_level.csv", true);
            if(!file_exists) writer.WriteLine("Serial Num, Date/Time, Version, "
                                 +"6m display offset, 6m preamp offset, 6m multimeter offset, "
                                 +"160m display offset, 160m preamp offset, 160m multimeter offset, "
                                 +"80m display offset, 80m preamp offset, 80m multimeter offset, "
                                 +"60m display offset, 60m preamp offset, 60m multimeter offset, "
                                 +"40m display offset, 40m preamp offset, 40m multimeter offset, "
                                 +"30m display offset, 30m preamp offset, 30m multimeter offset, "
                                 +"20m display offset, 20m preamp offset, 20m multimeter offset, "
                                 +"17m display offset, 17m preamp offset, 17m multimeter offset, "
                                 +"15m display offset, 15m preamp offset, 15m multimeter offset, "
                                 +"12m display offset, 12m preamp offset, 12m multimeter offset, "
                                 +"10m display offset, 10m preamp offset, 10m multimeter offset");
            writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.RX2Serial)+","
                +DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString()+","
                +console.Text+",");
            for(int i=0; i<bands.Length; i++)
            {
                for(int j=0; j<3; j++)
                {
                    writer.Write(console.GetRX2Level(bands[i], j).ToString("f1"));
                    if(i!=bands.Length-1 || j!=2) writer.Write(",");
                }
            }
            writer.WriteLine("");
            writer.Close();

            path += "\\RX2 Level";
            if(!Directory.Exists(path))	Directory.CreateDirectory(path);
            writer = new StreamWriter(path+"\\rx2_level_"+FWCEEPROM.SerialToString(FWCEEPROM.RX2Serial)+".csv");
            writer.WriteLine("Band, Display Offset, Preamp Offset, Multimeter Offset");
            for(int i=0; i<bands.Length; i++)
            {
                writer.Write(BandToString(bands[i])+",");
                writer.Write(console.GetRX2Level(bands[i], 0).ToString("f1")+",");
                writer.Write(console.GetRX2Level(bands[i], 1).ToString("f1")+",");
                writer.WriteLine(console.GetRX2Level(bands[i], 2).ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving Level data to EEPROM...");
            FWCEEPROM.WriteRX2Level(console.rx2_level_table);
            console.RX2SyncCalDateTime();
            lstDebug.Items[0] = "Saving Level data to EEPROM...done";

            grpTests.Enabled = true;
            grpCal.Enabled = true;
        }
Ejemplo n.º 35
0
        private void PollPTT()
        {
            HiPerfTimer cwpolltimer = new HiPerfTimer();
            cwpolltimer.Start();

            while(chkPower.Checked)
            {
                // reset the CW ring buffers every 1000ms when not in use
                if(current_ptt_mode != PTTMode.NONE)
                {
                    switch(rx1_dsp_mode)
                    {
                        case DSPMode.CWL:
                        case DSPMode.CWU:
                            cwpolltimer.Start(); // start over since key is in use
                            break;
                    }
                }
                else
                {
                    switch(rx1_dsp_mode)
                    {
                        case DSPMode.CWL:
                        case DSPMode.CWU:
                            cwpolltimer.Stop(); // check how long since last reset
                            if(cwpolltimer.DurationMsec > 5000 + break_in_delay && !mox)
                            {
                                // if more than 5 sec + break in delay, reset timer and ring buffer
                                cwpolltimer.Start();
                                DttSP.CWRingRestart();
                                if(fwc_init && current_model == Model.FLEX5000)
                                    FWC.SetPABias(false);
                            }
                            break;
                    }
                }

                if(!manual_mox && !disable_ptt && !rx_only)
                {
                    bool mic_ptt = false, x2_ptt = false, cw_ptt = false, cat_ptt_local = false, vox_ptt = false;
                    bool keyer_playing = DttSP.KeyerPlaying();
                    if(fwc_init && current_model == Model.FLEX5000)
                    {
                        cw_ptt = (cw_semi_break_in_enabled && keyer_playing) || Keyer.KeyerPTT || Keyer.MemoryPTT;
                        mic_ptt = fwc_mic_ptt;
                        x2_ptt = fwc_rca_ptt;
                        vox_ptt = Audio.VOXActive;
                        cat_ptt_local = (ptt_bit_bang_enabled && serialPTT != null && serialPTT.isPTT()) | cat_ptt;
                    }
                    else
                    {
                        byte b = Hdw.StatusPort();
                        cw_ptt = (cw_semi_break_in_enabled && keyer_playing) || Keyer.KeyerPTT || Keyer.MemoryPTT;
                        mic_ptt = (b & (byte)StatusPin.Dot) != 0;

                        bool loop_ptt = (DttSP.GetLoopPTT() != 0);
                        mic_ptt = loop_ptt | mic_ptt;

                        if ( !mic_ptt )  // check aux sources for ptt if not already set
                        {
                            if ( (JanusAudio.GetDotDash() & 0x1) != 0 )
                            {
                                mic_ptt = true;
                            }
                            if ( !mic_ptt )  // if we're not in cw mode take either of the serial port keyer lines as ptt - mostly for soft rock support.
                            {
                                if ( rx1_dsp_mode != DSPMode.CWL && rx1_dsp_mode != DSPMode.CWU )
                                {
                                    if ( Keyer.PrimaryConnPort != "SDR" && Keyer.PrimaryConnPort != "Ozy" )
                                    {
                                        if ( Keyer.sp.CtsHolding ) mic_ptt = true;
                                        else if ( Keyer.sp.DsrHolding ) mic_ptt = true;
                                    }
                                }
                            }
                        }

            //						x2_ptt = (b & (byte)StatusPin.PIN_11) != 0;
                        if(usb_present) x2_ptt = !((b & (byte)StatusPin.PIN_11) != 0);
                        vox_ptt = Audio.VOXActive;
                        cat_ptt_local = (ptt_bit_bang_enabled && serialPTT != null && serialPTT.isPTT()) | cat_ptt;

                        if(auto_mute)
                        {
                            bool mute = !((b & (byte)StatusPin.PIN_12) != 0);
                            if(chkMUT.Checked != mute) chkMUT.Checked = mute;
                        }
                    }

                    /*Debug.WriteLine(cw_ptt.ToString().PadRight(6, ' ')+
                        mic_ptt.ToString().PadRight(6, ' ')+
                        x2_ptt.ToString().PadRight(6, ' ')+
                        vox_ptt.ToString().PadRight(6, ' ')+
                        cat_ptt_local.ToString().PadRight(6, ' ')+
                        current_ptt_mode.ToString());*/

                    if (cw_ptt) break_in_timer.Start();

                    if(!mox)
                    {
                        if(x2_ptt)
                        {
                            current_ptt_mode = PTTMode.X2;
                            switch(rx1_dsp_mode)
                            {
                                case DSPMode.CWL:
                                case DSPMode.CWU:
                                    if(!cw_disable_monitor)
                                    {
                                        mon_recall = chkMON.Checked;
                                        chkMON.Checked = true;
                                    }
                                    break;
                                case DSPMode.LSB:
                                case DSPMode.USB:
                                case DSPMode.DSB:
                                case DSPMode.AM:
                                case DSPMode.SAM:
                                case DSPMode.FMN:
                                case DSPMode.DIGL:
                                case DSPMode.DIGU:
                                    if(chkPhoneVAC.Checked && allow_vac_bypass)
                                        Audio.VACBypass = true;
                                    break;
                            }

                            chkMOX.Checked = true;
                            if(!mox)
                            {
                                chkPower.Checked = false;
                                return;
                            }
                        }

                        if(cat_ptt_local)
                        {
                            current_ptt_mode = PTTMode.CAT;
                            if(rx1_dsp_mode == DSPMode.CWL ||
                                rx1_dsp_mode == DSPMode.CWU)
                            {
                                if(!cw_disable_monitor)
                                {
                                    mon_recall = chkMON.Checked;
                                    chkMON.Checked = true;
                                }
                            }

                            chkMOX.Checked = true;
                            if(!mox)
                            {
                                chkPower.Checked = false;
                                return;
                            }
                        }

                        if((rx1_dsp_mode == DSPMode.CWL ||
                            rx1_dsp_mode == DSPMode.CWU) &&
                            cw_ptt)
                        {
                            current_ptt_mode = PTTMode.CW;
                            cwpolltimer.Start();
                            if(!cw_disable_monitor)
                            {
                                mon_recall = chkMON.Checked;
                                chkMON.Checked = true;
                            }
                            chkMOX.Checked = true;
                            if(!mox)
                            {
                                chkPower.Checked = false;
                                return;
                            }
                        }

                        if((rx1_dsp_mode == DSPMode.LSB ||
                            rx1_dsp_mode == DSPMode.USB ||
                            rx1_dsp_mode == DSPMode.DSB ||
                            rx1_dsp_mode == DSPMode.AM  ||
                            rx1_dsp_mode == DSPMode.SAM ||
                            rx1_dsp_mode == DSPMode.DIGU ||
                            rx1_dsp_mode == DSPMode.DIGL ||
                            rx1_dsp_mode == DSPMode.FMN ||
                            all_mode_mic_ptt) &&
                            mic_ptt)
                        {
                            current_ptt_mode = PTTMode.MIC;

                            if(chkPhoneVAC.Checked && allow_vac_bypass)
                                Audio.VACBypass = true;

                            chkMOX.Checked = true;
                            if(!mox)
                            {
                                chkPower.Checked = false;
                                return;
                            }
                        }

                        if((rx1_dsp_mode == DSPMode.LSB ||
                            rx1_dsp_mode == DSPMode.USB ||
                            rx1_dsp_mode == DSPMode.DSB ||
                            rx1_dsp_mode == DSPMode.AM  ||
                            rx1_dsp_mode == DSPMode.SAM ||
                            rx1_dsp_mode == DSPMode.DIGU ||
                            rx1_dsp_mode == DSPMode.DIGL ||
                            rx1_dsp_mode == DSPMode.FMN) &&
                            vox_ptt)
                        {
                            current_ptt_mode = PTTMode.VOX;
                            vox_timer.Start();
                            chkMOX.Checked = true;
                            if(!mox)
                            {
                                chkPower.Checked = false;
                                return;
                            }
                        }
                    }
                    else // else if(mox)
                    {
                        switch(current_ptt_mode)
                        {
                            case PTTMode.X2:
                                if(!x2_ptt)
                                {
                                    chkMOX.Checked = false;
                                    switch(rx1_dsp_mode)
                                    {
                                        case DSPMode.CWL:
                                        case DSPMode.CWU:
                                            if(!cw_disable_monitor)
                                                chkMON.Checked = mon_recall;
                                            break;
                                        case DSPMode.LSB:
                                        case DSPMode.USB:
                                        case DSPMode.DSB:
                                        case DSPMode.AM:
                                        case DSPMode.SAM:
                                        case DSPMode.FMN:
                                        case DSPMode.DIGL:
                                        case DSPMode.DIGU:
                                            if(chkPhoneVAC.Checked && Audio.VACBypass)
                                                Audio.VACBypass = false;
                                            break;
                                    }
                                }
                                break;
                            case PTTMode.CAT:
                                if(!cat_ptt_local)
                                {
                                    chkMOX.Checked = false;
                                    if((rx1_dsp_mode == DSPMode.CWL ||
                                        rx1_dsp_mode == DSPMode.CWU) &&
                                        !cw_disable_monitor)
                                        chkMON.Checked = mon_recall;
                                }
                                break;
                            case PTTMode.MIC:
                                if(!mic_ptt)
                                {
                                    chkMOX.Checked = false;
                                    if(chkPhoneVAC.Checked && Audio.VACBypass)
                                        Audio.VACBypass = false;
                                }
                                break;
                            case PTTMode.CW:
                                if(!cw_ptt)
                                {
                                    if (cw_semi_break_in_enabled)
                                    {
                                        break_in_timer.Stop();
                                        if (break_in_timer.DurationMsec > break_in_delay)
                                        {
                                            chkMOX.Checked = false;
                                            if((rx1_dsp_mode == DSPMode.CWL ||
                                                rx1_dsp_mode == DSPMode.CWU) &&
                                                !cw_disable_monitor)
                                                chkMON.Checked = mon_recall;
                                            //DttSP.CWRingRestart(); // removed to stop glitches found by EHR -- added to bias switch off
                                        }
                                    }
                                    else
                                    {
                                        break_in_timer.Stop();
                                        if (break_in_timer.DurationMsec > 43)
                                        {
                                            chkMOX.Checked = false;
                                            if((rx1_dsp_mode == DSPMode.CWL ||
                                                rx1_dsp_mode == DSPMode.CWU) &&
                                                !cw_disable_monitor)
                                                chkMON.Checked = mon_recall;
                                        }
                                    }
                                }
                                break;
                            case PTTMode.VOX:
                                if(!vox_ptt)
                                {
                                    vox_timer.Stop();
                                    if(vox_timer.DurationMsec > vox_hang_time)
                                        chkMOX.Checked = false;
                                }
                                else vox_timer.Start();
                                break;
                        }
                    }
                }
                Thread.Sleep(2);
                /*				polltimer.Stop();
                                msecs += polltimer.DurationMsec;
                                if (++pollcount == 1000)
                                {
                                    msecs *= 0.001;
                                    Debug.WriteLine("timer average = " +msecs.ToString());
                                    pollcount = 0;
                                }*/
            }
            //			poll_ptt_running = false;
        }
Ejemplo n.º 36
0
        public bool CalibrateTXImage(float freq, Progress progress, bool suppress_errors)
        {
            if(!fwc_init || current_model != Model.FLEX5000)
            {
                progress.Text = "";
                progress.Hide();
                return false;
            }

            if(!chkPower.Checked)
            {
                if(!suppress_errors)
                {
                    MessageBox.Show("Power must be on in order to calibrate TX Image.", "Power Is Off",
                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                calibration_running = false;
                progress.Text = "";
                tx_image_rejection[(int)tx_band] = 0.0f;
                return false;
            }

            float tol = 10.0f;
            float phase_step = 2;
            float gain_step = 2;
            float global_min_phase = 0;
            float global_min_gain = 0;
            float gain_index = 0.0f, phase_index = 0.0f;
            float global_min_value = float.MaxValue;
            bool progressing = true;
            int gain_dir = -1;
            int phase_dir = 1;
            int gain_count = 1, phase_count = 1;
            int wrong_direction_count;
            int switch_direction_count;
            string index_string;
            string val_string;
            string gain_string = "";
            string phase_string = "";
            float fundamental = -200.0f;

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            HiPerfTimer t2 = new HiPerfTimer();

            // Setup Rig for TX Image Null Cal
            bool ret_val = false;
            calibration_running = true;

            //int retval = 0;
            progress.SetPercent(0.0f);

            bool spur_red = chkSR.Checked;					// save current spur reduction setting
            chkSR.Checked = false;							// turn spur reduction off

            bool polyphase = SetupForm.Polyphase;			// save current polyphase setting
            SetupForm.Polyphase = false;					// disable polyphase

            int dsp_buf_size = SetupForm.DSPPhoneRXBuffer;		// save current DSP buffer size
            SetupForm.DSPPhoneRXBuffer = 4096;					// set DSP Buffer Size to 4096

            DSPMode dsp_mode = rx1_dsp_mode;			// save current dsp mode
            RX1DSPMode = DSPMode.USB;					// set dsp mode to USB

            // Setting filters for TX calibration (optmized for SSB) and we need to fix the VAR filter setting
            // consequence of this action

            string display_mode = comboDisplayMode.Text;
            comboDisplayMode.Text = "Spectrum";

            bool avg = chkDisplayAVG.Checked;				// save current average state
            chkDisplayAVG.Checked = true;

            Filter filter = rx1_filter;					// save current filter
            UpdateRX1Filters(300, 3000);						// set filter to -3k, -300 ... LSB for image

            int tx_filt_low = SetupForm.TXFilterLow;		// save tx filter low cut
            SetupForm.TXFilterLow = 300;					// set low cut to 300Hz

            int tx_filt_high = SetupForm.TXFilterHigh;		// save tx filter high cut
            SetupForm.TXFilterHigh = 3000;					// set high cut to 3kHz

            PreampMode preamp = rx1_preamp_mode;		// save current preamp setting
            RX1PreampMode = PreampMode.HIGH;			// set preamp to high

            bool duplex = full_duplex;
            FullDuplex = true;

            double vfo_freq = VFOAFreq;						// save current frequency
            VFOAFreq = freq;								// set frequency to passed value
            VFOBFreq = freq;

            Audio.TXInputSignal = Audio.SignalSource.SINE;
            double last_scale = Audio.SourceScale;			// saved audio scale
            Audio.SourceScale = 1.0;
            double tone_freq = Audio.SineFreq1;				// save tone freq
            Audio.SineFreq1 = 1500.0;						// set freq

            int pwr = (int)udPWR.Value;
            udPWR.Value = 100;
            Audio.RadioVolume = 0.200;

            FWC.SetQSD(true);
            Thread.Sleep(50);
            FWC.SetQSE(true);
            Thread.Sleep(50);
            FWC.SetTR(true);
            Thread.Sleep(50);
            FWC.SetSig(true);
            Thread.Sleep(50);
            FWC.SetGen(false);
            Thread.Sleep(50);
            FWC.SetTest(true);
            Thread.Sleep(50);
            FWC.SetTXMon(false);
            Thread.Sleep(50);

            DisableAllFilters();
            DisableAllModes();
            VFOLock = true;
            comboPreamp.Enabled = false;
            comboDisplayMode.Enabled = false;

            SetupForm.ImageGainTX = -200.0f;
            SetupForm.ImagePhaseTX = -200.0f;

            float[] a = new float[Display.BUFFER_SIZE];
            for(int i=0; i<5; i++)
            {
                calibration_mutex.WaitOne();
                fixed(float* ptr = &a[0])
                    DttSP.GetSpectrum(0, ptr);// get the spectrum values
                calibration_mutex.ReleaseMutex();
                Thread.Sleep(50);
            }

            float max_signal = float.MinValue;
            int peak_bin = 2048+(int)(1500.0/sample_rate1*4096.0);

            Thread.Sleep(100);
            for(int i=0; i<20; i++)
            {
                calibration_mutex.WaitOne();
                fixed(float* ptr = &a[0])
                    DttSP.GetSpectrum(0, ptr);// get the spectrum values
                calibration_mutex.ReleaseMutex();
                for(int j=0; i==19 && j<Display.BUFFER_SIZE; j++)
                {
                    if(a[j] > max_signal)
                    {
                        max_signal = a[j];
                        peak_bin = j;
                    }
                }
                Thread.Sleep(100);
            }
            fundamental = max_signal;
            UpdateRX1Filters(-3000, -300);
            Thread.Sleep(100);

            peak_bin = 2048+(int)(-1500.0/sample_rate1*4096.0);
            max_signal = float.MinValue;
            float sum = 0.0f;
            int filt_low_bin = 2048+(int)(-3000.0/sample_rate1*4096.0);
            int filt_high_bin = 2048+(int)(-300.0/sample_rate1*4096.0);
            for(int i=0; i<20; i++)
            {
                calibration_mutex.WaitOne();
                fixed(float* ptr = &a[0])
                    DttSP.GetSpectrum(0, ptr);// get the spectrum values
                calibration_mutex.ReleaseMutex();
                for(int j=0; i==19 && j<Display.BUFFER_SIZE; j++)
                {
                    if(a[j] > max_signal)
                    {
                        max_signal = a[j];
                        peak_bin = j;
                    }
                }
                for(int j=filt_low_bin; j<filt_high_bin; j++) // TODO fix limits for 48/96kHz
                {
                    if(j<peak_bin-8 || j > peak_bin+8)
                        sum += a[j];
                }
                Thread.Sleep(100);
            }
            float noise_floor = (sum / (float)(((filt_high_bin-filt_low_bin)-17)*20));
            Debug.WriteLine("noise_floor: "+noise_floor.ToString("f6")+" peak_bin:"+peak_bin);
            //MessageBox.Show("Noise Floor: "+(noise_floor + Display.DisplayCalOffset + Display.PreampOffset).ToString("f1"));

            if(max_signal < noise_floor + 30.0)
            {
                if(!suppress_errors)
                {
                    MessageBox.Show("Image not found (max signal < noise floor + 30dB).  Please try again.\n"+
                        DateTime.Now.ToShortTimeString(),
                        "Image Not Found",
                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                calibration_running = false;
                //progress.Text = "";
                goto end;
            }

            SetupForm.ImagePhaseTX = 0.0f;
            SetupForm.ImageGainTX = 0.0f;

            while(progressing)
            {
                // find minimum of the peak signal over
                // the range of Gain settings

                float start = 0.0f;
                float min_signal = float.MaxValue;
                max_signal = float.MinValue;
                wrong_direction_count = switch_direction_count = 0;
                bool first_time = true;

                Debug.WriteLine("gain_dir:"+gain_dir+" gain_step: "+gain_step.ToString("f3"));
                t2.Start();
                index_string = "";
                val_string = "";
                gain_string += (gain_count+","+gain_dir+","+gain_step.ToString("f6")+"\n");
                for(float i=global_min_gain; i >= -500.0 && i <= 500.0; i+=(gain_step*gain_dir))
                {
                    SetupForm.ImageGainTX = i;				//set gain slider
                    Thread.Sleep(200);

                    int num_avg = gain_count;
                    //if(gain_step <= 0.01) num_avg = 4;
                    sum = 0.0f;
                    for(int j=0; j<num_avg; j++)
                    {
                        calibration_mutex.WaitOne();
                        fixed(float* ptr = &a[0])
                            DttSP.GetSpectrum(0, ptr);// get the spectrum values
                        sum += a[peak_bin];
                        calibration_mutex.ReleaseMutex();
                        if(j<num_avg-1) Thread.Sleep(50);
                    }
                    sum /= num_avg;
                    a[peak_bin] = sum;

                    index_string += i.ToString("f4")+",";
                    val_string += a[peak_bin].ToString("f4")+",";

                    if(a[peak_bin] < min_signal)			// if image is less than minimum
                    {
                        min_signal = a[peak_bin];
                        gain_index = i;
                        if(min_signal < global_min_value)
                        {
                            global_min_value = min_signal;
                            global_min_gain = gain_index;
                        }
                    }

                    // cal complete condition
                    if(min_signal < noise_floor+12.0f)
                    {
                        progressing = false;
                        break;
                    }

                    if(first_time)
                    {
                        first_time = false;
                        start = a[peak_bin];
                        max_signal = a[peak_bin];
                    }
                    else
                    {
                        if(a[peak_bin] > max_signal && a[peak_bin] > start+1.0)
                        {
                            max_signal = a[peak_bin];
                            wrong_direction_count++; Debug.Write("W");
                            if(wrong_direction_count > 1)
                            {
                                wrong_direction_count = 0;
                                if(++switch_direction_count > 1)
                                {
                                    // handle switched direction twice
                                    if(gain_step >= 0.1) gain_step /= 2.0f;
                                    else gain_step /= 2.0f;
                                    gain_dir *= -1;
                                    Debug.WriteLine("gain exit dir - gain_step:"+gain_step.ToString("f4")+"  distance:"+(global_min_value-noise_floor).ToString("f1"));
                                    break;
                                }

                                min_signal = start;
                                max_signal = start;
                                gain_dir *= -1;
                                i = global_min_gain;
                            }
                        }
                        else
                        {
                            if(min_signal > noise_floor + 20.0) tol = 3.0f;
                            else tol = 3.0f;
                            if (a[peak_bin] > min_signal + tol)
                            {
                                if(gain_step > 0.1) gain_step /= 2.0f;
                                else gain_step /= 2.0f;
                                gain_dir *= -1;
                                Debug.WriteLine("exit gain thresh - gain_step:"+gain_step.ToString("f4")+"  distance:"+(global_min_value-noise_floor).ToString("f1"));
                                break;
                            }
                        }
                    }

                    if(!progress.Visible) goto end;
                    else
                    {
                        t1.Stop();
                        if(t1.Duration > 90.0)
                        {
                            /*MessageBox.Show("TX Image Reject Calibration Failed.  Values have been returned to previous settings.\n"+
                                DateTime.Now.ToShortTimeString(),
                                "TX Image Failed",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);*/
                            goto end;
                        }
                        else progress.SetPercent((float)(t1.Duration/90.0));
                    }
                }

                t2.Stop();
                Debug.WriteLine("t2 gain("+gain_count+++"): "+t2.Duration);
                if(gain_count < 10)
                {
                    gain_string += (index_string+"\n");
                    gain_string += (val_string+"\n\n");
                }

                SetupForm.ImageGainTX = global_min_gain;			//set gain slider to min found

                if(!progressing) break;

                // find minimum of the peak signal over
                // the range of Phase settings
                min_signal = float.MaxValue;
                max_signal = float.MinValue;
                wrong_direction_count = switch_direction_count = 0;
                first_time = true;

                t2.Start();
                index_string = "";
                val_string = "";
                phase_string += (phase_count+","+phase_dir+","+phase_step.ToString("f3")+"\n");
                for(float i=global_min_phase; i >= -400.0 && i <= 400.0; i+=(phase_step*phase_dir))
                {
                    SetupForm.ImagePhaseTX = i;				// phase slider
                    Thread.Sleep(200);

                    sum = 0.0f;
                    int num_avg = phase_count;
                    //if(phase_step <= 0.01) num_avg = 4;
                    for(int j=0; j<num_avg; j++)
                    {
                        calibration_mutex.WaitOne();
                        fixed(float* ptr = &a[0])
                            DttSP.GetSpectrum(0, ptr);// get the spectrum values
                        sum += a[peak_bin];
                        calibration_mutex.ReleaseMutex();
                        if(j<num_avg-1) Thread.Sleep(50);
                    }
                    sum /= num_avg;
                    a[peak_bin] = sum;

                    index_string += i.ToString("f4")+",";
                    val_string += a[peak_bin].ToString("f4")+",";

                    if(a[peak_bin] < min_signal)			// if image is less than minimum
                    {
                        min_signal = a[peak_bin];
                        phase_index = i;
                        if(min_signal < global_min_value)
                        {
                            global_min_value = min_signal;
                            global_min_phase = phase_index;
                        }
                    }

                    // cal complete condition
                    if(min_signal < noise_floor+12.0f)
                    {
                        progressing = false;
                        break;
                    }

                    if(first_time)
                    {
                        first_time = false;
                        start = a[peak_bin];
                        max_signal = a[peak_bin];
                    }
                    else
                    {
                        if(a[peak_bin] > max_signal && a[peak_bin] > start+1.0)
                        {
                            max_signal = a[peak_bin];
                            wrong_direction_count++;Debug.Write("W");
                            if(wrong_direction_count > 1)
                            {
                                wrong_direction_count = 0;
                                if(++switch_direction_count > 1)
                                {
                                    // handle switched direction twice
                                    if(phase_step >= 0.1) phase_step /= 2.0f;
                                    else phase_step /= 2.0f;
                                    phase_dir *= -1;
                                    Debug.WriteLine("phase exit dir - phase_step:"+phase_step.ToString("f4")+"  distance:"+(global_min_value-noise_floor).ToString("f1"));
                                    break;
                                }

                                min_signal = start;
                                max_signal = start;
                                phase_dir *= -1;
                                i = global_min_phase;
                            }
                        }
                        else
                        {
                            if(min_signal > noise_floor + 20.0) tol = 3.0f;
                            else tol = 3.0f;
                            if (a[peak_bin] > min_signal + tol)
                            {
                                if(phase_step >= 0.1) phase_step /= 2.0f;
                                else phase_step /= 2.0f;
                                phase_dir *= -1;
                                Debug.WriteLine("phase exit thresh - phase_step:"+phase_step.ToString("f4")+"  distance:"+(global_min_value-noise_floor).ToString("f1"));
                                break;
                            }
                        }
                    }

                    if(!progress.Visible) goto end;
                    else
                    {
                        t1.Stop();
                        if(t1.Duration > 90.0)
                        {
                            /*MessageBox.Show("TX Image Reject Calibration Failed.  Values have been returned to previous settings.\n"+
                                DateTime.Now.ToShortTimeString(),
                                "TX Image Failed",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);*/
                            goto end;
                        }
                        else progress.SetPercent((float)(t1.Duration/90.0));
                    }
                }

                t2.Stop();
                Debug.WriteLine("t2 phase("+phase_count+++"): "+t2.Duration);

                SetupForm.ImagePhaseTX = global_min_phase;			//set phase slider to min found

                if(!progressing) break;
            }

            // Finish the algorithm and reset the values
            ret_val = true;
            end:
                if(!progress.Visible) progress.Text = "";
                else
                {
                    tx_image_gain_table[(int)tx_band] = SetupForm.ImageGainTX;
                    tx_image_phase_table[(int)tx_band] = SetupForm.ImagePhaseTX;
                }
            progress.Hide();
            calibration_running = false;

            tx_image_rejection[(int)tx_band] = global_min_value - fundamental;

            Audio.TXInputSignal = Audio.SignalSource.RADIO;
            Audio.SourceScale = last_scale;						// recall tone scale
            Audio.SineFreq1 = tone_freq;						// recall tone freq
            udPWR.Value = pwr;

            FullDuplex = duplex;
            Thread.Sleep(50);
            FWC.SetQSD(true);
            Thread.Sleep(50);
            FWC.SetQSE(false);
            Thread.Sleep(50);
            FWC.SetTR(false);
            Thread.Sleep(50);
            FWC.SetSig(false);
            Thread.Sleep(50);
            FWC.SetGen(false);
            Thread.Sleep(50);
            FWC.SetTest(false);
            Thread.Sleep(50);
            FWC.SetTXMon(false);
            Thread.Sleep(50);

            EnableAllFilters();
            EnableAllModes();
            VFOLock = false;
            comboPreamp.Enabled = true;
            comboDisplayMode.Enabled = true;

            SetupForm.TXFilterHigh = tx_filt_high;				// restore TX filter settings
            SetupForm.TXFilterLow = tx_filt_low;
            chkSR.Checked = spur_red;							// restore spur reduction setting
            RX1PreampMode = preamp;							// restore preamp mode
            comboDisplayMode.Text = display_mode;				// restore display mode
            //SetupForm.RXOnly = rx_only;							// restore RX Only setting
            RX1DSPMode = dsp_mode;							// restore dsp mode
            RX1Filter = filter;								// restore filter
            VFOAFreq = vfo_freq;								// restore frequency
            txtVFOAFreq_LostFocus(this, EventArgs.Empty);
            chkDisplayAVG.Checked = avg;						// restore average state
            SetupForm.DSPPhoneRXBuffer = dsp_buf_size;				// restore DSP Buffer Size
            SetupForm.Polyphase = polyphase;					// restore polyphase

            t1.Stop();
            //MessageBox.Show(t1.Duration.ToString());
            Debug.WriteLine("timer: "+t1.Duration);

            return ret_val;
        }
Ejemplo n.º 37
0
        private void btnEEReadFloat_Click(object sender, EventArgs e)
        {
            ushort offset = ushort.Parse(txtOffset.Text, NumberStyles.HexNumber);
            //byte num_bytes = 4;

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            int val;
            byte[] temp = new byte[4];
            val = Flex1500.ReadEEPROM((ushort)offset, 4, out temp);
            float f = BitConverter.ToSingle(temp, 0);

            t1.Stop();

            txtEERead.Text = f.ToString("f6");
            
            Debug.WriteLine("EERead Float: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 38
0
        public void RunCalRXLevel()
        {
            //float[] offset_avg = {-59.3f, -60.5f, -61.1f, -61.4f, -60.8f, -60.5f, -60.0f, -59.5f, -59.5f, -59.5f, -59.6f};
            //float[] preamp_avg = {-13.4f, -7.0f, -13.3f, -13.6f, -14.0f, -14.0f, -14.0f, -13.8f, -13.8f, -13.8f, -13.7f};
            //float offset_tol = 2.5f;	// maximum distance from the average value
            //float preamp_tol = 1.5f;

            test_rx_level = "RX Level Test: Passed";
            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;

            int tx_low = console.TXFilterLow;
            console.TXFilterLow = 100;

            int tx_high = console.TXFilterHigh;
            console.TXFilterHigh = 200;

            /*int dsp_phone_buf_size = console.SetupForm.DSPPhoneRXBuffer;			// save current DSP buffer size
            int dsp_cw_buf_size = console.SetupForm.DSPCWRXBuffer;			// save current DSP buffer size
            int dsp_dig_buf_size = console.SetupForm.DSPDigRXBuffer;			// save current DSP buffer size
            console.SetupForm.DSPPhoneRXBuffer = 2048;						// set DSP Buffer Size to 2048
            console.SetupForm.DSPCWRXBuffer = 2048;
            console.SetupForm.DSPDigRXBuffer = 2048;*/

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B6M, Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M };
            float[] band_freqs = { 50.11f, 1.85f, 3.75f, 5.357f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f };

            if (!console.PowerOn)
            {
                console.PowerOn = true;
                Thread.Sleep(500);
            }

            float level = (float)udLevel.Value;

            if (console.VFOSync)
                console.VFOSync = false;

            for (int i = 0; i < band_freqs.Length; i++)
            {
                bool do_band = false;
                switch (bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M:
                        {
                            if (console.CurrentRegion == FRSRegion.US) { do_band = ck60.Checked; break; }
                            else
                            {
                                lstDebug.Items.Insert(0, "RX Level Test - " + BandToString(bands[i]) + ": Result OK");
                                continue;
                            }
                        }
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M: do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if (do_band)
                {
                    p.SetPercent(0.0f);
                    Invoke(new MethodInvoker(p.Show));
                    Application.DoEvents();
                    console.VFOAFreq = band_freqs[i];
                    console.VFOBFreq = band_freqs[i];
                    console.CalibrateLevel(level, band_freqs[i], p, true);
                    if (p.Text == "") break;

                    if (console.CurrentModel == Model.FLEX1500)
                    {
                        if (console.GetRX1Level(bands[i], 0) >= -96.0 &&
                            console.GetRX1Level(bands[i], 0) <= -84.0)
                        {
                            lstDebug.Items.Insert(0, "RX Level Test - " + BandToString(bands[i]) + ": Passed ("
                                + console.GetRX1Level(bands[i], 0).ToString("f1") + ", "
                                + console.GetRX1Level(bands[i], 1).ToString("f1") + ", "
                                + console.GetRX1Level(bands[i], 2).ToString("f1") + ")");
                        }
                        else
                        {
                            btnRXLevel.BackColor = Color.Red;
                            if (!test_rx_level.StartsWith("RX Level Test: Failed ("))
                                test_rx_level = "RX Level Test: Failed (";
                            test_rx_level += BandToString(bands[i]) + ",";
                            lstDebug.Items.Insert(0, "RX Level Test - " + BandToString(bands[i]) + ": Failed ("
                                + console.GetRX1Level(bands[i], 0).ToString("f1") + ", "
                                + console.GetRX1Level(bands[i], 1).ToString("f1") + ", "
                                + console.GetRX1Level(bands[i], 2).ToString("f1") + ")");
                        }
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "RX Level Test - " + BandToString(bands[i]) + ": Passed ("
                                + console.GetRX1Level(bands[i], 0).ToString("f1") + ", "
                                + console.GetRX1Level(bands[i], 1).ToString("f1") + ", "
                                + console.GetRX1Level(bands[i], 2).ToString("f1") + ")");
                    }

                    Thread.Sleep(500);
                }
            }

            /*console.SetupForm.DSPPhoneRXBuffer = dsp_phone_buf_size;
            console.SetupForm.DSPCWRXBuffer = dsp_cw_buf_size;
            console.SetupForm.DSPDigRXBuffer = dsp_dig_buf_size;*/
            console.TXFilterLow = tx_low;
            console.TXFilterHigh = tx_high;

            if (test_rx_level.StartsWith("RX Level Test: Failed ("))
                test_rx_level = test_rx_level.Substring(0, test_rx_level.Length - 2) + ")";
            toolTip1.SetToolTip(btnRXLevel, test_rx_level);

            console.VFOAFreq = vfoa; Thread.Sleep(10);
            console.VFOBFreq = vfob;

            t1.Stop();
            Debug.WriteLine("RX Level Timer: " + t1.Duration);

            string path = console.AppDataPath + "\\Tests";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            bool file_exists = File.Exists(path + "\\rx_level.csv");
            StreamWriter writer = new StreamWriter(path + "\\rx_level.csv", true);
            if (!file_exists) writer.WriteLine("Model, Serial Num, Date/Time, Version, "
                                  + "6m display offset, 6m preamp offset, 6m multimeter offset, "
                                  + "160m display offset, 160m preamp offset, 160m multimeter offset, "
                                  + "80m display offset, 80m preamp offset, 80m multimeter offset, "
                                  + "60m display offset, 60m preamp offset, 60m multimeter offset, "
                                  + "40m display offset, 40m preamp offset, 40m multimeter offset, "
                                  + "30m display offset, 30m preamp offset, 30m multimeter offset, "
                                  + "20m display offset, 20m preamp offset, 20m multimeter offset, "
                                  + "17m display offset, 17m preamp offset, 17m multimeter offset, "
                                  + "15m display offset, 15m preamp offset, 15m multimeter offset, "
                                  + "12m display offset, 12m preamp offset, 12m multimeter offset, "
                                  + "10m display offset, 10m preamp offset, 10m multimeter offset");
            writer.Write(console.CurrentModel.ToString() + ",");
            switch (console.CurrentModel)
            {
                case Model.FLEX5000:
                case Model.FLEX3000:
                    writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ",");
                    break;
                case Model.FLEX1500:
                    writer.Write(HIDEEPROM.SerialToString(HIDEEPROM.TRXSerial) + ",");
                    break;
            }
            writer.Write(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ","
                + console.Text + ",");
            for (int i = 0; i < bands.Length; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    writer.Write(console.GetRX1Level(bands[i], j).ToString("f1"));
                    if (i != bands.Length - 1 || j != 2) writer.Write(",");
                }
            }
            writer.WriteLine("");
            writer.Close();

            path += "\\RX Level";
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);

            string filename = "";
            switch (console.CurrentModel)
            {
                case Model.FLEX5000:
                    filename = path + "\\rx_level_F5K_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ".csv";
                    break;
                case Model.FLEX3000:
                    filename = path + "\\rx_level_F3K_" + FWCEEPROM.SerialToString(FWCEEPROM.TRXSerial) + ".csv";
                    break;
                case Model.FLEX1500:
                    filename = path + "\\rx_level_F1.5K_" + HIDEEPROM.SerialToString(HIDEEPROM.SerialNumber) + ".csv";
                    break;
            }
            writer = new StreamWriter(filename);
            writer.WriteLine("Band, Display Offset, Preamp Offset, Multimeter Offset");
            for (int i = 0; i < bands.Length; i++)
            {
                writer.Write(BandToString(bands[i]) + ",");
                writer.Write(console.GetRX1Level(bands[i], 0).ToString("f1") + ",");
                writer.Write(console.GetRX1Level(bands[i], 1).ToString("f1") + ",");
                writer.WriteLine(console.GetRX1Level(bands[i], 2).ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving Level data to EEPROM...");
            byte checksum = 0;
            switch (console.CurrentModel)
            {
                case Model.FLEX5000:
                case Model.FLEX3000:
                    FWCEEPROM.WriteRXLevel(console.rx1_level_table, out checksum);
                    break;
                case Model.FLEX1500:
                    HIDEEPROM.WriteRXLevel(console.rx1_level_table, out checksum);
                    break;
            }
            console.rx1_level_checksum = checksum;
            console.SyncCalDateTime(); Thread.Sleep(10);
            lstDebug.Items[0] = "Saving Level data to EEPROM...done";

            grpGeneral.Enabled = true;
            grpReceiver.Enabled = true;
            grpTransmitter.Enabled = true;
            grpIO.Enabled = true;
        }
Ejemplo n.º 39
0
        private void btnI2CWrite2_Click(object sender, EventArgs e)
        {
            byte addr = byte.Parse(txtI2CAddr.Text, NumberStyles.HexNumber);
            byte b1 = byte.Parse(txtI2CByte1.Text, NumberStyles.HexNumber);
            byte b2 = byte.Parse(txtI2CByte2.Text, NumberStyles.HexNumber);

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            int val = USBHID.WriteI2C2Value(addr, b1, b2);

            t1.Stop();
            Debug.WriteLine("I2C2: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 40
0
        private void btnI2CRead_Click(object sender, EventArgs e)
        {
            byte addr = byte.Parse(txtI2CAddr.Text, NumberStyles.HexNumber);
            byte b1 = byte.Parse(txtI2CByte1.Text, NumberStyles.HexNumber);
            byte b2;

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            int val = USBHID.ReadI2CValue(addr, b1, out b2);

            t1.Stop();
            Debug.WriteLine("I2C Read: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
            txtI2CResult.Text = b2.ToString("X").PadLeft(2, '0');
        }
Ejemplo n.º 41
0
        unsafe private void KeyThread() // changes yt7pwr
        {
            try
            {
                int[] tmp     = new int[1];
                bool  tune_CW = false;

                //do
                {
                    DttSP.KeyerStartedWait();

                    while (runKeyer)
                    {
                        timer.Start();
                        DttSP.PollTimerWait();
                        CWMonitorState = DttSP.KeyerPlaying();

                        if (tuneCW && !tune_CW)
                        {
                            tune_CW = true;
                            secondary_keyer_dash = false;
                            secondary_keyer_dot  = true;
                        }
                        else if (!tuneCW && tune_CW)
                        {
                            tune_CW = false;
                            secondary_keyer_dash = false;
                            secondary_keyer_dot  = false;
                        }
                        else if (memoryptt)
                        {
                            //console ptt on
                            keyprog             = true;
                            secondary_keyer_dot = secondary_keyer_dash = memorykey;

                            if (console.CWMonitorEnabled)
                            {
                                if (console.CurrentModel == Model.GENESIS_G6)
                                {
                                    if (memorykey)
                                    {
                                        if (!CW_monitor_on && cw_monitor_enabled)
                                        {
                                            console.g6.WriteToDevice(24, 1); // CW monitor on
                                            CW_monitor_off = false;
                                            CW_monitor_on  = true;
                                        }
                                    }
                                    else
                                    {
                                        if (!CW_monitor_off && cw_monitor_enabled)
                                        {
                                            console.g6.WriteToDevice(24, 0);  // CW monitor off
                                            CW_monitor_on  = false;
                                            CW_monitor_off = true;
                                        }
                                    }
                                }
                                else if (console.CurrentModel == Model.GENESIS_G59USB)
                                {
                                    if (memorykey)
                                    {
                                        if (!CW_monitor_on && cw_monitor_enabled)
                                        {
                                            console.g59.WriteToDevice(24, 1); // CW monitor on
                                            CW_monitor_off = false;
                                            CW_monitor_on  = true;
                                        }
                                    }
                                    else
                                    {
                                        if (!CW_monitor_off && cw_monitor_enabled)
                                        {
                                            console.g59.WriteToDevice(24, 0);  // CW monitor off
                                            CW_monitor_on  = false;
                                            CW_monitor_off = true;
                                        }
                                    }
                                }
                                else if (console.CurrentModel == Model.GENESIS_G59NET)
                                {
                                    if (memorykey)
                                    {
                                        if (!CW_monitor_on && cw_monitor_enabled)
                                        {
                                            console.net_device.WriteToDevice(24, 1); // CW monitor on
                                            CW_monitor_off = false;
                                            CW_monitor_on  = true;
                                        }
                                    }
                                    else
                                    {
                                        if (!CW_monitor_off && cw_monitor_enabled)
                                        {
                                            console.net_device.WriteToDevice(24, 0);  // CW monitor off
                                            CW_monitor_on  = false;
                                            CW_monitor_off = true;
                                        }
                                    }
                                }
                                else if (console.CurrentModel == Model.GENESIS_G11)
                                {
                                    if (memorykey)
                                    {
                                        if (!CW_monitor_on && cw_monitor_enabled)
                                        {
                                            console.g11.WriteToDevice(24, 1); // CW monitor on
                                            CW_monitor_off = false;
                                            CW_monitor_on  = true;
                                        }
                                    }
                                    else
                                    {
                                        if (!CW_monitor_off && cw_monitor_enabled)
                                        {
                                            console.g11.WriteToDevice(24, 0);  // CW monitor off
                                            CW_monitor_on  = false;
                                            CW_monitor_off = true;
                                        }
                                    }
                                }
                                else if (console.CurrentModel == Model.GENESIS_G160 ||
                                         console.CurrentModel == Model.GENESIS_G3020 ||
                                         console.CurrentModel == Model.GENESIS_G40 ||
                                         console.CurrentModel == Model.GENESIS_G80)
                                {
                                    if (memorykey)
                                    {
                                        if (!CW_monitor_on && cw_monitor_enabled)
                                        {
                                            CW_monitor(true);
                                            CW_monitor_off = false;
                                            CW_monitor_on  = true;
                                        }
                                    }
                                    else
                                    {
                                        if (!CW_monitor_off && cw_monitor_enabled)
                                        {
                                            CW_monitor(false);
                                            CW_monitor_on  = false;
                                            CW_monitor_off = true;
                                        }
                                    }
                                }
                            }
                        }
                        else if (!tune_CW)
                        {
                            secondary_keyer_dash = false;
                            secondary_keyer_dot  = false;
                            keyprog = false;
                        }

                        if (enabled_secondary_keyer && (secondary_keyer_mox || ptt_bit_bang_enabled))
                        {
                            keyprog = false;

                            switch (secondary_conn_port)
                            {
                            case "None":
                                break;

                            default:     // comm port
                                if (sp2.IsOpen)
                                {
                                    switch (secondary_dot_line)
                                    {
                                    case KeyerLine.DSR:
                                        secondary_keyer_dot = sp2.DsrHolding;
                                        break;

                                    case KeyerLine.CTS:
                                        secondary_keyer_dot = sp2.CtsHolding;
                                        break;

                                    case KeyerLine.DCD:
                                        secondary_keyer_dot = sp2.CDHolding;
                                        break;

                                    case KeyerLine.NONE:
                                        secondary_keyer_dot = false;
                                        break;
                                    }
                                    switch (secondary_dash_line)
                                    {
                                    case KeyerLine.DSR:
                                        secondary_keyer_dash = sp2.DsrHolding;
                                        break;

                                    case KeyerLine.CTS:
                                        secondary_keyer_dash = sp2.CtsHolding;
                                        break;

                                    case KeyerLine.DCD:
                                        secondary_keyer_dash = sp2.CDHolding;
                                        break;

                                    case KeyerLine.NONE:
                                        secondary_keyer_dash = false;
                                        break;
                                    }

                                    if (console.CWMonitorEnabled)
                                    {
                                        if (console.CurrentModel == Model.GENESIS_G59USB)
                                        {
                                            if (CWMonitorState)
                                            {
                                                if (!CW_monitor_on && cw_monitor_enabled)
                                                {
                                                    console.g59.WriteToDevice(24, 1);     // CW monitor on
                                                    CW_monitor_off = false;
                                                    CW_monitor_on  = true;
                                                }
                                            }
                                            else
                                            {
                                                if (!CW_monitor_off && cw_monitor_enabled)
                                                {
                                                    console.g59.WriteToDevice(24, 0);      // CW monitor off
                                                    CW_monitor_on  = false;
                                                    CW_monitor_off = true;
                                                }
                                            }
                                        }
                                        else if (console.CurrentModel == Model.GENESIS_G59NET)
                                        {
                                            if (CWMonitorState)
                                            {
                                                if (!CW_monitor_on && cw_monitor_enabled)
                                                {
                                                    console.net_device.WriteToDevice(24, 1);     // CW monitor on
                                                    CW_monitor_off = false;
                                                    CW_monitor_on  = true;
                                                }
                                            }
                                            else
                                            {
                                                if (!CW_monitor_off && cw_monitor_enabled)
                                                {
                                                    console.net_device.WriteToDevice(24, 0);      // CW monitor off
                                                    CW_monitor_on  = false;
                                                    CW_monitor_off = true;
                                                }
                                            }
                                        }
                                        else if (console.CurrentModel == Model.GENESIS_G11)
                                        {
                                            if (CWMonitorState)
                                            {
                                                if (!CW_monitor_on && cw_monitor_enabled)
                                                {
                                                    console.g11.WriteToDevice(24, 1);     // CW monitor on
                                                    CW_monitor_off = false;
                                                    CW_monitor_on  = true;
                                                }
                                            }
                                            else
                                            {
                                                if (!CW_monitor_off && cw_monitor_enabled)
                                                {
                                                    console.g11.WriteToDevice(24, 0);      // CW monitor off
                                                    CW_monitor_on  = false;
                                                    CW_monitor_off = true;
                                                }
                                            }
                                        }
                                        else if (console.CurrentModel == Model.GENESIS_G160 ||
                                                 console.CurrentModel == Model.GENESIS_G3020 ||
                                                 console.CurrentModel == Model.GENESIS_G40 ||
                                                 console.CurrentModel == Model.GENESIS_G80)
                                        {
                                            if (dtr_cw_monitor && cw_monitor_enabled)
                                            {
                                                if (CWMonitorState)
                                                {
                                                    CW_monitor(true);
                                                }
                                                else
                                                {
                                                    CW_monitor(false);
                                                }
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                        }

                        if (enabled_primary_keyer && !secondary_keyer_mox && !memoryptt)
                        {
                            switch (primary_conn_port)
                            {
                            case "USB":
                            {
                                switch (console.CurrentModel)
                                {
                                case Model.GENESIS_G6:
                                {
                                    if (console.g6.Connected && console.g6.KeyerNewData)
                                    {
                                        keyprog           = false;
                                        primary_keyer_mox = true;

                                        switch (console.g6.KEYER)
                                        {
                                        case 0:                                                                // DASH ON command from USB
                                            primary_keyer_dash = true;
                                            break;

                                        case 1:                                                                // DOT ON command from USB
                                            primary_keyer_dot = true;
                                            break;

                                        case 2:                                                                // DASH OFF command from USB
                                            primary_keyer_dash = false;
                                            break;

                                        case 3:                                                                // DOT OFF command from USB
                                            primary_keyer_dot = false;
                                            break;

                                        case 0xaa:
                                            console.g6.KEYER   = 0xff;
                                            primary_keyer_dot  = false;
                                            primary_keyer_dash = false;
                                            break;

                                        case 0xcc:                                                              // TUN off
                                            console.g11.KEYER  = 0xff;
                                            primary_keyer_dot  = false;
                                            primary_keyer_dash = false;
                                            tuneCW             = false;
                                            break;

                                        default:
                                            primary_keyer_dash = false;
                                            primary_keyer_dot  = false;
                                            break;
                                        }
                                    }
                                }
                                break;

                                case Model.GENESIS_G59USB:
                                {
                                    if (console.g59.Connected && console.g59.KeyerNewData)
                                    {
                                        keyprog           = false;
                                        primary_keyer_mox = true;

                                        switch (console.g59.KEYER)
                                        {
                                        case 0:                                                                // DASH ON command from USB
                                            primary_keyer_dash = true;
                                            break;

                                        case 1:                                                                // DOT ON command from USB
                                            primary_keyer_dot = true;
                                            break;

                                        case 2:                                                                // DASH OFF command from USB
                                            primary_keyer_dash = false;
                                            break;

                                        case 3:                                                                // DOT OFF command from USB
                                            primary_keyer_dot = false;
                                            break;

                                        case 0xaa:
                                            console.g59.KEYER  = 0xff;
                                            primary_keyer_dot  = false;
                                            primary_keyer_dash = false;
                                            break;

                                        case 0xcc:                                                              // TUN off
                                            console.g11.KEYER  = 0xff;
                                            primary_keyer_dot  = false;
                                            primary_keyer_dash = false;
                                            tuneCW             = false;
                                            break;

                                        default:
                                            primary_keyer_dash = false;
                                            primary_keyer_dot  = false;
                                            break;
                                        }
                                    }
                                }
                                break;

                                case Model.GENESIS_G11:
                                {
                                    if (console.g11.Connected && console.g11.KeyerNewData)
                                    {
                                        keyprog           = false;
                                        primary_keyer_mox = true;

                                        switch (console.g11.KEYER)
                                        {
                                        case 0:                                                                // DASH ON command from USB
                                            primary_keyer_dash = true;
                                            break;

                                        case 1:                                                                // DOT ON command from USB
                                            primary_keyer_dot = true;
                                            break;

                                        case 2:                                                                // DASH OFF command from USB
                                            primary_keyer_dash = false;
                                            break;

                                        case 3:                                                                // DOT OFF command from USB
                                            primary_keyer_dot = false;
                                            break;

                                        case 0xaa:
                                            console.g11.KEYER  = 0xff;
                                            primary_keyer_dot  = false;
                                            primary_keyer_dash = false;
                                            break;

                                        case 0xcc:                                                              // TUN off
                                            console.g11.KEYER  = 0xff;
                                            primary_keyer_dot  = false;
                                            primary_keyer_dash = false;
                                            tuneCW             = false;
                                            break;

                                        default:
                                            primary_keyer_dash = false;
                                            primary_keyer_dot  = false;
                                            break;
                                        }
                                    }
                                }
                                break;
                                }
                            }
                            break;

                            case "NET":
                            {
                                if (console.net_device.Connected && console.net_device.KeyerNewData)
                                {
                                    keyprog           = false;
                                    primary_keyer_mox = true;

                                    switch (console.net_device.KEYER)
                                    {
                                    case 0:                                                        // DASH ON command from Network
                                        primary_keyer_dash = true;
                                        primary_keyer_dot  = false;
                                        break;

                                    case 1:                                                        // DOT ON command from Network
                                        primary_keyer_dot  = true;
                                        primary_keyer_dash = false;
                                        break;

                                    case 2:                                                        // DASH OFF command from Network
                                        primary_keyer_dash = false;
                                        break;

                                    case 3:                                                        // DOT OFF command from Network
                                        primary_keyer_dot = false;
                                        break;

                                    case 0xaa:
                                        console.net_device.KEYER = 0xff;
                                        primary_keyer_dot        = false;
                                        primary_keyer_dash       = false;
                                        break;

                                    default:
                                        primary_keyer_dash = false;
                                        primary_keyer_dot  = false;
                                        break;
                                    }
                                }
                            }
                            break;

                            case "QRP2000":
                            {
                                if (console.qrp2000.QRP2000Status())
                                {
                                    keyprog = false;

                                    if (console.MOX)
                                    {
                                        console.qrp2000.SetPTTGetCWInput(1, tmp);
                                    }
                                    else
                                    {
                                        console.qrp2000.SetPTTGetCWInput(0, tmp);
                                    }

                                    if (QRP2000CW1)
                                    {
                                        tmp[0] &= 0x20;
                                    }
                                    else if (QRP2000CW2)
                                    {
                                        tmp[0] &= 0x02;
                                    }

                                    if (tmp[0] == 0x00)
                                    {
                                        primary_keyer_dash = primary_keyer_dot = true;
                                    }
                                    else
                                    {
                                        primary_keyer_dash = primary_keyer_dot = false;
                                    }
                                }
                            }
                            break;

                            default:
                                if (sp.IsOpen)
                                {
                                    keyprog = false;

                                    keyprog            = false;
                                    primary_keyer_dash = sp.CtsHolding;
                                    primary_keyer_dot  = sp.DsrHolding;

                                    if (dtr_cw_monitor && console.CWMonitorEnabled)
                                    {
                                        if (CWMonitorState)
                                        {
                                            CW_monitor(true);
                                        }
                                        else
                                        {
                                            CW_monitor(false);
                                        }
                                    }
                                }
                                break;
                            }
                        }

                        timer.Stop();
                        msdel = (float)timer.DurationMsec;
                        //msdel = (float)DttSP.TimerRead();
                        //Debug.Write(msdel.ToString() + "\n");

                        if (keyprog || secondary_keyer_mox || tune_CW || ptt_bit_bang_enabled)
                        {
                            //keyprog = false;
                            DttSP.KeyValue(msdel, secondary_keyer_dash, secondary_keyer_dot, keyprog);
                            keyprog = false;
                        }
                        else if (primary_keyer_mox)
                        {
                            DttSP.KeyValue(msdel, primary_keyer_dash, primary_keyer_dot, keyprog);
                        }
                        else if (enabled_primary_keyer && !secondary_keyer_mox && !memoryptt)
                        {
                            DttSP.KeyValue(msdel, primary_keyer_dash, primary_keyer_dot, keyprog);
                        }
                        else
                        {
                            DttSP.KeyValue(msdel, false, false, false);
                            primary_keyer_mox   = false;
                            secondary_keyer_mox = false;
                            keyprog             = false;
                        }
                    }
                }// while (true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in KeyThread!\n" + ex.ToString());
            }
        }
Ejemplo n.º 42
0
        private void btnGPIOWrite1_Click(object sender, EventArgs e)
        {
            byte b = byte.Parse(txtGPIOByte.Text, NumberStyles.HexNumber);

            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            int val = USBHID.WriteGPIO(b);

            t1.Stop();
            Debug.WriteLine("GPIO1: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
        }
Ejemplo n.º 43
0
        public void CalRX2Image()
        {
            float rejection_tol = 75.0f;	// rejection from worst to null
            float floor_tol = 10.0f;		// from null to noise floor
            test_rx2_image = "RX2 Image Cal: Passed";

            double vfoa = console.VFOAFreq;
            double vfob = console.VFOBFreq;
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();
            Band[] bands = { Band.B160M, Band.B80M, Band.B60M, Band.B40M, Band.B30M, Band.B20M, Band.B17M, Band.B15M, Band.B12M, Band.B10M, Band.B6M };
            float[] band_freqs = { 1.85f, 3.75f, 5.3665f, 7.15f, 10.125f, 14.175f, 18.1f, 21.300f, 24.9f, 28.4f, 50.11f};
            for(int i=0; i<band_freqs.Length; i++)
            {
                bool do_band = false;
                switch(bands[i])
                {
                    case Band.B160M: do_band = ck160.Checked; break;
                    case Band.B80M: do_band = ck80.Checked; break;
                    case Band.B60M: do_band = ck60.Checked; break;
                    case Band.B40M: do_band = ck40.Checked; break;
                    case Band.B30M: do_band = ck30.Checked; break;
                    case Band.B20M: do_band = ck20.Checked; break;
                    case Band.B17M: do_band = ck17.Checked; break;
                    case Band.B15M: do_band = ck15.Checked; break;
                    case Band.B12M: do_band = ck12.Checked; break;
                    case Band.B10M:	do_band = ck10.Checked; break;
                    case Band.B6M: do_band = ck6.Checked; break;
                }

                if(do_band)
                {
                    p.SetPercent(0.0f);
                    Invoke(new MethodInvoker(p.Show));
                    Application.DoEvents();
                    console.VFOBFreq = band_freqs[i]+2*console.IFFreq;
                    console.VFOAFreq = band_freqs[i];
                    console.CalibrateRX2Image(band_freqs[i], p, true);
                    if(p.Text == "") break;

                    if(console.rx_image_rejection[(int)bands[i]] < rejection_tol ||
                        console.rx_image_from_floor[(int)bands[i]] > floor_tol)
                    {
                        if(!test_rx2_image.StartsWith("RX2 Image Cal: Failed ("))
                            test_rx2_image = "RX2 Image Cal: Failed (";
                        test_rx2_image += BandToString(bands[i])+", ";
                        btnCalImage.BackColor = Color.Red;
                        lstDebug.Items.Insert(0, "RX2 Image - "+BandToString(bands[i])+": Failed ("
                            +console.rx_image_rejection[(int)bands[i]].ToString("f1")+", "
                            +console.rx_image_from_floor[(int)bands[i]].ToString("f1")+")");
                    }
                    else
                    {
                        lstDebug.Items.Insert(0, "RX2 Image - "+BandToString(bands[i])+": Passed ("
                            +console.rx_image_rejection[(int)bands[i]].ToString("f1")+", "
                            +console.rx_image_from_floor[(int)bands[i]].ToString("f1")+")");
                    }

                    Thread.Sleep(500);
                }
            }
            console.VFOAFreq = vfoa;
            console.VFOBFreq = vfob;
            if(test_rx2_image.StartsWith("RX2 Image Cal: Failed ("))
                test_rx2_image = test_rx2_image.Substring(0, test_rx2_image.Length-2)+")";
            toolTip1.SetToolTip(btnCalImage, test_rx2_image);

            t1.Stop();
            Debug.WriteLine("RX2 Image Timer: "+t1.Duration);

            string path = Application.StartupPath+"\\Tests";
            if(!Directory.Exists(path))	Directory.CreateDirectory(path);
            bool file_exists = File.Exists(path+"\\rx2_image.csv");
            StreamWriter writer = new StreamWriter(path+"\\rx2_image.csv", true);
            if(!file_exists) writer.WriteLine("Serial Num, Date/Time, Version, "
                                 +"160m gain, 160m phase, 160m rejection, 160m noise distance, "
                                 +"80m gain, 80m phase, 80m rejection, 80m noise distance, "
                                 +"60m gain, 60m phase, 60m rejection, 60m noise distance, "
                                 +"40m gain, 40m phase, 40m rejection, 40m noise distance, "
                                 +"30m gain, 30m phase, 30m rejection, 30m noise distance, "
                                 +"20m gain, 20m phase, 20m rejection, 20m noise distance, "
                                 +"17m gain, 17m phase, 17m rejection, 17m noise distance, "
                                 +"15m gain, 15m phase, 15m rejection, 15m noise distance, "
                                 +"12m gain, 12m phase, 12m rejection, 12m noise distance, "
                                 +"10m gain, 10m phase, 10m rejection, 10m noise distance, "
                                 +"6m gain, 6m phase, 6m rejection, 6m noise distance");
            writer.Write(FWCEEPROM.SerialToString(FWCEEPROM.RX2Serial)+","
                +DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString()+","
                +console.Text+",");
            for(int i=0; i<bands.Length; i++)
            {
                writer.Write(console.rx2_image_gain_table[(int)bands[i]].ToString("f3")+",");
                writer.Write(console.rx2_image_phase_table[(int)bands[i]].ToString("f3")+",");
                writer.Write(console.rx_image_rejection[(int)bands[i]].ToString("f1")+",");
                writer.Write(console.rx_image_from_floor[(int)bands[i]].ToString("f1")+",");
            }
            writer.WriteLine("");
            writer.Close();

            path += "\\RX2 Image";
            if(!Directory.Exists(path))	Directory.CreateDirectory(path);
            writer = new StreamWriter(path+"\\rx2_image_"+FWCEEPROM.SerialToString(FWCEEPROM.RX2Serial)+".csv");
            writer.WriteLine("Band, Gain, Phase, Rejection, Noise Distance");
            for(int i=0; i<bands.Length; i++)
            {
                writer.Write(BandToString(bands[i])+",");
                writer.Write(console.rx2_image_gain_table[(int)bands[i]].ToString("f3")+",");
                writer.Write(console.rx2_image_phase_table[(int)bands[i]].ToString("f3")+",");
                writer.Write(console.rx_image_rejection[(int)bands[i]].ToString("f1")+",");
                writer.WriteLine(console.rx_image_from_floor[(int)bands[i]].ToString("f1"));
            }
            writer.Close();

            lstDebug.Items.Insert(0, "Saving Image data to EEPROM...");
            FWCEEPROM.WriteRX2Image(console.rx2_image_gain_table, console.rx2_image_phase_table);
            console.RX2SyncCalDateTime();
            lstDebug.Items[0] = "Saving Image data to EEPROM...done";

            grpTests.Enabled = true;
            grpCal.Enabled = true;
        }
Ejemplo n.º 44
0
        private void btnGPIOWrite3_Click(object sender, EventArgs e)
        {
            HiPerfTimer t1 = new HiPerfTimer();
            t1.Start();

            byte b;
            int val = USBHID.ReadGPIO(out b);

            t1.Stop();
            Debug.WriteLine("GPIO3: " + val + "  (" + t1.DurationMsec.ToString("f2") + ")");
            txtGPIOResult.Text = b.ToString("X");
        }
Ejemplo n.º 45
0
 public PanelHighlighter(Panel panel)
 {
     p = panel;
     timer.Start();
 }
Ejemplo n.º 46
0
        public void KeyThread()
        {
            byte extkey_dash, extkey_dot;

            do
            {
                DttSP.KeyerStartedWait();
                for (; DttSP.KeyerRunning() != 0;)
                {
                    byte keyprog = 0;
                    timer.Start();
                    DttSP.PollTimerWait();
                    switch (primary_conn_port)
                    {
                    case "SDR":
                        byte b = hw.StatusPort();
                        extkey_dash = (byte)(((b & (byte)StatusPin.Dash) != 0) ? 1:0);
                        extkey_dot  = (byte)(((b & (byte)StatusPin.Dot) != 0) ? 1:0);
                        break;

                    default:                             // COM port
                        extkey_dash = System.Convert.ToByte(sp.CtsHolding);
                        extkey_dot  = System.Convert.ToByte(sp.DsrHolding);
                        break;
                    }

                    // [patch_16
                    // M0PUB : also allow keying via USB-connected AVR processor, running DG8SAQ firmware
                    if ((extkey_dash == 0) && (extkey_dot == 0))                     // don't override primary
                    {
                        extkey_dot = extkey_dash = Console.GetDG8SAQkeyStatus();
                    }
                    // patch_16]

                    if (memoryptt)
                    {
                        //console ptt on
                        keyprog    = 1;
                        extkey_dot = extkey_dash = System.Convert.ToByte(memorykey);
                    }
                    else
                    {
                        keyprog = 0;
                        //console ptt off
                    }
                    switch (secondary_conn_port)
                    {
                    case "None":
                        break;

                    case "CAT":
                        if ((extkey_dash == 0) && (extkey_dot == 0))                               // don't override primary
                        {
                            switch (secondary_ptt_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = System.Convert.ToByte(siolisten.SIO.isDSR());
                                }
                                else
                                {
                                    extkey_dot = System.Convert.ToByte(siolisten.SIO.isCTS());
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                keyerptt = siolisten.SIO.isDSR();
                                //										extkey_dot = System.Convert.ToByte(sp2.CtsHolding);
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                keyerptt = siolisten.SIO.isCTS();
                                //										extkey_dash  = System.Convert.ToByte(sp2.DsrHolding);
                                break;
                            }

                            switch (secondary_key_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = System.Convert.ToByte(siolisten.SIO.isDSR());
                                }
                                else
                                {
                                    extkey_dot = System.Convert.ToByte(siolisten.SIO.isCTS());
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                extkey_dot = System.Convert.ToByte(siolisten.SIO.isDSR());
                                //										Debug.WriteLine("extkey_dot: "+extkey_dot);
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                extkey_dash = System.Convert.ToByte(siolisten.SIO.isCTS());
                                break;
                            }

                            if ((extkey_dash + extkey_dot) != 0)
                            {
                                keyprog = 1;
                            }
                            else
                            {
                                keyprog = 0;
                            }
                            //								Debug.WriteLine("keyprog: "+keyprog);
                        }
                        else
                        {
                            keyprog = 0;
                        }

                        break;

                    default:                                         // comm port
                        if ((extkey_dash == 0) && (extkey_dot == 0)) // don't override primary
                        {
                            switch (secondary_ptt_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = System.Convert.ToByte(sp2.DsrHolding);
                                }
                                else
                                {
                                    extkey_dot = System.Convert.ToByte(sp2.CtsHolding);
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                keyerptt = sp2.DsrHolding;
//										extkey_dot = System.Convert.ToByte(sp2.CtsHolding);
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                keyerptt = sp2.CtsHolding;
//										extkey_dash  = System.Convert.ToByte(sp2.DsrHolding);
                                break;
                            }

                            switch (secondary_key_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = System.Convert.ToByte(sp2.DsrHolding);
                                }
                                else
                                {
                                    extkey_dot = System.Convert.ToByte(sp2.CtsHolding);
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                extkey_dot = System.Convert.ToByte(sp2.DsrHolding);
//										Debug.WriteLine("extkey_dot: "+extkey_dot);
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                extkey_dash = System.Convert.ToByte(sp2.CtsHolding);
                                break;
                            }

                            if ((extkey_dash + extkey_dot) != 0)
                            {
                                keyprog = 1;
                            }
                            else
                            {
                                keyprog = 0;
                            }
//								Debug.WriteLine("keyprog: "+keyprog);
                        }
                        else
                        {
                            keyprog = 0;
                        }

                        break;
                    }
                    timer.Stop();
                    msdel = (float)timer.DurationMsec;
                    DttSP.KeyValue(msdel, extkey_dash, extkey_dot, keyprog);
                }
            } while(true);
        }