Ejemplo n.º 1
0
def output_swing_plot(data, fig, error_plot=False):
    vcc = data.vcc
    extend(data)
    fw = FigureWrapper(
        data, fig,
        x='voltage',
        y='error' if error_plot else 'voltage',
        title='Maximum peak output voltage swing')
    yname = 'Vout_diff' if error_plot else 'Vout'
    for R in Rloads(data):
        fw.addcol(legend=unicode(format_ohm(R) if R else R),
                  x='Vout_expected',
                  y=yname,
                  filter_func=get_filter_func(R, 'output_swing'),
                  sortbyx=True,
                          )

    ax = fw.subplot
#    ax.legend(*ax.get_legend_handles_labels(), loc='upper center')
    ax.set_xlabel('Expected (V)')

#    ax.grid(True)
#    ax.axvline(x=0, color='black')
#    ax.axvline(x=dw.data.vcc, color='black')
#    ax.axhline(y=0, color='black')
    if error_plot:
        ax.set_ylabel('error (V)')
#        ax.axis([0, 5.1, -0.2, 0.2])
    else:
#        ax.axhline(y=dw.data.vcc, color='black')
        ax.plot([0, vcc], [0, vcc])
#        ax.axis([0, 5.1, 0, 5.1])
        ax.set_ylabel('Real (V)')
    return fig
Ejemplo n.º 2
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(data, fig, x='time', y='analog_value',
                       convert2voltage=voltage)

    fw.addcol(legend='volt', y='Avolt')
    fw.addcol(legend='current', y='Acurrent')
    return fig
Ejemplo n.º 3
0
def transfer_plot(data, fig):
    title = 'Voltage Transfer Curve'
    extend(data)
    fw = FigureWrapper(
        data,
        fig,
        x='Vin (V)',
        y='Vout (V)',
        title=title,
#        xlimits=[-5, 5],
#        ylimits=[-0.020, 0.020],
    )

    fw.subplot.plot(
        [0, data.Vmax],
        [0, data.Vmax],
        'r-')
    fw.subplot.plot(
        [0, data.Vmax],
        [data.Vmax, 0],
        'r-')

#     fw.addcol(legend='', x='Vin', y='Vout')
    fw.addcol(legend='up',
              x='Vin',
              y='Vout',
              filter_func=lambda e: e.reverse == 0,
              )
    fw.addcol(legend='down',
              x='Vin',
              y='Vout',
              filter_func=lambda e: e.reverse == 1,
              )

    return fig
Ejemplo n.º 4
0
def IV_curve_plot(data, fig):
    title = 'I/O pin current vs. output voltage'
    extend(data)
    fw = FigureWrapper(
        data,
        fig,
        x='voltage',
        y='I (A)',
        title=title,
        xlimits=[-5, 5],
        ylimits=[-0.020, 0.020],
    )

    x = 'Vx'
    y = 'I'

    fw.subplot.plot(
        [0, data.Vmax],
        [data.Imax, 0],
        'b-')
    fw.subplot.plot(
        [0, -data.Vmax],
        [-data.Imax, 0],
        'b-')

    fw.addcol(legend='', x=x, y=y)

    return fig
Ejemplo n.º 5
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(
        data, fig, x='time', y='analog_value', convert2voltage=voltage)

    fw.addcol(legend='out', y=lambda e: e.Aout)
    fw.addcol(legend='amp', y=lambda e: e.Aamp)
    return fig
Ejemplo n.º 6
0
def transfer_plot(data, fig, error_plot=False):
    data.measurements = filter_measurements(data.measurements, ['pwm_value'],
                                            ['Ain'])
    title = 'Transfer error plot (%s)' if error_plot else 'Transfer plot (%s)'
    title = title % (data.model)
    fw = FigureWrapper(
        data,
        fig,
        x='voltage',
        y='error (V)' if error_plot else 'voltage',
        title=title,
    )

    vcc = data.vcc
    fw.addcol(
        legend=data.config.pin_in,
        x=lambda e: pwm2v(e.pwm_value, vcc),
        y=lambda e: an2v(e.Ain, vcc) - (pwm2v(e.pwm_value, vcc)
                                        if error_plot else 0),
    )
    ax = fw.subplot
    if error_plot:
        ax.axis([0, 5.1, -0.050, 0.050])

    return fig
