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

triggering source on the analog channels #52

Open
ascnave opened this issue Jan 25, 2024 · 3 comments
Open

triggering source on the analog channels #52

ascnave opened this issue Jan 25, 2024 · 3 comments

Comments

@ascnave
Copy link
Contributor

ascnave commented Jan 25, 2024

Hi Christian,

First of all, I like to thanks you for this great contribution, I recently started to use M2p.5946-x4 cards and found your code extremely useful.

For my application I would like to use as external trigger the main analog channel of the card. So I can display the channel I am triggering on.

In the manual p'103, they give some examples. I would like to do something like that:

trigger_settings = TriggerSettings(
trigger_sources=[TriggerSource.SPC_TMASK_CH0],
external_trigger_mode=ExternalTriggerMode.SPC_TM_POS,
external_trigger_level_in_mv=1000,
)

Is this option implemented in your code?

Thank you very much for your support.

Cheers,
Andy

@crnbaker
Copy link
Collaborator

Hi Andy, sorry for the slow reply. I've had a quick look at the docs and I think you can do this manually:

from spectrum_gmbh.py_header.regs import SPC_TMASK0_CH0, SPC_TM_POS, SPC_TRIG_CH0_MODE, SPC_TRIG_CH_ORMASK0
from spectrumdevice import SpectrumDigitiserCard
from spectrumdevice.settings import ExternalTriggerMode, TriggerSettings, TriggerSource

card = SpectrumDigitiserCard(device_number=0)

# Disable the "external" trigger
trigger_settings = TriggerSettings(
    trigger_sources=[TriggerSource.SPC_TMASK_NONE],
    external_trigger_mode=ExternalTriggerMode.SPC_TM_NONE,
    external_trigger_level_in_mv=1000,
)
card.configure_trigger(trigger_settings)

# Enable channel 0 in the trigger OR mask and set the mode
card.write_to_spectrum_device_register(SPC_TRIG_CH_ORMASK0, SPC_TMASK0_CH0)
card.write_to_spectrum_device_register(SPC_TRIG_CH0_MODE, SPC_TM_POS)

Thanks for raising this, I'll try to get it implemented properly as soon as I can! Hopefully the above will work for you in the meantime.

And thanks for using the library!

@ascnave
Copy link
Contributor Author

ascnave commented Feb 22, 2024

Hi Christian,

Thank you very much, I tested this solution and it worked on card M2p.5946-x4. However I needed to make a few small modification. See below the code I use to set-up the digitiser using channel 1 for triggering:

import spectrum_gmbh.regs as registry
from spectrumdevice.settings import TriggerSettings, AcquisitionSettings, TriggerSource, ExternalTriggerMode, AcquisitionMode
from spectrumdevice.settings.channel import InputImpedance
from spectrumdevice import SpectrumDigitiserCard

def Set_digitizer():
trigger_settings = TriggerSettings(
trigger_sources=[TriggerSource.SPC_TMASK_NONE], #TriggerSource.SPC_TMASK_EXT0 SPC_TMASK_NONE
external_trigger_mode=ExternalTriggerMode.SPC_TM_NONE, # ExternalTriggerMode.SPC_TM_NEG SPC_TM_NONE
external_trigger_level_in_mv=2500,
)

acquisition_settings = AcquisitionSettings(
acquisition_mode=AcquisitionMode.SPC_REC_FIFO_MULTI,
sample_rate_in_hz=80000000, # at 80 MHz one sample measured every 12.5 ns
acquisition_length_in_samples=8192, # x 12.5 ns -> duration of measurement, must be a multiple of 8, see page 133
pre_trigger_length_in_samples=8, # must be a multiple of 8
timeout_in_ms=2000,
enabled_channels=[0, 1, 2, 3],
vertical_ranges_in_mv=[2000, 10000, 10000, 500], # 200, 500, 1000, 2000, 5000, 10000 mV
vertical_offsets_in_percent=[0, 0, 0, 0], # only integer
input_impedances=[InputImpedance.FIFTY_OHM, InputImpedance.ONE_MEGA_OHM,
InputImpedance.ONE_MEGA_OHM,InputImpedance.ONE_MEGA_OHM],
timestamping_enabled=False,
batch_size=1
)

card = SpectrumDigitiserCard(device_number=0)
card.configure_trigger(trigger_settings)

Enable channel 1 in the trigger OR mask and set the mode

card.write_to_spectrum_device_register(registry.SPC_TRIG_CH_ORMASK0, registry.SPC_TMASK0_CH1)
card.write_to_spectrum_device_register(registry.SPC_TRIG_CH1_MODE, registry.SPC_TM_NEG)

card.configure_acquisition(acquisition_settings)

return card

@crnbaker
Copy link
Collaborator

That's great, thanks for the example. I'll leave the issue open as I'd still like to make it easier to do this in spectrumdevice.

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

2 participants