MATLAB Bode Plot Generator (Under Construction)
Introduction
This MATLAB function generates Bode plots based on a user-defined frequency sweep. It requires the Data Acquisition Toolbox and an Analog Discovery 2 to generate and capture the signals. The user defines the start, stop, and the number of frequency samples per decade in the frequency sweep.
The highest frequency sweep range is limited at 500kHz due to the Data Acquisition Toolbox's sampling rate restriction, which is capped at 1MHz. If higher sampling rates are needed, please use the Network Analyzer tool in Digilent's free application WaveForms.
Inventory
- Analog Discovery 2
- MATLAB with Data Acquisition Toolbox
- Ensure that MATLAB's Data Acquisition Toolbox is properly installed and able to communicate with the Analog Discovery 2. This can be done by following the Getting Started Acquiring Data with Digilent Analog Discovery tutorial on MATLAB's website.
- ZIP archive with freqSweep.m MATLAB source file.
Setup
Open the file “freqSweep.m” and call the function freqSweep() from MATLAB's Command Window. This function has the following syntax:
freqSweep(start,stop,samplesPerDec)
Parameter | Description |
---|---|
start | Optional. Frequency sweep start value (Hz) |
stop | Optional. Frequency sweep stop value (Hz) |
samplesPerDec | Optional. Specifies number of samples to take per decade |
The function defaults to a 10Hz-100kHz sweep with 10 samples per decade if no parameters are passed.
This function is configured so that the Analog Discovery Oscilloscope Channel 1 (solid orange wire) senses the input signal, and Channel 2 (solid blue wire) senses the output signal. The negative leads (marked with a white stripe) and a black ground wire should be connected to the ground of the network under test. The Function Generator Channel 1 (solid yellow wire) is used as the input signal and should be connected at the same place as Oscilloscope Channel 1. See the diagram to the right.
Final Notes
For more guides and example projects for your Test and Measurement device, please visit its Resource Center, which can be found through this wiki's Test and Measurement page.
For technical support, please visit the Digilent Forums.