Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

record value in waveform_info struct returned from niscope fetch methods is wrong if record_number is non-zero #1510

Closed
sbethur opened this issue Aug 13, 2020 · 0 comments · Fixed by #1515

Comments

@sbethur
Copy link
Contributor

sbethur commented Aug 13, 2020

Description of issue

record value in waveform_info struct returned from niscope fetch methods is wrong if record_number is non-zero. Affected public methods:

  • fetch
  • fetch_into
  • read

System report

Command: python -c "import niscope; niscope.print_diagnostic_information()"

Output:

OS:
    Name:      Windows
    Version:   10.0.16299
    Bits:      64
Driver:
    Name:      NI-SCOPE
    Version:   20.0.0.49152
Module:
    Name:      niscope
    Version:   1.3.1
Python:
    Version:   3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
    Bits:      64
    Is_Venv:   True
    Installed Packages:
        zipp==3.1.0
        toml==0.10.1
        six==1.15.0
        setuptools==49.3.1
        pytest==6.0.1
        pyparsing==2.4.7
        py==1.9.0
        pluggy==0.13.1
        pip==20.2.1
        packaging==20.4
        numpy==1.19.1
        nitclk==1.3.1
        niscope==1.3.1
        nidigital==0.9.1
        more-itertools==8.4.0
        monotonic==1.5
        iniconfig==1.0.1
        importlib-metadata==1.7.0
        hightime==0.2.0
        fasteners==0.15
        colorama==0.4.3
        attrs==19.3.0
        atomicwrites==1.4.0

Steps to reproduce issue

import nifgen
import niscope

import statistics
import time

def waveform_mean(waveforms, channel, record):
    wfm = next(wfm for wfm in waveforms if (wfm.channel == channel and wfm.record == record))
    return statistics.mean(wfm.samples)

with nifgen.Session("PXI1Slot2") as fgen_session, niscope.Session("PXI1Slot3") as scope_session:

    fgen_session.output_mode = nifgen.OutputMode.FUNC
    fgen_session.func_waveform = nifgen.Waveform.DC
    fgen_session.load_impedance = 1e6
    fgen_session.channels[0].func_dc_offset = 0.4
    fgen_session.channels[1].func_dc_offset = -0.4

    scope_session.min_sample_rate = 100e6
    scope_session.horz_num_records = 3
    scope_session.horz_min_num_pts = 1000
    scope_session.trigger_type = niscope.TriggerType.IMMEDIATE
    scope_session.channels[0,1].channel_enabled = True
    scope_session.channels[0,1].vertical_coupling = niscope.VerticalCoupling.DC
    scope_session.channels[0,1].vertical_range = 1.0
    scope_session.channels[0,1].input_impedance = 1e6

    fgen_session.initiate()
    time.sleep(1)
    scope_session.initiate()

    waveforms1 = scope_session.channels[0,1].fetch(num_samples=1000, num_records=3)
    waveforms2 = scope_session.channels[0,1].fetch(num_samples=10, offset=50, num_records=3)

for channel in ['0','1']:
    for record in [0,1,2]:
        average = waveform_mean(waveforms1, channel, record)
        print("Channel %s, Record %d average: %f" % (channel, record, average))

print()

for wfm in waveforms2:
    average = statistics.mean(wfm.samples)
    print("Channel %s, Record %d average: %f" % (wfm.channel, wfm.record, average))

# Output:
# Channel 0, Record 0 average: 0.398528
# Channel 0, Record 1 average: -0.402130
# Channel 0, Record 2 average: 0.398400
# Channel 1, Record 0 average: -0.402165
# Channel 1, Record 1 average: 0.398511
# Channel 1, Record 2 average: -0.402210
#
# Channel 0, Record 50 average: 0.397490
# Channel 0, Record 51 average: -0.402677
# Channel 0, Record 52 average: 0.398914
# Channel 1, Record 50 average: -0.401785
# Channel 1, Record 51 average: 0.399121
# Channel 1, Record 52 average: -0.401847
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant