With this Dash DAQ app, you can create a user-friendly GUI for analyzing the frequency responses of circuits. We wrote it using a function generator and an oscilloscope in tandem, to output a specific frequency and read the relevant response.
You can check out the mock app online, and explore the source code below.
First, we import the relevant packages, including
sys, the Dash and Plotly libraries, NumPy, and Plotter:
Plotter is a class that will communicate with our function generator and oscilloscope in a different thread, so as not to block our application while it is generating inputs.
Dash DAQ components are an intuitive means to interface with your devices. Let’s see what happens when the “Calculate” button component is pressed:
As you see above, we simply call our Plotter object to start plotting.
Note: Since our application only runs a local instance, and only handles one request at a time, a global variable can be used here. However, if the Dash application is ever forked to handle multiple requests in parallel, then global variables should not be used.
After this, we continuously query our Plotter object to see if it has any data, using a Dash core component called Interval. If the Plotter object has data, then we add it to a list of data points, which the graph object picks up, as seen in the code sample below.
These three function summarize the crucial functions of the app. Using Dash DAQ, you can integrate the virtual hardware controls, like the two Dash DAQ Knob components, into the app.