Beispiel #1
0
        int GetDataBlockReadCount(AmplifierSampleRate sampleRate)
        {
            switch (sampleRate)
            {
            case AmplifierSampleRate.SampleRate1000Hz:
            case AmplifierSampleRate.SampleRate1250Hz:
            case AmplifierSampleRate.SampleRate1500Hz:
            case AmplifierSampleRate.SampleRate2000Hz:
            case AmplifierSampleRate.SampleRate2500Hz:
                return(1);

            case AmplifierSampleRate.SampleRate3000Hz:
            case AmplifierSampleRate.SampleRate3333Hz:
            case AmplifierSampleRate.SampleRate4000Hz:
                return(2);

            case AmplifierSampleRate.SampleRate5000Hz:
            case AmplifierSampleRate.SampleRate6250Hz:
                return(3);

            case AmplifierSampleRate.SampleRate8000Hz:
                return(4);

            case AmplifierSampleRate.SampleRate10000Hz:
                return(6);

            case AmplifierSampleRate.SampleRate12500Hz:
                return(7);

            case AmplifierSampleRate.SampleRate15000Hz:
                return(8);

            case AmplifierSampleRate.SampleRate20000Hz:
                return(12);

            case AmplifierSampleRate.SampleRate25000Hz:
                return(14);

            case AmplifierSampleRate.SampleRate30000Hz:
                return(16);

            default:
                throw new ArgumentException("Invalid amplifier sample rate.", "sampleRate");
            }
        }
Beispiel #2
0
        void ChangeSampleRate(AmplifierSampleRate amplifierSampleRate)
        {
            evalBoard.SetSampleRate(amplifierSampleRate);

            // Now that we have set our sampling rate, we can set the MISO sampling delay
            // which is dependent on the sample rate.
            evalBoard.SetCableLengthMeters(BoardPort.PortA, cableLengthPortA);
            evalBoard.SetCableLengthMeters(BoardPort.PortB, cableLengthPortB);
            evalBoard.SetCableLengthMeters(BoardPort.PortC, cableLengthPortC);
            evalBoard.SetCableLengthMeters(BoardPort.PortD, cableLengthPortD);

            // Set up an RHD2000 register object using this sample rate to
            // optimize MUX-related register settings.
            var sampleRate = evalBoard.GetSampleRate();

            chipRegisters = new Rhd2000Registers(sampleRate);
            var commandList = new List <int>();

            // Create a command list for the AuxCmd1 slot.  This command sequence will create a 250 Hz,
            // zero-amplitude sine wave (i.e., a flatline).  We will change this when we want to perform
            // impedance testing.
            var sequenceLength = chipRegisters.CreateCommandListZcheckDac(commandList, 250, 0);

            evalBoard.UploadCommandList(commandList, AuxCmdSlot.AuxCmd1, 0);
            evalBoard.SelectAuxCommandLength(AuxCmdSlot.AuxCmd1, 0, sequenceLength - 1);
            evalBoard.SelectAuxCommandBank(BoardPort.PortA, AuxCmdSlot.AuxCmd1, 0);
            evalBoard.SelectAuxCommandBank(BoardPort.PortB, AuxCmdSlot.AuxCmd1, 0);
            evalBoard.SelectAuxCommandBank(BoardPort.PortC, AuxCmdSlot.AuxCmd1, 0);
            evalBoard.SelectAuxCommandBank(BoardPort.PortD, AuxCmdSlot.AuxCmd1, 0);

            // Next, we'll create a command list for the AuxCmd2 slot.  This command sequence
            // will sample the temperature sensor and other auxiliary ADC inputs.
            sequenceLength = chipRegisters.CreateCommandListTempSensor(commandList);
            evalBoard.UploadCommandList(commandList, AuxCmdSlot.AuxCmd2, 0);
            evalBoard.SelectAuxCommandLength(AuxCmdSlot.AuxCmd2, 0, sequenceLength - 1);
            evalBoard.SelectAuxCommandBank(BoardPort.PortA, AuxCmdSlot.AuxCmd2, 0);
            evalBoard.SelectAuxCommandBank(BoardPort.PortB, AuxCmdSlot.AuxCmd2, 0);
            evalBoard.SelectAuxCommandBank(BoardPort.PortC, AuxCmdSlot.AuxCmd2, 0);
            evalBoard.SelectAuxCommandBank(BoardPort.PortD, AuxCmdSlot.AuxCmd2, 0);

            // For the AuxCmd3 slot, we will create three command sequences.  All sequences
            // will configure and read back the RHD2000 chip registers, but one sequence will
            // also run ADC calibration.  Another sequence will enable amplifier 'fast settle'.

            // Before generating register configuration command sequences, set amplifier
            // bandwidth parameters.
            chipRegisters.SetDspCutoffFreq(DspCutoffFrequency);
            chipRegisters.SetLowerBandwidth(LowerBandwidth);
            chipRegisters.SetUpperBandwidth(UpperBandwidth);
            chipRegisters.EnableDsp(DspEnabled);

            // Upload version with ADC calibration to AuxCmd3 RAM Bank 0.
            sequenceLength = chipRegisters.CreateCommandListRegisterConfig(commandList, true);
            evalBoard.UploadCommandList(commandList, AuxCmdSlot.AuxCmd3, 0);
            evalBoard.SelectAuxCommandLength(AuxCmdSlot.AuxCmd3, 0, sequenceLength - 1);

            // Upload version with no ADC calibration to AuxCmd3 RAM Bank 1.
            sequenceLength = chipRegisters.CreateCommandListRegisterConfig(commandList, false);
            evalBoard.UploadCommandList(commandList, AuxCmdSlot.AuxCmd3, 1);
            evalBoard.SelectAuxCommandLength(AuxCmdSlot.AuxCmd3, 0, sequenceLength - 1);

            // Upload version with fast settle enabled to AuxCmd3 RAM Bank 2.
            chipRegisters.SetFastSettle(true);
            sequenceLength = chipRegisters.CreateCommandListRegisterConfig(commandList, false);
            evalBoard.UploadCommandList(commandList, AuxCmdSlot.AuxCmd3, 2);
            evalBoard.SelectAuxCommandLength(AuxCmdSlot.AuxCmd3, 0, sequenceLength - 1);
            chipRegisters.SetFastSettle(false);

            UpdateRegisterConfiguration(fastSettle: false);
        }