Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AWG control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
whuie2
AWG control
Commits
4392bd6c
Commit
4392bd6c
authored
1 year ago
by
Marshal
Browse files
Options
Downloads
Patches
Plain Diff
changed toggle channel behavior for enabling multiple channels
parent
11e4e308
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Python/lib/AWG.py
+26
-16
26 additions, 16 deletions
Python/lib/AWG.py
with
26 additions
and
16 deletions
Python/lib/AWG.py
+
26
−
16
View file @
4392bd6c
...
@@ -230,18 +230,25 @@ class AWG:
...
@@ -230,18 +230,25 @@ class AWG:
"
HOLDLAST
"
:
SPCM_STOPLVL_HOLDLAST
}
"
HOLDLAST
"
:
SPCM_STOPLVL_HOLDLAST
}
if
not
self
.
is_connected
():
if
not
self
.
is_connected
():
return
return
if
self
.
channel
[
ch
]
==
0
:
enable_mask
=
0
self
.
channel
[
ch
]
=
1
self
.
ch_amp
=
amplitude
for
c
in
ch
:
spcm_dwSetParam_i64
(
self
.
card
,
SPC_CHENABLE
,
int64
(
2
**
ch
))
# see CHANNEL0-3 in regs.py for detail
self
.
channel
[
c
]
=
1
spcm_dwSetParam_i32
(
self
.
card
,
SPC_ENABLEOUT0
+
ch
*
(
SPC_ENABLEOUT1
-
SPC_ENABLEOUT0
),
1
)
enable_mask
=
enable_mask
|
2
**
c
spcm_dwSetParam_i32
(
self
.
card
,
SPC_AMP0
+
ch
*
(
SPC_AMP1
-
SPC_AMP0
),
amplitude
)
spcm_dwSetParam_i64
(
self
.
card
,
SPC_CHENABLE
,
enable_mask
)
# see CHANNEL0-3 in regs.py for detail
spcm_dwSetParam_i32
(
self
.
card
,
SPC_CH0_STOPLEVEL
+
ch
*
(
SPC_CH1_STOPLEVEL
-
SPC_CH0_STOPLEVEL
),
stopmask
[
stoplvl
])
else
:
for
c
in
ch
:
self
.
channel
[
ch
]
=
0
c
=
int
(
c
)
spcm_dwSetParam_i32
(
self
.
card
,
SPC_ENABLEOUT0
+
ch
*
(
SPC_ENABLEOUT1
-
SPC_ENABLEOUT0
),
0
)
spcm_dwSetParam_i32
(
self
.
card
,
SPC_ENABLEOUT0
+
c
*
(
SPC_ENABLEOUT1
-
SPC_ENABLEOUT0
),
1
)
# self.check_error("Checking error at enable_channel")
spcm_dwSetParam_i32
(
self
.
card
,
SPC_AMP0
+
c
*
(
SPC_AMP1
-
SPC_AMP0
),
amplitude
)
# print("Channels enabled: ", self.channel)
spcm_dwSetParam_i32
(
self
.
card
,
SPC_CH0_STOPLEVEL
+
c
*
(
SPC_CH1_STOPLEVEL
-
SPC_CH0_STOPLEVEL
),
stopmask
[
stoplvl
])
def
get_channel_count
(
self
)
->
int
:
if
not
self
.
is_connected
():
return
chcount
=
int32
(
0
)
spcm_dwGetParam_i32
(
self
.
card
,
SPC_CHCOUNT
,
byref
(
chcount
))
return
chcount
.
value
def
set_trigger
(
self
,
**
kwargs
):
def
set_trigger
(
self
,
**
kwargs
):
"""
"""
...
@@ -302,11 +309,12 @@ class AWG:
...
@@ -302,11 +309,12 @@ class AWG:
if
self
.
mode
!=
"
Sequence Replay
"
:
if
self
.
mode
!=
"
Sequence Replay
"
:
print
(
"
Wrong method, current mode is:
"
+
self
.
mode
)
print
(
"
Wrong method, current mode is:
"
+
self
.
mode
)
return
return
nch
=
np
.
sum
(
self
.
channel
)
# number of activated channels
chcount
=
int32
(
0
)
spcm_dwGetParam_i32
(
self
.
card
,
SPC_CHCOUNT
,
byref
(
chcount
))
# if data.dtype != int:
# if data.dtype != int:
# sys.stdout.write("data must be in int type\n")
# sys.stdout.write("data must be in int type\n")
# return
# return
if
data
.
size
>
self
.
mem_size
.
value
/
np
.
sum
(
self
.
channel
)
/
2
:
if
data
.
size
>
self
.
mem_size
.
value
/
chcount
.
value
/
2
:
sys
.
stdout
.
write
(
"
data is too big
"
)
sys
.
stdout
.
write
(
"
data is too big
"
)
return
return
spcm_dwSetParam_i32
(
self
.
card
,
SPC_SEQMODE_WRITESEGMENT
,
segment
)
# set current segment to write on
spcm_dwSetParam_i32
(
self
.
card
,
SPC_SEQMODE_WRITESEGMENT
,
segment
)
# set current segment to write on
...
@@ -314,13 +322,15 @@ class AWG:
...
@@ -314,13 +322,15 @@ class AWG:
# data transfer
# data transfer
sample_len
=
data
.
size
sample_len
=
data
.
size
buflength
=
uint32
(
sample_len
*
2
*
nch
)
# samples * (2 bytes/sample)
* number of activated channels
buflength
=
uint32
(
sample_len
*
2
)
# samples * (2 bytes/sample)
data_ptr
=
data
.
ctypes
.
data_as
(
ptr16
)
# cast data array into a c-like array
data_ptr
=
data
.
ctypes
.
data_as
(
ptr16
)
# cast data array into a c-like array
buffer
=
pvAllocMemPageAligned
(
sample_len
*
2
)
# buffer now holds a page-aligned location
buffer
=
pvAllocMemPageAligned
(
sample_len
*
2
)
# buffer now holds a page-aligned location
buffer_data
=
cast
(
addressof
(
buffer
),
ptr16
)
# cast it to int16 array
buffer_data
=
cast
(
addressof
(
buffer
),
ptr16
)
# cast it to int16 array
memmove
(
buffer_data
,
data_ptr
,
sample_len
*
2
)
# moving data into the page-aligned block
memmove
(
buffer_data
,
data_ptr
,
sample_len
*
2
)
# moving data into the page-aligned block
spcm_dwDefTransfer_i64
(
self
.
card
,
SPCM_BUF_DATA
,
SPCM_DIR_PCTOCARD
,
int32
(
0
),
byref
(
buffer
),
int64
(
0
),
int64
(
buflength
.
value
))
spcm_dwDefTransfer_i64
(
self
.
card
,
SPCM_BUF_DATA
,
SPCM_DIR_PCTOCARD
,
0
,
byref
(
buffer
),
0
,
buflength
)
# self.check_error("Checking error at write_segment")
spcm_dwSetParam_i32
(
self
.
card
,
SPC_M2CMD
,
M2CMD_DATA_STARTDMA
|
M2CMD_DATA_WAITDMA
)
spcm_dwSetParam_i32
(
self
.
card
,
SPC_M2CMD
,
M2CMD_DATA_STARTDMA
|
M2CMD_DATA_WAITDMA
)
spcm_dwSetParam_i32
(
self
.
card
,
SPC_M2CMD
,
M2CMD_DATA_STOPDMA
)
# self.check_error("Checking error at write_segment")
# self.check_error("Checking error at write_segment")
def
configure_step
(
self
,
step
:
int
,
segment
:
int
,
nextstep
:
int
,
loop
:
int
,
condition
:
int
):
def
configure_step
(
self
,
step
:
int
,
segment
:
int
,
nextstep
:
int
,
loop
:
int
,
condition
:
int
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment