public static void initATIS(string filename) { // detect Opal Kelly and Program dev = new okCFrontPanel(); int num_boards = 0; bool device_opened = false; lock (dev) { while (device_opened == false) { num_boards = dev.GetDeviceCount(); for(int i=0; i < num_boards; i++) { if (dev.GetDeviceListModel(i) == okCFrontPanel.BoardModel.brdXEM6010LX150) { dev.OpenBySerial(dev.GetDeviceListSerial(i)); device_opened = true; } } } /* while (dev.OpenBySerial("") != okCFrontPanel.ErrorCode.NoError) { }//wait for Opal Kelly to be plugged in */ dev.LoadDefaultPLLConfiguration(); dev.ConfigureFPGA(filename); } // Initialize the Biases BiasesInterface.initBiases(); }
public FpgaTimebaseTask(DeviceSettings deviceSettings, okCFrontPanel opalKellyDevice, SequenceData sequence, double masterClockPeriod, out int nSegments, bool useRfModulation, bool assymetric) : base() { com.opalkelly.frontpanel.okCFrontPanel.ErrorCode errorCode; this.opalKellyDevice = opalKellyDevice; this.masterClockPeriod = masterClockPeriod; TimestepTimebaseSegmentCollection segments = sequence.generateVariableTimebaseSegments(SequenceData.VariableTimebaseTypes.AnalogGroupControlledVariableFrequencyClock, masterClockPeriod); this.max_elapsedtime_ms = (UInt32)((sequence.SequenceDuration * 1000.0) + 100); byte[] data = FpgaTimebaseTask.createByteArray(segments, sequence, out nSegments, masterClockPeriod, assymetric); // Send the device an abort trigger. errorCode = opalKellyDevice.ActivateTriggerIn(0x40, 1); if (errorCode != okCFrontPanel.ErrorCode.NoError) { throw new Exception("Unable to set abort trigger to FPGA device. Error code " + errorCode.ToString()); } UInt16 wireInValue = 0; if (deviceSettings.StartTriggerType != DeviceSettings.TriggerType.SoftwareTrigger) { wireInValue += 1; } if (useRfModulation) { wireInValue += 2; } setWireInValue(0x00, wireInValue); setWireInValue(0x01, deviceSettings.RetriggerDebounceSamples); opalKellyDevice.UpdateWireIns(); // pipe the byte stream to the device int xfered = opalKellyDevice.WriteToPipeIn(0x80, data.Length, data); if (xfered != data.Length) { throw new Exception("Error when piping clock data to FPGA device. Sent " + xfered + " bytes instead of " + data.Length + "bytes."); } }
public FpgaTimebaseTask(DeviceSettings deviceSettings, okCFrontPanel opalKellyDevice, SequenceData sequence, double masterClockPeriod, out int nSegments, bool useRfModulation, bool assymetric) : base() { com.opalkelly.frontpanel.okCFrontPanel.ErrorCode errorCode; this.opalKellyDevice = opalKellyDevice; this.masterClockPeriod = masterClockPeriod; TimestepTimebaseSegmentCollection segments = sequence.generateVariableTimebaseSegments(SequenceData.VariableTimebaseTypes.AnalogGroupControlledVariableFrequencyClock, masterClockPeriod); this.max_elapsedtime_ms = (UInt32)((sequence.SequenceDuration * 1000.0) + 100); byte[] data = FpgaTimebaseTask.createByteArray(segments, sequence, out nSegments, masterClockPeriod, assymetric ); // Send the device an abort trigger. errorCode = opalKellyDevice.ActivateTriggerIn(0x40, 1); if (errorCode != okCFrontPanel.ErrorCode.NoError) { throw new Exception("Unable to set abort trigger to FPGA device. Error code " + errorCode.ToString()); } UInt16 wireInValue = 0; if (deviceSettings.StartTriggerType != DeviceSettings.TriggerType.SoftwareTrigger) { wireInValue += 1; } if (useRfModulation) { wireInValue += 2; } setWireInValue(0x00, wireInValue); setWireInValue(0x01, deviceSettings.RetriggerDebounceSamples); opalKellyDevice.UpdateWireIns(); // pipe the byte stream to the device int xfered = opalKellyDevice.WriteToPipeIn(0x80, data.Length, data); if (xfered != data.Length) { throw new Exception("Error when piping clock data to FPGA device. Sent " + xfered + " bytes instead of " + data.Length + "bytes."); } }
public static void initATIS(string filename) { // detect Opal Kelly and Program dev = new okCFrontPanel(); int num_boards = 0; bool device_opened = false; lock (dev) { while (device_opened == false) { num_boards = dev.GetDeviceCount(); for (int i = 0; i < num_boards; i++) { if (dev.GetDeviceListModel(i) == okCFrontPanel.BoardModel.brdXEM6010LX150) { dev.OpenBySerial(dev.GetDeviceListSerial(i)); device_opened = true; } } } /* * while (dev.OpenBySerial("") != okCFrontPanel.ErrorCode.NoError) * { * * }//wait for Opal Kelly to be plugged in */ dev.LoadDefaultPLLConfiguration(); dev.ConfigureFPGA(filename); } // Initialize the Biases BiasesInterface.initBiases(); }
// public methods /// <summary> /// Attempt to open Opal Kelly XEM3010 USB FPGA board. /// </summary> /// <param name="dataRate">Data rate (High, Medium, or Low).</param> /// <param name="boardID">Board ID number.</param> /// <param name="boardVersion">Board version number.</param> /// <returns>Board name.</returns> public string Open(DataRate dataRate, out int boardID, out int boardVersion) { boardID = -1; boardVersion = -1; // Open Opal Kelly XEM3010 board myXEM = new okCFrontPanel(); if (myXEM.OpenBySerial("") != okCFrontPanel.ErrorCode.NoError) { UsbException e = new UsbException("USB Setup Error: Could not find USB board."); throw e; } // Setup the PLL from the stored configuration. myXEM.LoadDefaultPLLConfiguration(); // Read back the CY22393 PLL configuation (6/3/11) okCPLL22393 myPLL = new okCPLL22393(); myXEM.GetEepromPLL22393Configuration(myPLL); // Modify PLL settings from default myPLL.SetOutputDivider(0, 5); // set clk1 to 80 MHz (normally 4 = 100 MHz) myPLL.SetOutputDivider(1, 8); // set clk2 to 50 MHz (normally 4 = 100 MHz) // ... 8 works at 30 MHz with state 7 present (BER = 5.3e-4), zero BER at 20 MHz myXEM.SetPLL22393Configuration(myPLL); // Download the configuration file. if (okCFrontPanel.ErrorCode.NoError != myXEM.ConfigureFPGA("bug3a_receiver_1.bit")) { UsbException e = new UsbException("USB Setup Error: FPGA configuration failed."); throw e; } Debug.WriteLine("FPGA configuration complete."); // Check for FrontPanel support in the FPGA configuration. if (false == myXEM.IsFrontPanelEnabled()) { UsbException e = new UsbException("USB Setup Error: FrontPanel support is not available."); throw e; } // Reset FIFOs myXEM.SetWireInValue(wireInResetReadWrite, 0x04); myXEM.UpdateWireIns(); myXEM.SetWireInValue(wireInResetReadWrite, 0x00); myXEM.UpdateWireIns(); // Turn raw data mode off by default myXEM.SetWireInValue(wireInRawDataMode, 0x00); myXEM.UpdateWireIns(); myXEM.UpdateWireOuts(); boardID = (int)myXEM.GetWireOutValue(wireOutBoardID); boardVersion = (int)myXEM.GetWireOutValue(wireOutBoardVersion); string boardName; boardName = myXEM.GetDeviceID(); // Debug.WriteLine("Board ID: " + boardID); return(boardName); }