Introduction
The Oscilloscope component in Sci-Compiler provides a powerful tool for monitoring analog signals connected to the analog inputs of the board, as well as internal signals within the designed diagram. With its intuitive interface and comprehensive features, the Oscilloscope allows users to visualize and analyze waveforms, enabling a deeper understanding of the behavior of the designed processing chain.
In this application note, we will explore the various functionalities and benefits of the Oscilloscope component in Sci-Compiler. We will discuss how to set up the Oscilloscope, capture and display waveforms, read data using Resource Explorer, and leverage its advanced features to troubleshoot and optimize the design.
Oscilloscope component
The oscilloscope component allows to monitor multiple channels of the board. Each channel can be a physical input of the board or an internal signal of the design. The Oscilloscope can be triggered on internal analog channel, or on external digital signal like the system trigger.
Oscilloscope configuration
Once the oscilloscope component is added to the design, it is possible to configure it by clicking on the component and opening the configuration window. The configuration window allows to set the number of channels to monitor, the depth of the monitor, enable/disable the digital traces.
Each analog trace is associated with 4 digital traces that can be used to monitor the digital signals associated with the analog trace. For example the digital traces can be used to monitor a comparator output of the analog input signal. In this way the oscilloscope can be used to monitor the analog signal in order to select the right threshold for the comparator.
Design block diagram in Sci-Compiler
We will use the following block diagram to demonstrate the usage of the Oscilloscope component. The block diagram consists of an analog input, a comparator, and an oscilloscope. The analog input is connected to a PMT detector. The comparator compares the exponential signal with a threshold programmable with a register and outputs a digital signal. The oscilloscope monitors the analog input and the comparator output.
Readout waveform using Resource Explorer
The SCI-Compiler offers the possibility to connect with one of the two supported board types and to explore the features of the FPGA firmware that has been graphically designed by the user, compiled and downloaded to the FPGA with the application software. The Oscilloscope component is one of the tools that can be used to monitor the signals inside the design. The Oscilloscope component is rendered with a windows form with a left side bar and a main area. The left side bar contains the controls to configure the Oscilloscope, while the main area is used to display the waveforms.
Trigger mode allows to select the trigger source and the trigger edge. The trigger source can be an internal analog channel, an external digital signal, or self periodic trigger (to look at the baseline and search for a valid trigger). When internal trigger is selected, the trigger level can be set by looking at the waveform and choosing the right level over the noise.
The Resource Explorer allows to set the decimation factor and the ratio between pre-trigger (number of samples before trigger) and post trigger.
Readout waveform using Sci-SDK
Sci-SDK is a hardware-agnostic library that interfaces with CAEN Open hardware boards developed with Sci-Compiler. It offers flexibility and scalability for data acquisition, readout, and analysis, with a user-friendly interface and comprehensive documentation. The Sci-SDK library offers a hierarchical and hardware-agnostic approach, providing a common interface to manage various elements and seamlessly interface with different hardware boards. It ensures a unified and flexible experience for data acquisition and analysis, regardless of the specific hardware being used.
The Sci-SDK library is available for most common programming languages, including C/C++, Python, and LabVIEW. The library is open-source and available on GitHub. Sci-SDK Information
The following code snippet shows how to use the Sci-SDK library to read the data from the Oscilloscope component. The script set the THRS register to 2350 (trigger level) and than monitor the analog signal and digital signal with the oscilloscope. The code snippet is written in python and uses the Sci-SDK python library.
First of all the Sci-SDK library must be installed system wide. Use the Installer in windows or with package manager in Linux. Please be sure to install the Sci-SDK library binary files. The pip package is only a wrapper to the binary files and does not include the libraries files.
- Install the Sci-SDK library and matplotlib
pip install matplotlib
pip install scisdk
- Create a new python file and import the Sci-SDK library
Replace the usb:10500 with the PID of your board or
Read more about Oscilloscope Driver on GitHub Docs
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import os
from scisdk.scisdk import SciSDK
from scisdk.scisdk_defines import *
fig = plt.figure("Oscilloscope analog data - channel 0")
ax1 = fig.add_subplot(1,1,1)
# initialize scisdk library
sdk = SciSDK()
# add new device
#DT1260
res = sdk.AddNewDevice("usb:10500","dt1260", "./DT1260RegisterFile.json","board0")
if res != 0:
print ("Script exit due to connetion error")
exit()
# configure the threshold of the comparator
sdk.SetRegister("board0:/Registers/THRS", 2350)
# set oscilloscope parameters
res = sdk.SetParameterString("board0:/MMCComponents/Oscilloscope_0.data_processing","decode")
res = sdk.SetParameterInteger("board0:/MMCComponents/Oscilloscope_0.trigger_level", 30000)
res = sdk.SetParameterString("board0:/MMCComponents/Oscilloscope_0.trigger_mode","self")
res = sdk.SetParameterInteger("board0:/MMCComponents/Oscilloscope_0.trigger_channel", 0)
res = sdk.SetParameterInteger("board0:/MMCComponents/Oscilloscope_0.pretrigger", 150)
decimator = 1
res = sdk.SetParameterInteger("board0:/MMCComponents/Oscilloscope_0.decimator", decimator)
res = sdk.SetParameterString("board0:/MMCComponents/Oscilloscope_0.acq_mode", "blocking")
res = sdk.SetParameterInteger("board0:/MMCComponents/Oscilloscope_0.timeout", 3000)
# allocate buffer for oscilloscope
res, buf = sdk.AllocateBuffer("board0:/MMCComponents/Oscilloscope_0")
def updateGraph(i, buffer, decimator): # function that provides to plot new data on graph
res, buffer = sdk.ReadData("board0:/MMCComponents/Oscilloscope_0", buffer)# read data from board
if res == 0:
xar = []
yar = []
ydr = []
for index in range(buffer.info.samples_analog):
xar.append(index * decimator)
yar.append(buffer.analog[index])
ydr.append(buffer.digital[index])
ax1.clear()
ax1.plot(xar,yar)
ax1.plot(xar,ydr*1000) #scale the digital trace to overlap to the analog trace
# update graph every 50ms
ani = animation.FuncAnimation(fig, updateGraph, fargs=[buf, decimator,],interval=100)
# updateGraph(None, buf, decimator)
plt.show()
DT1260RegisterFile.json is the register file generated by Sci-Compiler. It is used to enumerate all components presents in the Sci-Compiler design. Double check the path of the file or copy in the same folder of the python script. The file is automatically generated by Sci-Compiler in the folder “library” inside the project folder.