Ejemplo n.º 7
0
def transfer_plot(data, fig, error_plot=False):
    data.measurements = filter_measurements(data.measurements, ['value'],
                                            ['Ain'])
    title = 'Transfer error plot' if error_plot else 'Transfer plot'
    title = title
    fw = FigureWrapper(
        data,
        fig,
        x='voltage',
        y='error (V)' if error_plot else 'voltage',
        title=title,
    )

    vcc = data.vcc

    if error_plot:
        fw.subplot.plot([0, vcc], [vcc / 99, vcc / 99], 'r-')
        fw.subplot.plot([0, vcc], [-vcc / 99, -vcc / 99], 'r-')
    else:
        fw.subplot.plot([0, 0], [vcc, vcc], 'r-')

    fw.addcol(
        legend=data.config.pin_in,
        x=lambda e: pot2v(e.value, vcc),
        y=lambda e: an2v(e.Ain, vcc) - (pot2v(e.value, vcc)
                                        if error_plot else 0),
    )
    ax = fw.subplot
    if error_plot:
        ax.axis([0, 5.1, -0.1, 0.1])

    return fig
Ejemplo n.º 8
0
def dig_input_plot(data, fig):

    title = 'Digital input characteristic %s@%s' % (data.config.pin_dig_in, data.model)

    fw = FigureWrapper(
        data,
        fig,
        x='VCC percentage',
        y='digital in',
        title=title,
        ylimits=[-0.5, 1.5],
    )

    def fperc(e):
        return e.Ain * 100 / 1023

    fw.addcol(legend='up',
              x=fperc,
              y='Din',
              filter_func=lambda e: e.reverse == 0,
              )
    fw.addcol(legend='down',
              x=fperc,
              y='Din',
              filter_func=lambda e: e.reverse == 1,
              )

    return fig
Ejemplo n.º 9
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(
        data, fig, x='time', y='analog_value', convert2voltage=voltage)

    fw.addcol(legend='analog in', y=lambda e: e.Ain)
    fw.addcol(legend='digital in', y=lambda e: e.Din * 1023)
    return fig
Ejemplo n.º 10
0
def input_range_plot(data, fig, error_plot=False):
    vcc = data.vcc

    extend(data)
    fw = FigureWrapper(
        data,
        fig,
        x='voltage',
        y='error' if error_plot else 'voltage',
        title='Common-mode input voltage range')
#    print data.measurements

    yname = 'Vin_diff' if error_plot else 'Vopamp_minus'
    for R in [NO_LOAD]:
        fw.addcol(legend='',
                  x='Vplus',
                  y=yname,
                  filter_func=get_filter_func(R, 'input_range'),
                          )

    ax = fw.subplot
    ax.set_xlabel('opamp+ (V)')

#    ax.grid(True)
#    ax.axvline(x=0, color='black')
#    ax.axvline(x=dw.data.vcc, color='black')
    if error_plot:
#        ax.axhline(y=0, color='black')
        ax.set_ylabel('error (V)')
#        ax.axis([0, 5.1, -0.050, 0.050])
    else:
        ax.plot([0, vcc], [0, vcc])
#        ax.axis([0, 5.1, 0, 5.1])
        ax.set_ylabel('opamp- (V)')
    return fig
Ejemplo n.º 11
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(
        data, fig, x='time', y='analog_value', convert2voltage=voltage)

    fw.addcol(y='Ab')
    fw.addcol(y='Ac')

    return fig
Ejemplo n.º 12
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(data, fig, x="time", y="analog_value", convert2voltage=voltage)

    #     fw.addcol(legend=data.config.pin_in, y='Ain')
    #     fw.addcol(legend='%s relativ PWM' % data.config.pin_pwm,
    #               y=lambda e: e.value / 255 * 1023)
    fw.addcol(y="Ain")
    fw.addcol(y="value")
    return fig
Ejemplo n.º 13
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(
        data, fig, x='time', y='analog_value', convert2voltage=voltage)

    legend = data['config']['pin']
    fw.addcol(legend=legend,
              y='A',
              )
    return fig
