SlideShare une entreprise Scribd logo
1  sur  21
Automated Python Test
 Frameworks for Hardware
Validation and Verification




                Barbara Jones
About Me

                          Barbara Jones
                          bjones@vtiinstruments.com




    Test & Measurement
    Data Acquisition
Boeing 787 Fatigue Test




                   Rack of instruments to measure strain
Definitions & Theory
   Strain gauge
   Thermocouple
   Channel
   Sample rate
   Waveform
   Waveform generator
Why test hardware?
 Verification
 Validation
Software Techniques Don’t Help
 Unit
     Tests
 Mocking
 TDD
What does help?
 Spec-based   testing
 Test stand automation
 A good test framework
Bed-of-nails tester




                      Engineering
                        test rig
Test Framework Requirements
   Easily design broad
    tests from spec       def module_test_1(suite, cl, slave_cls):
                           def verify(result, success, args):
                              if not success:
   Control external             return False
                              if result[-1] != args:
    equipment                    return False
                              return True
   Easy math handling
                             arg1 = 0.1
                             arg2 = 0.2
                             calls = [Call(cl.InstrumentSpecific.ThisIsAMethod, arg1, arg2),
                                       Set(cl.InstrumentSpecific, "ThisIsAProperty", arg1),
                                       Get(cl.InstrumentSpecific, "ThisIsAProperty")]
                             suite.add(calls, verify, arg1)

                          def add(suite, cl, slave_cls):
                           module_test_1(suite, cl, slave_cls)
Designing tests based on hardware specs
  Phase alignment on multiple instruments must be
            within 0.000010 arc seconds
                          Discrete Fourier Transform




                                  Amplitude



                                    Phase
Phase Alignment
Aligned




                  Out of Phase
Controlling external equipment
                                    Specifications
                                       IEEE 488.2 (1975)
                                       SCPI (1990)
                                       VXI-11 (1995)


Agilent 33220A Waveform Generator
Controlling external equipment
from vxi11client import *

class ag33120(TCPVXI11Client):
    timeout = 10000
    def __init__(self, hostname, gpib):
        TCPVXI11Client.__init__(self, hostname, 1, gpib)

    def query(self, str):
        self.device_write(self.lid, self.timeout, self.timeout, 0, str)
        return self.device_read(self.lid, 256, self.timeout, self.timeout, 0x80,
0x0a)

   def check_error(self):
       res = self.query(":SYST:ERR?n")
       err, msg = res.data.split(",")
       if int(err) != 0:
           raise Exception(res.data)

   def reset(self):
       self.device_write(self.lid, self.timeout, self.timeout, 0, "*RST;n")

   def apply(self, func, freq=None, amp=None, off=None):
       freq = self._defopt(freq)
       amp = self._defopt(amp)
       off = self._defopt(off)
       return self.query("APPLY:%s %s, %s, %s; *OPC?n" % (func, freq, amp, off))

   def _defopt(self, arg):
       if arg == None:
           return "DEF"
       return "%12.7e" % arg
Controlling external equipment
 def dc(self, off=None):
     return self.query("APPLY:DC 1, 1, %s; *OPC?n" % (off))

 def set_highimpedance_mode(self):
     return self.query("OUTP:LOAD 9.9E37; *OPC?n")
 def sine(self, freq=None, amp=None, off=None):
     return self.apply("SIN", freq, amp, off)

 def square(self, freq=None, amp=None, off=None):
     return self.apply("SQU", freq, amp, off)

 def triangle(self, freq=None, amp=None, off=None):
     return self.apply("TRI", freq, amp, off)

 def ramp(self, freq=None, amp=None, off=None):
     return self.apply("RAMP", freq, amp, off)
Phase Alignment Test


# Data acquisition characteristics:
FILTER_TYPE = ex1629constants.IIRFILTER_TYPE_NONE
SAMP_FREQ = 1000.0
SAMPLE_COUNT = 1000
# Expected input: 1V peak (2V peak-to-peak) sine wave at 10Hz.
INPUT_AMPLITUDE = 1
INPUT_FREQ = 10
# Maximum tolerated skew (in seconds):
MAX_PERMISSIBLE_SKEW = 0.000010

