Beispiel #1
0
        niscope_types.InitiateAcquisitionRequest(vi=vi))).status)

    # Allocate space for the waveform according to the max number of
    # points to fetch and the number of waveforms.
    channel_list = channels.split(',')
    total_samples = int(total_acquisition_time_in_seconds * sample_rate_in_hz)
    waveforms = [
        np.ndarray(total_samples, dtype=np.float64) for c in channel_list
    ]

    # Set fetch relative to attribute.
    CheckForError(vi, (client.SetAttributeViInt32(
        niscope_types.SetAttributeViInt32Request(
            vi=vi,
            channel_list="",
            attribute_id=niscope_types.NiScopeAttributes.
            NISCOPE_ATTRIBUTE_FETCH_RELATIVE_TO,
            value=niscope_types.NiScopeInt32AttributeValues.
            NISCOPE_INT32_FETCH_RELATIVE_TO_VAL_READ_POINTER))).status)

    # Fetch continuously until all samples are acquired.
    current_pos = 0
    samples_per_fetch = 100
    while current_pos < total_samples:

        # We fetch each channel at a time so we don't have to de-interleave afterwards.
        # We do not keep the wfm_info returned from fetch.
        for channel_name, waveform in zip(channel_list, waveforms):
            fetch_response = client.Fetch(
                niscope_types.FetchRequest(vi=vi,
                                           channel_list=channel_name,
Beispiel #2
0
    # Configure Horizontal Timing
    config_result = scope_service.ConfigureHorizontalTiming(
        niscope_types.ConfigureHorizontalTimingRequest(vi=vi,
                                                       min_sample_rate=1000000,
                                                       min_num_pts=1000,
                                                       ref_position=50,
                                                       num_records=1,
                                                       enforce_realtime=True))
    CheckForError(vi, config_result.status)

    # Setup an Edge Trigger
    result = scope_service.SetAttributeViInt32(
        niscope_types.SetAttributeViInt32Request(
            vi=vi,
            attribute_id=niscope_types.NiScopeAttributes.
            NISCOPE_ATTRIBUTE_TRIGGER_TYPE,
            value=niscope_types.NiScopeInt32AttributeValues.
            NISCOPE_INT32_TRIGGER_TYPE_VAL_EDGE_TRIGGER))
    CheckForError(vi, result.status)

    conf_trigger_edge_result = scope_service.ConfigureTriggerEdge(
        niscope_types.ConfigureTriggerEdgeRequest(
            vi=vi,
            trigger_source=channels,
            level=0.00,
            slope=niscope_types.TriggerSlope.
            TRIGGER_SLOPE_NISCOPE_VAL_POSITIVE,
            trigger_coupling=niscope_types.TriggerCoupling.
            TRIGGER_COUPLING_NISCOPE_VAL_DC,
            holdoff=0.0))
    CheckForError(vi, conf_trigger_edge_result.status)
confTrigger_edge_result = scope_service.ConfigureTriggerEdge(
    niscope_types.ConfigureTriggerEdgeRequest(
        vi=vi,
        trigger_source=channels,
        level=0.00,
        trigger_coupling=niscope_types.TriggerCoupling.
        TRIGGER_COUPLING_NISCOPE_VAL_DC,
        slope=niscope_types.TriggerSlope.TRIGGER_SLOPE_NISCOPE_VAL_POSITIVE))
CheckStatus(scope_service, vi, confTrigger_edge_result)

result = scope_service.SetAttributeViInt32(
    niscope_types.SetAttributeViInt32Request(
        vi=vi,
        channel_list=channels,
        attribute_id=niscope_types.NiScopeAttributes.
        NISCOPE_ATTRIBUTE_MEAS_REF_LEVEL_UNITS,
        value=niscope_types.NiScopeInt32AttributeValues.
        NISCOPE_INT32_REF_LEVEL_UNITS_VAL_VOLTS))
CheckStatus(scope_service, vi, result)

# Read a waveform from the scope
read_result = scope_service.Read(
    niscope_types.ReadRequest(vi=vi,
                              channel_list=channels,
                              timeout=10000,
                              num_samples=100000))
CheckStatus(scope_service, vi, read_result)
values = read_result.waveform[0:10]
print(values)