Ejemplo n.º 14
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(
        data, fig, x='time', y='analog_value', convert2voltage=voltage)

    fw.addcol(legend='top', y=lambda e: e.get('Atop'))
    fw.addcol(legend='middle', y=lambda e: e.get('Amiddle'))
    fw.addcol(legend='bottom', y=lambda e: e.get('Abottom'))

    return fig
Ejemplo n.º 15
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(data,
                       fig,
                       x='time',
                       y='analog_value',
                       convert2voltage=voltage)

    fw.addcol(legend='in', y='Ain')
    return fig
Ejemplo n.º 16
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(
        data, fig, x='time', y='analog_value', convert2voltage=voltage)

#    fw.addcol(legend='rel pwm', y=lambda e: e.pwm_value/255*1023)
    fw.addcol(legend='in', y='Ain')
    fw.addcol(legend='out', y='Aout')
    fw.addcol(legend='amp', y='Aamp')
    return fig
Ejemplo n.º 17
0
def frequency_time_plot(data, fig):
    fw = FigureWrapper(data, fig, x='time', y='frequency', draw_axis=False)

    fw.addcol(y='frequency')
    #     fw.subplot.set_ylim(bottom=100000)
    #     fw.subplot.set_ylim(auto=True)
    #     ax = fw.subplot
    #     ax.set_autoscale_on(True)
    #     ax.autoscale_view(True,False,True)
    return fig
Ejemplo n.º 18
0
def frequency_time_plot(data, fig):
    fw = FigureWrapper(data, fig, x="time", y="frequency", draw_axis=False)

    fw.addcol(y="frequency")
    #     fw.subplot.set_ylim(bottom=100000)
    #     fw.subplot.set_ylim(auto=True)
    #     ax = fw.subplot
    #     ax.set_autoscale_on(True)
    #     ax.autoscale_view(True,False,True)
    return fig
Ejemplo n.º 19
0
def processed_analog_value_time_plot(data, fig):
    fw = FigureWrapper(
        data, fig, x='time', y='voltage')

    extend(data)

    fw.addcol(legend='Vin', y='Vin')
    fw.addcol(legend='Vout', y='Vout')
    fw.addcol(legend='Vamp', y='Vamp')
    return fig
Ejemplo n.º 20
0
def processed_analog_value_time_plot(data, fig):
    fw = FigureWrapper(data, fig, x='time', y='voltage')

    extend(data)

    #    fw.addcol(legend='rel pwm', y=lambda e: e.pwm_value/255*1023)
    fw.addcol(legend='Vin', y=lambda e: e.Vin)
    fw.addcol(legend='Vout', y=lambda e: e.Vout)
    fw.addcol(legend='Vamp', y=lambda e: e.Vamp)
    fw.addcol(legend='Vx', y=lambda e: e.Vx)
    fw.addcol(legend='I', y=lambda e: e.I)
    return fig
Ejemplo n.º 21
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(data,
                       fig,
                       x='time',
                       y='analog_value',
                       convert2voltage=voltage)

    #    fw.addcol(legend='top', y='Atop')
    fw.addcol(legend='middle', y='Amiddle')
    #    fw.addcol(legend='bottom', y='Abottom')

    return fw
Ejemplo n.º 22
0
def ohm_plot(data, fig):
    d = analyse1(data)
    #    print d
    newdata = dict(measurements=d, project='esr')

    #    print 676,newdata
    fw = FigureWrapper(newdata, fig, x='frequency', y='R')

    fw.addcol(x='frequency', y='Rx')
    ax = fw.subplot
    ax.set_xscale('log')
    # ax.set_yscale('log')
    return fig
Ejemplo n.º 23
0
def unity_gain_plot(data, fig, error_plot=False):
    #    dw = DataWrapper(data)
    config = data.config
    vcc = data.vcc
    measurements = data.measurements
    #    A = config.R2 / config.R1

    extend(data)
    fw = FigureWrapper(data,
                       fig,
                       x='voltage',
                       y='error' if error_plot else 'voltage',
                       title='Unity gain')

    #    ax = fig.add_subplot(111)

    yname = 'Vout_diff' if error_plot else 'Vout'
    for R in [NO_LOAD]:
        fw.addcol(
            legend='',
            x='Vout_expected',
            y=yname,
            filter_func=get_filter_func(R, 'unity_gain'),
        )
    ax = fw.subplot
    ax.set_xlabel('Vout_expected (V)')
    #    ax.grid(True)
    #    ax.axvline(x=0, color='black')
    #    ax.axvline(x=dw.data.vcc, color='black')
    if error_plot:
        limit = 0.050
        ax.axhline(y=limit, color='red')
        ax.axhline(y=-limit, color='red')

        # TODO: vlines
        #         interv = calculate_good_interval(config, measurements, limit=limit)
        #         if interv:
        #             ax.axvline(x=interv[0], color='red')
        #             ax.axvline(x=interv[1], color='red')

        ax.axhline(y=0, color='black')
        ax.set_ylabel('error (V)')


#        ax.axis([0, 5.1, -0.5, 0.5])
    else:
        ax.plot([0, vcc], [0, vcc])
        #        ax.axis([0, 5.1, 0, 5.1])
        ax.set_ylabel('Vout (V)')

    return fig
Ejemplo n.º 24
0
def ohm_plot(data, fig):
    d = analyse1(data)
#    print d
    newdata = dict(measurements=d, project='esr')

#    print 676,newdata
    fw = FigureWrapper(
        newdata, fig, x='frequency', y='R')

    fw.addcol(x='frequency', y='Rx')
    ax = fw.subplot
    ax.set_xscale('log')
    # ax.set_yscale('log')
    return fig
Ejemplo n.º 25
0
def unity_gain_plot(data, fig, error_plot=False):
#    dw = DataWrapper(data)
    config = data.config
    vcc = data.vcc
    measurements = data.measurements
#    A = config.R2 / config.R1

    extend(data)
    fw = FigureWrapper(
        data, fig,
        x='voltage',
        y='error' if error_plot else 'voltage',
        title='Unity gain')

#    ax = fig.add_subplot(111)

    yname = 'Vout_diff' if error_plot else 'Vout'
    for R in [NO_LOAD]:
        fw.addcol(legend='',
                  x='Vout_expected',
                  y=yname,
                  filter_func=get_filter_func(R, 'unity_gain'),
                          )
    ax = fw.subplot
    ax.set_xlabel('Vout_expected (V)')
#    ax.grid(True)
#    ax.axvline(x=0, color='black')
#    ax.axvline(x=dw.data.vcc, color='black')
    if error_plot:
        limit = 0.050
        ax.axhline(y=limit, color='red')
        ax.axhline(y=-limit, color='red')

        # TODO: vlines
#         interv = calculate_good_interval(config, measurements, limit=limit)
#         if interv:
#             ax.axvline(x=interv[0], color='red')
#             ax.axvline(x=interv[1], color='red')

        ax.axhline(y=0, color='black')
        ax.set_ylabel('error (V)')
#        ax.axis([0, 5.1, -0.5, 0.5])
    else:
        ax.plot([0, vcc], [0, vcc])
#        ax.axis([0, 5.1, 0, 5.1])
        ax.set_ylabel('Vout (V)')

    return fig
Ejemplo n.º 26
0
def processed_analog_value_time_plot(data, fig):
    fw = FigureWrapper(
        data, fig, x='time', y='voltage')

    extend(data)

#    fw.addcol(legend='rel pwm', y=lambda e: e.pwm_value/255*1023)
    fw.addcol(legend='Vin', y=lambda e: e.Vin)
    fw.addcol(legend='Vout', y=lambda e: e.Vout)
    fw.addcol(legend='Vamp', y=lambda e: e.Vamp)
    fw.addcol(legend='Vx', y=lambda e: e.Vx)
    fw.addcol(legend='I', y=lambda e: e.I)
    return fig
Ejemplo n.º 27
0
def frequency_time_plot(data, fig):
    title = 'Frequency (gate time=%s s)' % (data.config.gate_time)
    fw = FigureWrapper(
        data, 
        fig, 
        x='time', 
        y='frequency',
        draw_axis=False,
        title=title,
        )

    fw.addcol(y='frequency')
#     fw.subplot.set_ylim(bottom=100000)
#     fw.subplot.set_ylim(auto=True)
#     ax = fw.subplot
#     ax.set_autoscale_on(True)
#     ax.autoscale_view(True,False,True)
    return fig
Ejemplo n.º 28
0
def frequency_time_plot(data, fig):
    title = 'Frequency (gate time=%s s)' % (data.config.gate_time)
    fw = FigureWrapper(
        data,
        fig,
        x='time',
        y='frequency',
        draw_axis=False,
        title=title,
    )

    fw.addcol(y='frequency')
    #     fw.subplot.set_ylim(bottom=100000)
    #     fw.subplot.set_ylim(auto=True)
    #     ax = fw.subplot
    #     ax.set_autoscale_on(True)
    #     ax.autoscale_view(True,False,True)
    return fig
Ejemplo n.º 29
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(data,
                       fig,
                       x='time',
                       y='analog_value',
                       convert2voltage=voltage)

    fw.addcol(legend='plus', y='Aplus')
    fw.addcol(legend='minus', y='Aminus')
    fw.addcol(legend='out', y='Aout')
    return fig
Ejemplo n.º 30
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(
        data, fig, x='time', y='analog_value', convert2voltage=voltage)

    fw.addcol(legend='plus', y='Aplus')
    fw.addcol(legend='minus', y='Aminus')
    fw.addcol(legend='out', y='Aout')
    return fig
Ejemplo n.º 31
0
def dig_input_plot(data, fig):

    title = 'Digital input characteristic %s@%s' % (data.config.pin_dig_in,
                                                    data.model)

    fw = FigureWrapper(
        data,
        fig,
        x='VCC percentage',
        y='digital in',
        title=title,
        ylimits=[-0.5, 1.5],
    )

    def fperc(e):
        return e.Ain * 100 / 1023

    fw.addcol(
        legend='up',
        x=fperc,
        y='Din',
        filter_func=lambda e: e.reverse == 0,
    )
    fw.addcol(
        legend='down',
        x=fperc,
        y='Din',
        filter_func=lambda e: e.reverse == 1,
    )

    return fig
Ejemplo n.º 32
0
def transfer_plot(data, fig):
    title = 'Voltage Transfer Curve'
    extend(data)
    fw = FigureWrapper(
        data,
        fig,
        x='Vin (V)',
        y='Vout (V)',
        title=title,
        #        xlimits=[-5, 5],
        #        ylimits=[-0.020, 0.020],
    )

    fw.subplot.plot([0, data.Vmax], [0, data.Vmax], 'r-')
    fw.subplot.plot([0, data.Vmax], [data.Vmax, 0], 'r-')

    #     fw.addcol(legend='', x='Vin', y='Vout')
    fw.addcol(
        legend='up',
        x='Vin',
        y='Vout',
        filter_func=lambda e: e.reverse == 0,
    )
    fw.addcol(
        legend='down',
        x='Vin',
        y='Vout',
        filter_func=lambda e: e.reverse == 1,
    )

    return fig
Ejemplo n.º 33
0
def IV_curve_plot(data, fig):
    title = 'I/O pin current vs. output voltage'
    extend(data)
    fw = FigureWrapper(
        data,
        fig,
        x='voltage',
        y='I (A)',
        title=title,
        xlimits=[-5, 5],
        ylimits=[-0.020, 0.020],
    )

    x = 'Vx'
    y = 'I'

    fw.subplot.plot([0, data.Vmax], [data.Imax, 0], 'b-')
    fw.subplot.plot([0, -data.Vmax], [-data.Imax, 0], 'b-')

    fw.addcol(legend='', x=x, y=y)

    return fig
Ejemplo n.º 34
0
def ohm_invf_plot(data, fig):
    d = analyse1(data)
#    print d
    measurements = d
    newdata = dict(measurements=d, project='esr')

#    print 676,newdata
    fw = FigureWrapper(
        newdata, fig, x='1/frequency', y='Rx')
#    def xtransform(f):
#        return 1000000 / (2 * 3.141 * f)
    fw.addcol(x=lambda e: 1 / (e.frequency), y='Rx')
    ax = fw.subplot
#    fmin = filter(lambda e: e['Rx'] is not None, measurements)[0]['frequency']
    fmin = min(measurements['frequency'])
#    assert 0 ,fmin
    ax.set_autoscale_on(False)
