A Raspberry Pi with an Adafruit MAX31855 thermocouple interface board and a solid-state relay is used to control the temperature profile in an oven for reflow surface-mount soldering. The software running on the Raspberry Pi is here: https://github.com/apollo-ng/picoReflow. The instructions in the README.md file in the picoReflow project are good, with one modification needed: to auto-start on power-up, the reflow script in lib/init needs “#! /bin/sh” on the first line of the file, not line 12 as given.
I set my Raspberry Pi with a static IP address of 192.168.0.222, so the address to browse to see the oven interface is 192.168.0.222:8081.
The oven used is an Argos Cookworks 20L 1380W model with top and bottom heaters. The heaters are connected in parallel. Extra insulation is added around the top and sides of the oven chassis and in the door. The seams are sealed with high-temperature putty. Some cross-bars in the rack are removed to reduce thermal mass.
Using the Digilent Analog Discovery 2 to automatically test audio frequency response
An Analog Discovery 2 (AD2) signal generator is configured to generate a sine wave through a range of frequencies. The sine wave is fed into the Unit Under Test (UUT) and an AD2 oscilloscope channel is used to sample the UUT’s output. A Python script automates the whole thing and produces a .csv file and graphical plot of the results. Python script details are here.
The AD2 mounts conveniently on a standard die cast aluminium enclosure (e.g. Hammond 10758). The enclosure houses connectors to route the signals and a switch and LED to select jack or XLR inputs.
Scope channel 1 connects to either a 6.35mm jack or the positive pin of a balanced XLR, selected with the switch. Channel 2 connects to the negative pin of the XLR.
The signal generator is fed to the UUT and directly back into channel 2 of the oscilloscope so the phase delay between channel 1 and channel 2 can be calculated, for the phase response measurements.
The first thing to do is connect the signal generator output directly back into the ‘scope input, as shown in the photo above, in order to check the frequency response of the tester. The test script produces the following plot:
The plot is reassuringly flat from 10Hz to 200kHz, with a negligible but consistent gain offset of around 0.2dB throughout.
Now that Python and the Digilent DWF Python wrapper are installed (link), we can start using the Analog Discovery 2 to do something useful. The Waveforms SDK provides access to an API that allows the creation of custom applications using the Digilent Analog Design hardware (e.g. the Analog Discovery 2). The reference manual is here.
Working code examples are installed in /usr/share/digilent/waveforms/samples/
I used AnalogIn_Record_Wave_Mono.py as a basis, and along with it copied dwfconstants.py to the project folder.
For a multi-threaded front-end, I used the good example here: https://github.com/beenje/tkinter-logging-text-widget/blob/master/main.py
The script generates a sine wave at a range of frequencies on signal generator channel 1 and samples the input on scope channel 1. Gain is calculated for each frequency, with the aim of evaluating the frequency response of some audio hardware. Some flakiness with the USB connection was solved by switching the PC connection to the Analog Discovery 2 from a USB 2 to a USB 3 port. Code is available here: https://github.com/richardtoller/1007-AD2.git. I used the PyCharm IDE.
The first test to run is with the Analog Discovery 2 output connected directly back to its input, i.e. with no test hardware in the circuit, to establish the frequency response of the test kit.
First, install Python, etc
First, check we have python installed:
The result is “Python 3.8.2” on my system. Now check we have setuptools and pip installed. These are third-party Python packages that we (may) need later.
command -v pip
The result is nothing, so we need to install as follows:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python3 get-pip.py
This installs to /home/USER/.local/bin which is not on PATH. To add to the path:
Now install the Python dependency manager pipenv (this does a user installation to avoid breaking any system-wide packages):
pip install --user pipenv
Next, install the Adept 2 runtime and Waveforms software to allow communication with the hardware
Next, install the Digilent DWF library wrapper for Python
pip install dwf
This installs the latest stable version of DWF.
Here’s a test script, modified from a version found on the Digilent forum (forum.digilent.com):
from ctypes import * import sys if sys.platform.startswith("win"): dwf = cdll.dwf elif sys.platform.startswith("darwin"): dwf = cdll.LoadLibrary("libdwf.dylib") else: dwf = cdll.LoadLibrary("libdwf.so") #declare ctype variables szerr = create_string_buffer(512) dwf.FDwfGetLastErrorMsg(szerr) print (szerr.value) #declare ctype variables IsInUse = c_bool() hdwf = c_int() channel = c_int() hzfreq = c_double() cdevices = c_int() #declare string variables devicename = create_string_buffer(64) serialnum = create_string_buffer(16) #print DWF version version = create_string_buffer(16) dwf.FDwfGetVersion(version) print ("DWF Version: "+str(version.value)) #enumerate and print device information dwf.FDwfEnum(c_int(0), byref(cdevices)) print ("Number of Devices: "+str(cdevices.value)) for i in range(0, cdevices.value): dwf.FDwfEnumDeviceName (c_int(i), devicename) dwf.FDwfEnumSN (c_int(i), serialnum) print ("------------------------------") print ("Device "+str(i)+" : ") print ("t" + str(devicename.value)) print ("t" + str(serialnum.value)) dwf.FDwfEnumDeviceIsOpened(c_int(i), byref(IsInUse)) if not IsInUse: dwf.FDwfDeviceOpen(c_int(i), byref(hdwf)) dwf.FDwfAnalogInChannelCount(hdwf, byref(channel)) dwf.FDwfAnalogInFrequencyInfo(hdwf, None, byref(hzfreq)) print ("tAnalog input channels: "+str(channel.value)) print ("tMax freq: "+str(hzfreq.value)) dwf.FDwfDeviceClose(hdwf) hdwf = c_int(-1) # ensure all devices are closed dwf.FDwfDeviceCloseAll()
Running the script results in the following output: