private void Load() { evalBoard = new Rhythm.Net.Rhd2000EvalBoard(); // Open Opal Kelly XEM6010 board. evalBoard.Open(); samplesPerBlock = Rhd2000DataBlock.GetSamplesPerDataBlock(evalBoard.IsUsb3()); try { // Load Rhythm FPGA configuration bitfile (provided by Intan Technologies). evalBoard.UploadFpgaBitfile(BitFileName); // Initialize interface board. evalBoard.Initialize(); // Set sample rate and upload all auxiliary SPI command sequences. ChangeSampleRate(SampleRate); // Run ADC calibration RunCalibration(); // Set default configuration for all eight DACs on interface board. SetDacDefaultConfiguration(); // Find amplifier chips connected to interface board and compute their // optimal delay parameters. ScanConnectedAmplifiers(); } catch { // Close interface board in case of configuration errors evalBoard.Close(); throw; } }
public Rhd2000EvalBoard() { BitFileName = "main.bit"; SampleRate = AmplifierSampleRate.SampleRate20000Hz; LowerBandwidth = 0.1; UpperBandwidth = 7500.0; DspCutoffFrequency = 1.0; DspEnabled = true; source = Observable.Create <Rhd2000DataFrame>((observer, cancellationToken) => { var activeTtlOut = ttlOut = 0; return(Task.Factory.StartNew(() => { Load(); var ledSequence = LedSequence(); try { evalBoard.SetTtlMode(0); evalBoard.SetTtlOut(activeTtlOut); evalBoard.SetContinuousRunMode(true); evalBoard.EnableExternalFastSettle(ExternalFastSettleEnabled); evalBoard.Run(); var blocksToRead = GetDataBlockReadCount(SampleRate); var fifoCapacity = Rhythm.Net.Rhd2000EvalBoard.FifoCapacityInWords(); var queue = new Queue <Rhd2000DataBlock>(); ledSequence.MoveNext(); while (!cancellationToken.IsCancellationRequested) { if (activeTtlOut != ttlOut) { activeTtlOut = ttlOut; evalBoard.SetTtlOut(activeTtlOut); } if (evalBoard.ReadDataBlocks(blocksToRead, queue)) { var wordsInFifo = evalBoard.NumWordsInFifo(); var bufferPercentageCapacity = 100.0 * wordsInFifo / fifoCapacity; foreach (var dataBlock in queue) { observer.OnNext(new Rhd2000DataFrame(dataBlock, bufferPercentageCapacity)); } queue.Clear(); ledSequence.MoveNext(); } } } finally { ledSequence.Dispose(); evalBoard.ClearTtlOut(); evalBoard.SetContinuousRunMode(false); evalBoard.SetMaxTimeStep(0); evalBoard.Flush(); evalBoard.Close(); evalBoard = null; chipRegisters = null; } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default)); }) .PublishReconnectable() .RefCount(); }