def add_phase_test(suite, cl, slave_cls, wavegen)

def add(suite, cl, slave_cls):
      wavegen = require_slaves(slave_cls, "ag33120")
      slaves = require_slaves(slave_cls, "ex1629")
      add_phase_test(suite, cl, slaves, wavegen)
Setup & Verify
def add_phase_test(suite, cl, slave_cls, wavegen):
    # Constant parameters
    PI = 4*atan(1)
    if suite.test_level == test.FULL_TEST:
        NUM_INNER_LOOPS = 2000 # approximately 13 hours with two devices
    else:
        NUM_INNER_LOOPS = 10 # approximately 4 minutes with 2 devices

   def verify(result, success, args):
       # Since the actual data analysis was performed in analyze_data,
       #   we only need to check the function call returns to determine
       #   overall success/failure.
       for call_result in result:
           if call_result == False:
               return False
       return success

   # set up the waveform generator
   # Sine wave at 10Hz, 1V peak (2V peak-to-peak), no offset
   calls = [Call(wavegen.reset),
           Call(wavegen.set_highimpedance_mode),
           Call(wavegen.sine(INPUT_FREQ, INPUT_AMPLITUDE, 0)]
   suite.add(calls)

   for config_name in config_sequence
Test Sequence
for config_name in config_sequence:
    calls = []
    # Configure the master & slave devices
    calls += configure_device(cl)
    calls += configure_device_trigger(cl, configs[config_name]['master'])
    for slave_cl in slave_cls:
        calls += configure_device(slave_cl)
        calls += configure_device_trigger(slave_cl, configs[config_name]['slave'])
    suite.add(calls, verify, None)

   for inner_loop in range(0, NUM_INNER_LOOPS):
       calls = []
       # Instruct the master device to issue a sync pulse
       calls += [Call(cl.soft_sync)]
       # Start acquiring data on each slave device
       for slave_cl in slave_cls:
           calls += [Call(slave_cl.trig_init)]
       # Start acquiring data on the master device
       calls += [Call(cl.trig_init)]
       # Issue a soft trigger command to the master device
       calls += [Call(cl.soft_trig)]
       # Read the data
       calls += [Call(analyze_data, cl, slave_cls, config_name)]
       suite.add(calls, verify, None)

   # Reset the slave devices & the master device
   calls = []
   for slave_cl in slave_cls:
       calls += [Call(slave_cl.reset)]
   calls += [Call(cl.reset)]

   suite.add(calls, verify, None)
DFT Calculation


N = len(device_result.datapages)
n = INPUT_FREQ * N / SAMP_FREQ
val_dft_real = val_dft_imag = 0.0
k = 0
for page in device_result.datapages:
    val_dft_real += page.dataset[board][0].data[0] * cos(2*PI*n*k/N)
    val_dft_imag -= page.dataset[board][0].data[0] * sin(2*PI*n*k/N)
    k += 1
val_magnitude = sqrt(pow(val_dft_imag, 2) + pow(val_dft_real, 2))/N
val_phase = atan2(val_dft_imag , val_dft_real)
Phase Alignment Test Data
Questions?

Contenu connexe

Tendances

ファイルやディレクトリに「別名」を付ける機能について 〜ハードリンクからシンボリックリンクまで〜
ファイルやディレクトリに「別名」を付ける機能について 〜ハードリンクからシンボリックリンクまで〜ファイルやディレクトリに「別名」を付ける機能について 〜ハードリンクからシンボリックリンクまで〜
ファイルやディレクトリに「別名」を付ける機能について 〜ハードリンクからシンボリックリンクまで〜
iPride Co., Ltd.
 
Testing boolean difference
Testing boolean differenceTesting boolean difference
Testing boolean difference
Anish Gupta
 
Ipmi spec ch1~6_simon_20110422
Ipmi spec ch1~6_simon_20110422Ipmi spec ch1~6_simon_20110422
Ipmi spec ch1~6_simon_20110422
davidsmc
 
Finite state machines
Finite state machinesFinite state machines
Finite state machines
dennis gookyi
 
Challenges in Using UVM at SoC Level
Challenges in Using UVM at SoC LevelChallenges in Using UVM at SoC Level
Challenges in Using UVM at SoC Level
DVClub
 

Tendances (20)

高位合成友の会@ドワンゴ,2015年12月8日
高位合成友の会@ドワンゴ,2015年12月8日高位合成友の会@ドワンゴ,2015年12月8日
高位合成友の会@ドワンゴ,2015年12月8日
 
Exception handling and function in python
Exception handling and function in pythonException handling and function in python
Exception handling and function in python
 
Synthesijer hls 20150116
Synthesijer hls 20150116Synthesijer hls 20150116
Synthesijer hls 20150116
 
ファイルやディレクトリに「別名」を付ける機能について 〜ハードリンクからシンボリックリンクまで〜
ファイルやディレクトリに「別名」を付ける機能について 〜ハードリンクからシンボリックリンクまで〜ファイルやディレクトリに「別名」を付ける機能について 〜ハードリンクからシンボリックリンクまで〜
ファイルやディレクトリに「別名」を付ける機能について 〜ハードリンクからシンボリックリンクまで〜
 
Testing boolean difference
Testing boolean differenceTesting boolean difference
Testing boolean difference
 
Ipmi spec ch1~6_simon_20110422
Ipmi spec ch1~6_simon_20110422Ipmi spec ch1~6_simon_20110422
Ipmi spec ch1~6_simon_20110422
 
llvm basic porting for risc v
llvm basic porting for risc vllvm basic porting for risc v
llvm basic porting for risc v
 
Interrupts
InterruptsInterrupts
Interrupts
 
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | EdurekaPython Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
 
Wishbone interface and bus cycles
Wishbone interface and bus cyclesWishbone interface and bus cycles
Wishbone interface and bus cycles
 
Finite state machines
Finite state machinesFinite state machines
Finite state machines
 
Task migration using CRIU
Task migration using CRIUTask migration using CRIU
Task migration using CRIU
 
Edureka-DevOps-Ebook.pdf
Edureka-DevOps-Ebook.pdfEdureka-DevOps-Ebook.pdf
Edureka-DevOps-Ebook.pdf
 
4 bit add sub
4 bit add sub4 bit add sub
4 bit add sub
 
Challenges in Using UVM at SoC Level
Challenges in Using UVM at SoC LevelChallenges in Using UVM at SoC Level
Challenges in Using UVM at SoC Level
 
Verilog Tutorial - Verilog HDL Tutorial with Examples
Verilog Tutorial - Verilog HDL Tutorial with ExamplesVerilog Tutorial - Verilog HDL Tutorial with Examples
Verilog Tutorial - Verilog HDL Tutorial with Examples
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis: COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis:
 
Local Stack - A fully functional AWS cloud on your desktop
Local Stack - A fully functional AWS cloud on your desktopLocal Stack - A fully functional AWS cloud on your desktop
Local Stack - A fully functional AWS cloud on your desktop
 

En vedette

Team system - фреймворк для автоматизации тестирования от Microsoft
Team system -  фреймворк для автоматизации тестирования от MicrosoftTeam system -  фреймворк для автоматизации тестирования от Microsoft
Team system - фреймворк для автоматизации тестирования от Microsoft
QA Dnepropetrovsk Community (Ukraine)
 
Работа тестировщиком в Германии - Виктор Малый
Работа тестировщиком в Германии - Виктор МалыйРабота тестировщиком в Германии - Виктор Малый
Работа тестировщиком в Германии - Виктор Малый
QA Dnepropetrovsk Community (Ukraine)
 

En vedette (20)

Automated hardware testing using python
Automated hardware testing using pythonAutomated hardware testing using python
Automated hardware testing using python
 
Python in Test automation
Python in Test automationPython in Test automation
Python in Test automation
 
Automated Regression Testing for Embedded Systems in Action
Automated Regression Testing for Embedded Systems in ActionAutomated Regression Testing for Embedded Systems in Action
Automated Regression Testing for Embedded Systems in Action
 
Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++
 
Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentals
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
Embedded System Test Automation
Embedded System Test AutomationEmbedded System Test Automation
Embedded System Test Automation
 
Разработка фреймворка на Python для автоматизации тестирования STB боксов
Разработка фреймворка на Python для автоматизации тестирования STB боксовРазработка фреймворка на Python для автоматизации тестирования STB боксов
Разработка фреймворка на Python для автоматизации тестирования STB боксов
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'ts
 
Robot Framework Introduction
Robot Framework IntroductionRobot Framework Introduction
Robot Framework Introduction
 
Team system - фреймворк для автоматизации тестирования от Microsoft
Team system -  фреймворк для автоматизации тестирования от MicrosoftTeam system -  фреймворк для автоматизации тестирования от Microsoft
Team system - фреймворк для автоматизации тестирования от Microsoft
 
Framework for Web Automation Testing
Framework for Web Automation TestingFramework for Web Automation Testing
Framework for Web Automation Testing
 
Работа тестировщиком в Германии - Виктор Малый
Работа тестировщиком в Германии - Виктор МалыйРабота тестировщиком в Германии - Виктор Малый
Работа тестировщиком в Германии - Виктор Малый
 
Automated Acceptance Testing from Scratch
Automated Acceptance Testing from ScratchAutomated Acceptance Testing from Scratch
Automated Acceptance Testing from Scratch
 
C to C++ Migration Strategy
C to C++ Migration Strategy C to C++ Migration Strategy
C to C++ Migration Strategy
 
Softwarequalitätssicherung mit Continuous Integration Tools
Softwarequalitätssicherung mit Continuous Integration ToolsSoftwarequalitätssicherung mit Continuous Integration Tools
Softwarequalitätssicherung mit Continuous Integration Tools
 
A Buffer's Guide to Selenium 2
A Buffer's Guide to Selenium 2A Buffer's Guide to Selenium 2
A Buffer's Guide to Selenium 2
 
Mock testing mit Python
Mock testing mit PythonMock testing mit Python
Mock testing mit Python
 
C++ and Embedded Linux - a perfect match
C++ and Embedded Linux - a perfect matchC++ and Embedded Linux - a perfect match
C++ and Embedded Linux - a perfect match
 
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 Talk: Unit TestingPython Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 Talk: Unit Testing
 

Similaire à Automated Python Test Frameworks for Hardware Verification and Validation

Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Robot Media
 
Python Unit Test
Python Unit TestPython Unit Test
Python Unit Test
David Xie
 
생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트
기룡 남
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
종인 전
 

Similaire à Automated Python Test Frameworks for Hardware Verification and Validation (20)

Introduction to nsubstitute
Introduction to nsubstituteIntroduction to nsubstitute
Introduction to nsubstitute
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon Galicia
 
Unit test
Unit testUnit test
Unit test
 
bluespec talk
bluespec talkbluespec talk
bluespec talk
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
Python Unit Test
Python Unit TestPython Unit Test
Python Unit Test
 
Lost in Translation: When Industrial Protocol Translation goes Wrong [CONFide...
Lost in Translation: When Industrial Protocol Translation goes Wrong [CONFide...Lost in Translation: When Industrial Protocol Translation goes Wrong [CONFide...
Lost in Translation: When Industrial Protocol Translation goes Wrong [CONFide...
 
Qualidade levada a sério em Python - Emilio Simoni
Qualidade levada a sério em Python - Emilio SimoniQualidade levada a sério em Python - Emilio Simoni
Qualidade levada a sério em Python - Emilio Simoni
 
How to fake_properly
How to fake_properlyHow to fake_properly
How to fake_properly
 
Testing My Patience
Testing My PatienceTesting My Patience
Testing My Patience
 
Testing in those hard to reach places
Testing in those hard to reach placesTesting in those hard to reach places
Testing in those hard to reach places
 
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com GoTDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
 
생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdf
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation
 
Asynchronous programming done right - Node.js
Asynchronous programming done right - Node.jsAsynchronous programming done right - Node.js
Asynchronous programming done right - Node.js
 
Unit tests and mocks
Unit tests and mocksUnit tests and mocks
Unit tests and mocks
 
ppopoff
ppopoffppopoff
ppopoff
 
Performance tests - it's a trap
Performance tests - it's a trapPerformance tests - it's a trap
Performance tests - it's a trap
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
 

Automated Python Test Frameworks for Hardware Verification and Validation

  • 1. Automated Python Test Frameworks for Hardware Validation and Verification Barbara Jones
  • 2. About Me Barbara Jones bjones@vtiinstruments.com  Test & Measurement  Data Acquisition
  • 3. Boeing 787 Fatigue Test Rack of instruments to measure strain
  • 4. Definitions & Theory  Strain gauge  Thermocouple  Channel  Sample rate  Waveform  Waveform generator
  • 5. Why test hardware?  Verification  Validation
  • 6. Software Techniques Don’t Help  Unit Tests  Mocking  TDD
  • 7. What does help?  Spec-based testing  Test stand automation  A good test framework
  • 8. Bed-of-nails tester Engineering test rig
  • 9.
  • 10. Test Framework Requirements  Easily design broad tests from spec def module_test_1(suite, cl, slave_cls): def verify(result, success, args): if not success:  Control external return False if result[-1] != args: equipment return False return True  Easy math handling arg1 = 0.1 arg2 = 0.2 calls = [Call(cl.InstrumentSpecific.ThisIsAMethod, arg1, arg2), Set(cl.InstrumentSpecific, "ThisIsAProperty", arg1), Get(cl.InstrumentSpecific, "ThisIsAProperty")] suite.add(calls, verify, arg1) def add(suite, cl, slave_cls): module_test_1(suite, cl, slave_cls)
  • 11. Designing tests based on hardware specs Phase alignment on multiple instruments must be within 0.000010 arc seconds Discrete Fourier Transform Amplitude Phase
  • 12. Phase Alignment Aligned Out of Phase
  • 13. Controlling external equipment Specifications  IEEE 488.2 (1975)  SCPI (1990)  VXI-11 (1995) Agilent 33220A Waveform Generator
  • 14. Controlling external equipment from vxi11client import * class ag33120(TCPVXI11Client): timeout = 10000 def __init__(self, hostname, gpib): TCPVXI11Client.__init__(self, hostname, 1, gpib) def query(self, str): self.device_write(self.lid, self.timeout, self.timeout, 0, str) return self.device_read(self.lid, 256, self.timeout, self.timeout, 0x80, 0x0a) def check_error(self): res = self.query(":SYST:ERR?n") err, msg = res.data.split(",") if int(err) != 0: raise Exception(res.data) def reset(self): self.device_write(self.lid, self.timeout, self.timeout, 0, "*RST;n") def apply(self, func, freq=None, amp=None, off=None): freq = self._defopt(freq) amp = self._defopt(amp) off = self._defopt(off) return self.query("APPLY:%s %s, %s, %s; *OPC?n" % (func, freq, amp, off)) def _defopt(self, arg): if arg == None: return "DEF" return "%12.7e" % arg
  • 15. Controlling external equipment def dc(self, off=None): return self.query("APPLY:DC 1, 1, %s; *OPC?n" % (off)) def set_highimpedance_mode(self): return self.query("OUTP:LOAD 9.9E37; *OPC?n") def sine(self, freq=None, amp=None, off=None): return self.apply("SIN", freq, amp, off) def square(self, freq=None, amp=None, off=None): return self.apply("SQU", freq, amp, off) def triangle(self, freq=None, amp=None, off=None): return self.apply("TRI", freq, amp, off) def ramp(self, freq=None, amp=None, off=None): return self.apply("RAMP", freq, amp, off)
  • 16. Phase Alignment Test # Data acquisition characteristics: FILTER_TYPE = ex1629constants.IIRFILTER_TYPE_NONE SAMP_FREQ = 1000.0 SAMPLE_COUNT = 1000 # Expected input: 1V peak (2V peak-to-peak) sine wave at 10Hz. INPUT_AMPLITUDE = 1 INPUT_FREQ = 10 # Maximum tolerated skew (in seconds): MAX_PERMISSIBLE_SKEW = 0.000010 def add_phase_test(suite, cl, slave_cls, wavegen) def add(suite, cl, slave_cls): wavegen = require_slaves(slave_cls, "ag33120") slaves = require_slaves(slave_cls, "ex1629") add_phase_test(suite, cl, slaves, wavegen)
  • 17. Setup & Verify def add_phase_test(suite, cl, slave_cls, wavegen): # Constant parameters PI = 4*atan(1) if suite.test_level == test.FULL_TEST: NUM_INNER_LOOPS = 2000 # approximately 13 hours with two devices else: NUM_INNER_LOOPS = 10 # approximately 4 minutes with 2 devices def verify(result, success, args): # Since the actual data analysis was performed in analyze_data, # we only need to check the function call returns to determine # overall success/failure. for call_result in result: if call_result == False: return False return success # set up the waveform generator # Sine wave at 10Hz, 1V peak (2V peak-to-peak), no offset calls = [Call(wavegen.reset), Call(wavegen.set_highimpedance_mode), Call(wavegen.sine(INPUT_FREQ, INPUT_AMPLITUDE, 0)] suite.add(calls) for config_name in config_sequence
  • 18. Test Sequence for config_name in config_sequence: calls = [] # Configure the master & slave devices calls += configure_device(cl) calls += configure_device_trigger(cl, configs[config_name]['master']) for slave_cl in slave_cls: calls += configure_device(slave_cl) calls += configure_device_trigger(slave_cl, configs[config_name]['slave']) suite.add(calls, verify, None) for inner_loop in range(0, NUM_INNER_LOOPS): calls = [] # Instruct the master device to issue a sync pulse calls += [Call(cl.soft_sync)] # Start acquiring data on each slave device for slave_cl in slave_cls: calls += [Call(slave_cl.trig_init)] # Start acquiring data on the master device calls += [Call(cl.trig_init)] # Issue a soft trigger command to the master device calls += [Call(cl.soft_trig)] # Read the data calls += [Call(analyze_data, cl, slave_cls, config_name)] suite.add(calls, verify, None) # Reset the slave devices & the master device calls = [] for slave_cl in slave_cls: calls += [Call(slave_cl.reset)] calls += [Call(cl.reset)] suite.add(calls, verify, None)
  • 19. DFT Calculation N = len(device_result.datapages) n = INPUT_FREQ * N / SAMP_FREQ val_dft_real = val_dft_imag = 0.0 k = 0 for page in device_result.datapages: val_dft_real += page.dataset[board][0].data[0] * cos(2*PI*n*k/N) val_dft_imag -= page.dataset[board][0].data[0] * sin(2*PI*n*k/N) k += 1 val_magnitude = sqrt(pow(val_dft_imag, 2) + pow(val_dft_real, 2))/N val_phase = atan2(val_dft_imag , val_dft_real)

Notes de l'éditeur

  1. Not web developers
  2. Fatigue TestSimulates flight service lifeOver 4000 channels totalOverall test to run for 165000 cyclesAverage cycle takes about 5 minutes (this includes pressurization and de-pressurization)Expected to take almost 3 years of continuous testing
  3. TODO: Pass around strain gauge & TCs for visual aidBefore I get started, I’m going to give some definitions since I’m pretty most of you aren’t familiar with the test & measurement industry.Strain gauge – A sensor for measuring the strain of an object. basically a wire (foil) looped into a pattern of parallel lines and attached to an object. As the object is deformed or bent, the strain gauge is deformed and its resistance changes. (stretching causes higher resistance, compression reduces resistance) (Excitation voltage is applied, voltage is read from the output leads, eqn to convert to strain.)Thermocouple – A sensor consisting of two different types of wire which works a lot like a thermostat – it produces a voltage that’s proportional to the temperature difference between the two ends. The voltage change is mostly linear (within a certain range), but more precise measurements require approximation with a polynomial (up to 13 terms, coefficients depend on the metals in the TC & can get nasty). There are several different types using different metals for range and accuracy. Type K is common & cheap, range -200 to 1350 C.Channel – one input (one sensor).Sample rate – samples (measurements) per second, per channel. Our strain instrument supports 1 Sa/s to 10 kSa/s (or 25 kSa/s in limited conditions). Thermocouple instrument supports up to 1000 Sa/s.Waveform – an electronic signal (voltage), something that you’d observe on an oscilloscopeWaveform generator – a device that produces a waveformTODO: Note that “waveform generator” & “function generator” & “signal generator” are all equivalent, definitely not the yield statement
  4. “No sense blowing up more than one at a time”Same reasons as testing softwareIn Hardware, as in Software, there’s often a published specification of what your device will do. If you don’t meet it, you get angry customers. To keep those customers happy and buying your product, you’ve got to make surethat you meet your published specifications.Often, these published specs are based on what the hardware can do, such as ‘a noise floor of 0.01 Decibels’, or 0.000010 arc seconds (2.78 x10^-9 degrees) of phase alignment between channels. For those of you who build web frameworks [raucous laughter], a noise floor means that you can detect any signal above that strength, and a phase alignment between channels means that if you put an identical signal into channel 1 and channel 2, you will see in the resulting data that the waveforms were processed at the same time.You also want to make sure that you’ve actually built your hardware correctly. Sometimes the production floor gets confused and they install a diode backwards. Sometimes they install a 10 ohm resistor instead of a 10,000 Ohm resistor. Whatever the reason, sometimes the failure isn’t enough to let the magic smoke out, but still gives your customers the wrong answer. You want your tests to show that your device works even once the design is shown to be good.
  5. With unit tests, the point is to pick small components or subsections of your code and test those pieces, to test functionality at the smallest unit. In some pieces of hardware, there are discrete pieces like this that you can test. If that’s the case with your hardware, by all means make use of it and test those pieces of functionality separately. However, in many cases you will have two pieces of hardware which are inextricably linked, like an analog-to-digital converter connected through an analog filter. In this case the final data is your only method of data gathering, and you need to test the filter and ADC as a cohesive unit.In hardware testing, some unit-like testing is still possible (Isolated HW pieces exist), but in large part the HW is a big black box that all hangs together. If you contracted out the design, you may not even know what’s in it, just that it has specs that it has to meet.Mocks are the practice of faking out classes with stubs that appear to perform all the correct behavior, or give all the appropriate responses without doing all of the work. When testing hardware, the whole point is the stuff down at the very bottom of the stack - the chips and circuits. Those aren’t possible to mock, because then you’d be faking exactly the data that you need. (This can be very useful, but not for testing.)The only piece of the system you’re testing is the hardware - and unless you have a 1:1 hardware simulator (which is expensive to construct and harder to guarantee correctness - it ends up looking like the HW itself), you can’t mock out a piece of hardware.TDD is the practice of writing the test before, or as a guide to, writing the software. But when making hardware, it’s not really possible to design your hardware based on the design of your test - hardware’s driven by other considerations like PCB space, component cost, and specification goals. We can build a prototype back in the lab, but it won’t match the final PCB design. What we can do is work with that final piece, the known specifications. Since the hardware must meet some specification, and this and the circuit designs are a known quantity before it goes off for fabrication, we can design and write our tests based on these hardware designs and goals. This isn’t exactly TDD... but it is Spec-Based Testing.
  6. So if you can’t mock it and you can’t break it down into unit tests... [pause] How DO you test hardware? I just mentioned that hardware has specifications it has to meet, specifications like Total Harmonic Distortion or Noise Floor. We can work with our hardware developers to put certain inputs into the product that should create certain types of outputs. We then use more equipment to sense those outputs, and verify that the responses we get are the responses the hardware engineers expect. The great news is, if you know the input signal, the type of hardware you’ll need to generate the input, the equipment you’ll need to measure the output, and the valid range for the outputs... you can write the entire test, and even construct the test harness, before the board comes back from the fabricator.
  7. Sometimes you may get 50 or 100 boards back from the fabricator at once. Sometimes you’re doing engineering verification and proving one board works correctly is enough... other times you’re doing build validation and you need to test all of them. Testing them by hand would be a waste of our time and awesome coding skills, so we can build test harnesses or test rigs. In the case where you need a lot of test points on a piece of hardware to test supply voltages or chip power, and you are testing a lot of boards, it may be economical to build a bed-of-nails tester which connects directly to the PCB, like the one shown here. Then you just need some switching and measuring and you can test many boards very quickly by automating the test procedure. Other times, you are testing a small number of units, as we most often do, and you just need a Cat-5 cable with the ends stripped off and a waveform generator (point to test rig and/or photo of test rig) to test the product right.
  8. If you need to test many things without changing cabling, a switching solution could come in handy. (possible picture of DIO switch test rig or Comparator test diagram) No, not a network switch. This lets you feed different signals into your hardware or send the outputs to different types of monitors, while only making one cable rig at the start of the test. Getting the switching paths correct can sometimes be tricky, but is a lot less tedious than doing it by hand.And your test won’t stop at 3am, waiting for you to change equipment connections.
  9. Once you have your test stand set up, test progressions should advance automatically too. This is where these frameworks have the most in common with SW frameworks, as long as we can easily and reliably load the external equipment and math portions. We do it with python.We don’t use any of the common Python test frameworks, since they’re all geared for software testing. Since we’re not writing unit tests and we can’t use mocks, we had to roll our own.In our framework, each test module has “add” function, each test has “verify” function.The major part of a test is the calls list. This is just a list of calls to make in the future, when the test actually runs. The dirty little secret of the framework is that all the work done here just generates a list of calls and functions to call later, when the framework actually runs the test. It then uses the verify function to determine if the test passed.
  10. For an example, our strain gauge instrument has a test for phase alignment. This diagram is the same test rig that was pictured earlier, with the waveform generator connected to two instruments.To guarantee the published phase alignment, the test spec defines the input as a sine wave at a particular voltage and frequency and then we run a Discrete Fourier Transform on the acquired data. These nasty equations are how we calculate the amplitude and phase.atan2 is the two-argument form of arctan
  11. Agilent 33120Awaveform generator & Agilent E5810A LAN/GPIB gatewayControlling external equipment can be extremely easy, since we have a plethora of industry standards for instrument communication.We use a waveform generator that supports VXI-11, a protocol for instrument communication and control over a network. Does anyone use xml-rpc or json-rpc? VXI-11 is similar, but it’s based on the original ONC RPC implementation.IEEE-488 – GPIB (general purpose interface bus), introduced 1975, 488.2 defines instrument control commands/messages - *IDN?, *RST, *OPC? SCPI – standard commands for programmable instruments, defined common syntax, command structure, and data formats. Includes generic commands & instrument classes. Doesn’t specify the communication link.VXI-11 – spec published 1995, RPC (remote procedure calls) over IP, uses ASCII messages (inc IEEE-488)
  12. *RST – reset*OPC? – operation complete query, returns an ASCII "+1" when all pending overlapped operations have been completedDEF – default
  13. The test begins by setting the waveform generator to produce a sine wave.As the comment in the verify function notes, it only checks the return values of the calls. The actual verification is a little complicated, so that’s handled in a separate function that’s part of the calls list.
  14. This is the main test sequence. It starts by setting all of the devices to acquire a thousand samples, using a sample rate of a thousand samples per second, from all 48 channels. It also configures the devices in a master/slave configuration. The master device will send sync and trigger signals on particular hardware lines and the slaves are set to listen for those signals.The inner loop is part of the reason the full test takes several hours to run. Each acquisition takes data for 1 second, but the test uses 2000 acquisitions for each of several trigger configurations.The analyze data method is where almost all of the work actually happens. It reads the data from each device and calculates the magnitude and phase of the data from each analog board in each device.There are several conditions that could generate a failure here - not enough data received, the data has an error code set, the magnitude indicates a weak analog signal, there's timestamp or phase skew between the analog boards within a device, or there's timestamp or phase skew between the master and slaves.
  15. The analyze data method is where almost all of the work actually happens. It reads the data from each device and calculates the magnitude and phase of the data from each analog board in each device.There are several conditions that could generate a failure here - not enough data received, the data has an error code set, the magnitude indicates a weak analog signal, there's timestamp or phase skew between the analog boards within a device, or there's timestamp or phase skew between the master and slaves.
  16. Summary/questions