#    @traced

    def Xc(f, c):
        return 1 / (2 * np.pi * f * c / 1e6)
    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 0.1)], label='100n')
    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 1)], label='1u')
    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 10)], label='10u')
    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 100)], label='100u')
    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 1000)], label='1000u')

    fw.update_legend()

    def formatter(x, pos):
        if x:
            return int(1.0 / x)
        else:
            return np.inf

    ax.xaxis.set_major_formatter(FuncFormatter(formatter))

    return fig
Ejemplo n.º 35
0
def processed_analog_value_time_plot(data, fig):
    fw = FigureWrapper(data, fig, x='time', y='voltage')

    extend(data)

    fw.addcol(legend='Vin', y='Vin')
    fw.addcol(legend='Vout', y='Vout')
    fw.addcol(legend='Vamp', y='Vamp')
    return fig
Ejemplo n.º 36
0
def input_range_plot(data, fig, error_plot=False):
    vcc = data.vcc

    extend(data)
    fw = FigureWrapper(data,
                       fig,
                       x='voltage',
                       y='error' if error_plot else 'voltage',
                       title='Common-mode input voltage range')
    #    print data.measurements

    yname = 'Vin_diff' if error_plot else 'Vopamp_minus'
    for R in [NO_LOAD]:
        fw.addcol(
            legend='',
            x='Vplus',
            y=yname,
            filter_func=get_filter_func(R, 'input_range'),
        )

    ax = fw.subplot
    ax.set_xlabel('opamp+ (V)')

    #    ax.grid(True)
    #    ax.axvline(x=0, color='black')
    #    ax.axvline(x=dw.data.vcc, color='black')
    if error_plot:
        #        ax.axhline(y=0, color='black')
        ax.set_ylabel('error (V)')


#        ax.axis([0, 5.1, -0.050, 0.050])
    else:
        ax.plot([0, vcc], [0, vcc])
        #        ax.axis([0, 5.1, 0, 5.1])
        ax.set_ylabel('opamp- (V)')
    return fig
Ejemplo n.º 37
0
def output_swing_plot(data, fig, error_plot=False):
    vcc = data.vcc
    extend(data)
    fw = FigureWrapper(data,
                       fig,
                       x='voltage',
                       y='error' if error_plot else 'voltage',
                       title='Maximum peak output voltage swing')
    yname = 'Vout_diff' if error_plot else 'Vout'
    for R in Rloads(data):
        fw.addcol(
            legend=unicode(format_ohm(R) if R else R),
            x='Vout_expected',
            y=yname,
            filter_func=get_filter_func(R, 'output_swing'),
            sortbyx=True,
        )

    ax = fw.subplot
    #    ax.legend(*ax.get_legend_handles_labels(), loc='upper center')
    ax.set_xlabel('Expected (V)')

    #    ax.grid(True)
    #    ax.axvline(x=0, color='black')
    #    ax.axvline(x=dw.data.vcc, color='black')
    #    ax.axhline(y=0, color='black')
    if error_plot:
        ax.set_ylabel('error (V)')


#        ax.axis([0, 5.1, -0.2, 0.2])
    else:
        #        ax.axhline(y=dw.data.vcc, color='black')
        ax.plot([0, vcc], [0, vcc])
        #        ax.axis([0, 5.1, 0, 5.1])
        ax.set_ylabel('Real (V)')
    return fig
Ejemplo n.º 38
0
def transfer_plot(data, fig, error_plot=False):
    data.measurements = filter_measurements(
        data.measurements, ['pwm_value'], ['Ain'])
    title = 'Transfer error plot (%s)' if error_plot else 'Transfer plot (%s)'
    title = title % (data.model)
    fw = FigureWrapper(
        data,
        fig,
        x='voltage',
        y='error (V)' if error_plot else 'voltage',
        title=title,
    )

    vcc = data.vcc
    fw.addcol(legend=data.config.pin_in,
              x=lambda e: pwm2v(e.pwm_value, vcc),
              y=lambda e: an2v(
                  e.Ain, vcc) - (pwm2v(e.pwm_value, vcc) if error_plot else 0),
              )
    ax = fw.subplot
    if error_plot:
        ax.axis([0, 5.1, -0.050, 0.050])

    return fig
