View full example on Github

Basic PCA level automated test example using Phidgets to power cycle a circuit board, take voltage data, plot, and store data in a CSV.

Wiring Diagram

Wiring Diagram

For the purposes of this example the PCA under test is just a power supply in order to accentuate the output waveform. For a practical application this would be tied to whatever output or test signal that you wish to measure.

BOM

GUI

Basic form accepts:

  • Serial Number: Tagged serial number for DUT that’s tagged in output file names
  • Start Up: Time in seconds data is collected prior to test (before power-up)
  • Duration: Time in seconds data is collected during the test
  • Shutdown: Time in seconds data is collected after test (after power-down)
  • Trials: Number of iterations of the test

Output Data Files

The output data files are named in the syntax “YYYY-MM-DD HH-MM-SS [Serial Number]”. For example “2023-09-03 13-05-21 SN12345”

The output data plot would appear as follows if the the voltage input Phidget was connected to a 3.3V supply. Each trial is overlayed.

The output CSV file is in the format below.

Sample Trial Elapsed Data
0 0 0 -0.0027
1 0 0.012917 -0.0027

Code Breakdown

The GUI itself is repeat of the previous blog post. It uses tkinter to create a basic GUI with our test criteria.

When you click the RUN button. it executes the runFunction() which checks the inputs, prints out the test configuration in the terminal and calls the functions to collect the data, save the data, and plots it.

In the data collection phase we attempt to connect to the phidgets and error out if they do not exist. It should be noted that the default data rate is rather slow for the Voltage Input Phidget so we set it to what it tells us is its maximum data rate. Otherwise you’ll get a rather stair-stepping output. Then we collect our data and add the arrays to our primary one. This creates an array-of-arrays for our resulting data. Each element in the primary array is the data for that trial. The index of the primary array is the trial number so we don’t need to keep track of that. Keeping track of the overall elapsed time and not simply the sample number can be important when sampling quite fast as any delay less than 15ms can be hit-and-miss with overall timing which can distort the resulting graphs when trying to compare data between trials.

Appending a copy of the trial array to the primary array is important. Otherwise when you delete the contents for the next trial it’ll delete the entry in the primary array.

When you finish, be sure to close the connections to the phidgets. Otherwise you will need to close the GUI for the next experiment.

Exporting the data needs to come before plotting since when you display the plot it’ll hold your script and not proceed until you close it. The exportData() function is a basic CSV script using two for loops to iterate through the primary data arrays to write everything. There’s likely a cleaner way to do this but this implementation was quick to implement and it works.

Finally, we plot our data. Likewise with the exportData() function we iterate through our arrays and plot. We use the same filename string as the data function. The file name for this was captured on the runFunction() so we capture the time stamp at the beginning of the test rather than at the end.

Leave a Reply

Your email address will not be published. Required fields are marked *