test18.py 2.5 KB
Newer Older
1 2 3 4 5 6 7
#!   /usr/bin/env   python
#    coding: utf8

# Copyright CERN, 2011
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
8
# Last modifications: 4/6/2012
9

10
# Import system modules
11 12 13 14
import sys
import time
import os

15 16 17 18 19 20
# Add common modules and libraries location to path
sys.path.append('../../../')
sys.path.append('../../../gnurabbit/python/')
sys.path.append('../../../common/')

# Import common modules
21
from ptsexcept import *
22
import rr
23

24 25 26 27
# Import specific modules
from numpy import *
from pylab import *
from calibr_box import *
28
import find_usb_tty
29 30 31 32 33 34 35 36 37 38 39
from PAGE.Agilent33250A import *
from PAGE.SineWaveform import *


"""
test18: Test calibration box

"""


NB_CHANNELS = 4
40
AWG_SET_SLEEP = 0.3
41 42 43 44


def main (default_directory = '.'):

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    # Constants declaration
    TEST_NB = 18

    # Calibration box vendor and device IDs
    BOX_USB_VENDOR_ID = 0x10c4 # Cygnal Integrated Products, Inc.
    BOX_USB_DEVICE_ID = 0xea60 # CP210x Composite Device

    try:

        # Objects declaration
        usb_tty = find_usb_tty.CttyUSB()
        box_tty = usb_tty.find_usb_tty(BOX_USB_VENDOR_ID, BOX_USB_DEVICE_ID)
        box = CCalibr_box(box_tty[0])

        # Calibration box version 2
        for i in range(NB_CHANNELS):
            box.select_output_ch(i+1, '10V')
            print "Channel %d = AWG, others = 10V Vref"%(i+1)
            raw_input('Press ENTER to continue...')

        for i in range(NB_CHANNELS):
            box.select_output_ch(i+1, '1V')
            print "Channel %d = AWG, others = 1V Vref"%(i+1)
            raw_input('Press ENTER to continue...')
69

70 71 72 73
        for i in range(NB_CHANNELS):
            box.select_output_ch(i+1, '100mV')
            print "Channel %d = AWG, others = 100mV Vref"%(i+1)
            raw_input('Press ENTER to continue...')
74 75


76 77
    except(CalibrBoxOperationError) as e:
        raise PtsError("Test failed: %s" % e)
78 79


80

81
    # Calibration box version 1
82
    """
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
    print('\n=== 10V range ===')
    box.select_output('10V')
    print('Box gpio: %X')%box.get_config()
    raw_input('Press ENTER to continue...')
    print('\n=== 1V range ===')
    box.select_output('1V')
    print('Box gpio: %X')%box.get_config()
    raw_input('Press ENTER to continue...')
    print('\n=== 100mV range ===')
    box.select_output('100mV')
    print('Box gpio: %X')%box.get_config()
    raw_input('Press ENTER to continue...')
    print('\n=== AWG ===')
    box.select_output('AWG')
    print('Box gpio: %X')%box.get_config()
98
    """
99 100 101 102


if __name__ == '__main__' :
    main()