Ejemplo n.º 39
0
def transfer_plot(data, fig, error_plot=False):
    data.measurements = filter_measurements(data.measurements, ["value"], ["Ain"])
    title = "Transfer error plot" if error_plot else "Transfer plot"
    title = title
    fw = FigureWrapper(data, fig, x="voltage", y="error (V)" if error_plot else "voltage", title=title)

    vcc = data.vcc

    if error_plot:
        fw.subplot.plot([0, vcc], [vcc / 99, vcc / 99], "r-")
        fw.subplot.plot([0, vcc], [-vcc / 99, -vcc / 99], "r-")
    else:
        fw.subplot.plot([0, 0], [vcc, vcc], "r-")

    fw.addcol(
        legend=data.config.pin_in,
        x=lambda e: pot2v(e.value, vcc),
        y=lambda e: an2v(e.Ain, vcc) - (pot2v(e.value, vcc) if error_plot else 0),
    )
    ax = fw.subplot
    if error_plot:
        ax.axis([0, 5.1, -0.1, 0.1])

    return fig
Ejemplo n.º 40
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(data,
                       fig,
                       x='time',
                       y='analog_value',
                       convert2voltage=voltage)

    fw.addcol(legend='analog in', y=lambda e: e.Ain)
    fw.addcol(legend='digital in', y=lambda e: e.Din * 1023)
    return fig
Ejemplo n.º 41
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(data,
                       fig,
                       x='time',
                       y='analog_value',
                       convert2voltage=voltage)

    #    fw.addcol(legend='rel pwm', y=lambda e: e.pwm_value/255*1023)
    fw.addcol(legend='in', y='Ain')
    fw.addcol(legend='out', y='Aout')
    fw.addcol(legend='amp', y='Aamp')
    return fig
Ejemplo n.º 42
0
def analog_value_time_plot(data, fig, voltage=False):
    fw = FigureWrapper(data,
                       fig,
                       x='time',
                       y='analog_value',
                       convert2voltage=voltage)

    #     fw.addcol(legend=data.config.pin_in, y='Ain')
    #     fw.addcol(legend='%s relativ PWM' % data.config.pin_pwm,
    #               y=lambda e: e.pwm_value / 255 * 1023)
    fw.addcol(y='Ain')
    fw.addcol(y='pwm_value')
    return fig
Ejemplo n.º 43
0
def io_iv_plot(data, fig):
    title = 'Output pin current vs. output voltage (%s)' % (data.model)

    extend(data)
    fw = FigureWrapper(
        data,
        fig,
        y='voltage',
        x='I (mA)',
        title=title)
    y = 'Vout'
    x = 'Iabs'

    fw.addcol(legend='high', x=x, y=y,
              filter_func=lambda e: e.Dout == 1)
    fw.addcol(legend='low', x=x, y=y,
              filter_func=lambda e: e.Dout == 0)
    return fig
Ejemplo n.º 44
0
def ohm_invf_plot(data, fig):
    d = analyse1(data)
    #    print d
    measurements = d
    newdata = dict(measurements=d, project='esr')

    #    print 676,newdata
    fw = FigureWrapper(newdata, fig, x='1/frequency', y='Rx')
    #    def xtransform(f):
    #        return 1000000 / (2 * 3.141 * f)
    fw.addcol(x=lambda e: 1 / (e.frequency), y='Rx')
    ax = fw.subplot
    #    fmin = filter(lambda e: e['Rx'] is not None, measurements)[0]['frequency']
    fmin = min(measurements['frequency'])
    #    assert 0 ,fmin
    ax.set_autoscale_on(False)

    #    @traced

    def Xc(f, c):
        return 1 / (2 * np.pi * f * c / 1e6)

    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 0.1)], label='100n')
    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 1)], label='1u')
    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 10)], label='10u')
    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 100)], label='100u')
    ax.plot([0, 1 / (fmin)], [0, Xc(fmin, 1000)], label='1000u')

    fw.update_legend()

    def formatter(x, pos):
        if x:
            return int(1.0 / x)
        else:
            return np.inf

    ax.xaxis.set_major_formatter(FuncFormatter(formatter))

    return fig