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

Issues With changing the sampling interval #150

Open
OscarGrime opened this issue Jun 18, 2019 · 8 comments
Open

Issues With changing the sampling interval #150

OscarGrime opened this issue Jun 18, 2019 · 8 comments

Comments

@OscarGrime
Copy link

Hello, I just started using these scripts to run my picoscope via the terminal. I am running into an issue in that I am not able to easily change the length of recording and the sampling rate. I am new to hardware scripting so any help would be great! I am probably missing something dumb.

@hmaarrfk
Copy link
Collaborator

It would help if you shared the code you are using. Could you please share that?

@OscarGrime
Copy link
Author

if name == "main":
print(doc)

print("Attempting to open Picoscope 2000...")

ps = ps2000.PS2000()
# Uncomment this line to use with the 2000a/2000b series
# ps = ps2000a.PS2000a()

print("Found the following picoscope:")
print(ps.getAllUnitInfo())

waveform_desired_duration = 50E-3
obs_duration = 3 * waveform_desired_duration
sampling_interval = obs_duration / 4096

(actualSamplingInterval, nSamples, maxSamples) = \
    ps.setSamplingInterval(sampling_interval, obs_duration)
print("Sampling interval = %f ns" % (actualSamplingInterval * 1E9))
print("Taking  samples = %d" % nSamples)
print("Maximum samples = %d" % maxSamples)

# the setChannel command will chose the next largest amplitude
channelRange = ps.setChannel('A', 'DC', 2.0, 0.0, enabled=True,
                             BWLimited=False)
print("Chosen channel range = %d" % channelRange)

ps.setSimpleTrigger('A', 1.0, 'Falling', timeout_ms=100, enabled=True)

ps.setSigGenBuiltInSimple(offsetVoltage=0, pkToPk=1.2, waveType="Sine",
                          frequency=50E3)

ps.runBlock()
ps.waitReady()
print("Waiting for awg to settle.")
time.sleep(2.0)
ps.runBlock()
ps.waitReady()
print("Done waiting for trigger")
dataA = ps.getDataV('A', nSamples, returnOverflow=False)

dataTimeAxis = np.arange(nSamples) * actualSamplingInterval

ps.stop()
ps.close()
f = open("test.bin", "wb")
s = struct.pack('f'*len(dataA), *dataA)
f.write(s)
f.close()

# Uncomment following for call to .show() to not block
# plt.ion()

plt.figure()
plt.plot(dataA, label="Clock")
plt.grid(True, which='major')
plt.title("Picoscope 2000 waveforms")
plt.ylabel("Voltage (V)")
plt.xlabel("Time (ms)")
plt.legend()

plt.show()

the same on as the one colin has in the examples folder: https://github.com/colinoflynn/pico-python/blob/master/examples/ps2000_demo.py

@hmaarrfk
Copy link
Collaborator

Do you get any error?

@OscarGrime
Copy link
Author

This is my error(Error calling _lowLevelGetTimebase)
I change waveform_desired_duration from 50E-6 to 50E-2. I thought this means the time of the waveform.

@hmaarrfk
Copy link
Collaborator

If i recall correctly, timebase is something like the sampling time.

Was that your understanding?

@juhakivekas
Copy link

I ran into this issue too! This seems to be because of the "sampling_interval = obs_duration / 4096" line. I think sometimes the calculation will result in taking more samples than the maximum (My 2204a can only sample 3968 samples) and that makes the setting of the interval fail. I reduced the divisor and got it working!

@hmaarrfk
Copy link
Collaborator

hmaarrfk commented Aug 1, 2021

patches are welcome. happy to review and to release.

@hmaarrfk
Copy link
Collaborator

hmaarrfk commented Aug 1, 2021

it is appreciated if you can justify the patch with a screenshot from documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants