Created
September 11, 2024 14:50
-
-
Save bodokaiser/03d4d959c68a4202437ff3107ef94725 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spcm | |
import numpy as np | |
# Define frequency ranges for each channel | |
ch0_freqs = np.linspace(85.0e6, 121.0e6, 3) | |
ch1_freqs = np.linspace(84.5e6, 120.5e6, 3) | |
# Assign cores to each channel | |
ch0_cores = np.concatenate((np.arange(0, 8), np.arange(12, 20))) | |
ch1_cores = np.concatenate((np.arange(8, 12), [20])) | |
# Check if the number of frequencies exceeds the number of cores | |
if len(ch0_freqs) > len(ch0_cores): | |
raise RuntimeError(f"Number of frequencies for CH0 ({len(ch0_freqs)}) exceeds available cores ({len(ch0_cores)}).") | |
if len(ch1_freqs) > len(ch1_cores): | |
raise RuntimeError(f"Number of frequencies for CH1 ({len(ch1_freqs)}) exceeds available cores ({len(ch1_cores)}).") | |
# Configure and use the SPCM card | |
with spcm.Card(serial_number=18924) as card: | |
channels = spcm.Channels(card) | |
channels.enable(True) | |
channels.amp(2.0 * spcm.units.V) | |
card.card_mode(spcm.SPC_REP_STD_DDS) | |
dds = spcm.DDS(card, channels=channels) | |
dds.reset() | |
dds.cores_on_channel(1, *map(lambda core: 2**core, ch1_cores)) | |
frac = 0.40 | |
for freq, core in zip(ch0_freqs, ch0_cores): | |
dds.amp(core, frac / len(ch0_freqs)) | |
dds.freq(core, freq) | |
for freq, core in zip(ch1_freqs, ch1_cores): | |
dds.amp(core, frac / len(ch1_freqs)) | |
dds.freq(core, freq) | |
dds.exec_at_trg() | |
dds.write_to_card() | |
card.start(spcm.M2CMD_CARD_ENABLETRIGGER | spcm.M2CMD_CARD_FORCETRIGGER) | |
input("Press enter to exit.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment