Skip to content

Commit

Permalink
Improve examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusgreuel committed Oct 31, 2024
1 parent 36fb894 commit e025c06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions examples/analog_in_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@

print(f"DWF Version: {dwf.Application.get_version()}")

with dwf.AnalogDiscovery2() as device:
with dwf.Device() as device:
print(f"Found device: {device.name} ({device.serial_number})")

scope = device.analog_input
wavegen = device.analog_output

print('Connect Waveform Generator output 1 to Oscilloscope input 1: W1 to 1+, GND to 1-')
input("Connect waveform generator to oscilloscope:\n- W1 to 1+\n- GND to 1-\nPress Enter to continue...")

print("Generating sine wave...")
wavegen[0].setup("sine", frequency=1, amplitude=2, start=True)
wavegen[0].setup("sine", frequency=1e3, amplitude=2, start=True)

print("Starting oscilloscope...")
scope[0].setup(range=5)
scope.setup_edge_trigger(mode="normal", channel=0, slope="rising", level=0, hysteresis=0.01, position=-0.25)
recorder = scope.record(sample_rate=100e3, length=2, configure=True, start=True)
scope.setup_edge_trigger(mode="normal", channel=0, slope="rising", level=0, hysteresis=0.01)
recorder = scope.record(sample_rate=1e6, length=2e-3, configure=True, start=True)

if recorder.lost_samples > 0:
print("Samples lost, reduce sample rate.")
Expand Down
4 changes: 3 additions & 1 deletion examples/analog_in_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

print(f"DWF Version: {dwf.Application.get_version()}")

with dwf.AnalogDiscovery2() as device:
with dwf.Device() as device:
print(f"Found device: {device.name} ({device.serial_number})")

scope = device.analog_input
wavegen = device.analog_output

input("Connect waveform generator to oscilloscope:\n- W1 to 1+\n- GND to 1-\nPress Enter to continue...")

print("Generating square wave...")
wavegen[0].setup("square", frequency=11, amplitude=1, offset=1, start=True)

Expand Down
2 changes: 1 addition & 1 deletion examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import dwfpy as dwf

with dwf.AnalogDiscovery2() as device:
with dwf.Device() as device:
print("Generating a 1kHz sine wave on WaveGen channel 1...")
device.analog_output["ch1"].setup("sine", frequency=1e3, amplitude=1, start=True)
input("Press Enter key to exit.")

0 comments on commit e025c06

Please sign in to comment.