Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
ADC Testing
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
ADC Testing
Commits
f6bab201
Commit
f6bab201
authored
Sep 01, 2011
by
Federico Asara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various bugfixes.
parent
4f1aeb02
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
5 deletions
+76
-5
Agilent33250A.py
PAGE/Agilent33250A.py
+11
-2
Generator.py
PAGE/Generator.py
+3
-1
SineWaveform.py
PAGE/SineWaveform.py
+13
-0
TTWaveform.py
PAGE/TTWaveform.py
+42
-0
Waveform.py
PAGE/Waveform.py
+7
-2
No files found.
PAGE/Agilent33250A.py
View file @
f6bab201
...
@@ -79,6 +79,7 @@ class Agilent33250A(Generator):
...
@@ -79,6 +79,7 @@ class Agilent33250A(Generator):
def
command
(
self
,
what
):
def
command
(
self
,
what
):
'''Send a (list of) command(s) to the device: a command is a string, and
'''Send a (list of) command(s) to the device: a command is a string, and
this function appends automatically a new line.'''
this function appends automatically a new line.'''
print
what
if
len
(
what
)
==
0
:
if
len
(
what
)
==
0
:
return
return
...
@@ -129,21 +130,29 @@ class Agilent33250A(Generator):
...
@@ -129,21 +130,29 @@ class Agilent33250A(Generator):
if
type
(
f
)
in
(
tuple
,
list
):
if
type
(
f
)
in
(
tuple
,
list
):
if
len
(
f
)
==
2
:
if
len
(
f
)
==
2
:
f
,
n
=
f
f
,
n
=
f
if
n
[
0
]
!=
':'
:
n
=
":"
+
n
else
:
else
:
return
return
else
:
n
=
''
if
type
(
f
)
!=
str
:
if
type
(
f
)
!=
str
:
return
return
f
=
f
.
upper
()
f
=
f
.
upper
()
if
' '
in
f
:
if
' '
in
f
:
f
,
n
=
f
.
split
(
' '
)
f
,
n
=
f
.
split
(
' '
)
else
:
if
n
[
0
]
!=
':'
:
n
=
":"
+
n
elif
':'
not
in
n
:
n
=
''
n
=
''
if
f
not
in
self
.
functionList
:
if
f
not
in
self
.
functionList
:
return
return
self
.
command
(
"FUNC
%
s
%
s"
%
(
f
,
n
))
self
.
command
(
"FUNC
%
s
%
s"
%
(
f
,
n
))
return
locals
()
return
locals
()
...
...
PAGE/Generator.py
View file @
f6bab201
...
@@ -15,7 +15,9 @@ class Generator(Item):
...
@@ -15,7 +15,9 @@ class Generator(Item):
# this dictionary is used to map data types into function which can
# this dictionary is used to map data types into function which can
# translate such type of data into something the generator can understand.
# translate such type of data into something the generator can understand.
adaptDict
=
{}
adaptDict
=
{}
def
play
(
self
,
wave
):
return
def
adaptKeys
(
self
):
def
adaptKeys
(
self
):
"""Returns all data types supported."""
"""Returns all data types supported."""
return
self
.
adaptDict
.
keys
()
return
self
.
adaptDict
.
keys
()
...
...
PAGE/SineWaveform.py
View file @
f6bab201
...
@@ -31,6 +31,19 @@ class SineWaveform(Waveform.Waveform):
...
@@ -31,6 +31,19 @@ class SineWaveform(Waveform.Waveform):
return
(
s
/
lsb
)
.
astype
(
int
)
return
(
s
/
lsb
)
.
astype
(
int
)
def
generatePeriod
(
self
,
nbits
,
samples
,
fsr
):
f
=
self
.
frequency
A
=
self
.
amplitude
C
=
self
.
dc
t
=
arange
(
samples
,
dtype
=
float
)
/
samples
s
=
A
*
sin
(
2
*
pi
*
t
)
+
C
lsb
=
fsr
/
(
2
**
nbits
)
return
(
s
/
lsb
)
.
astype
(
int
),
f
def
scale
(
self
,
factor
):
def
scale
(
self
,
factor
):
"""Multiply the frequency by factor."""
"""Multiply the frequency by factor."""
self
.
frequency
*=
factor
self
.
frequency
*=
factor
...
...
PAGE/TTWaveform.py
View file @
f6bab201
...
@@ -6,7 +6,32 @@ import Pyro4
...
@@ -6,7 +6,32 @@ import Pyro4
import
Pyro4.util
import
Pyro4.util
import
sys
import
sys
import
commands
import
commands
def
gcd
(
a
,
b
):
"""Return greatest common divisor using Euclid's Algorithm."""
while
b
:
a
,
b
=
b
,
a
%
b
return
a
def
lcm
(
a
,
b
):
"""Return lowest common multiple."""
return
a
*
b
//
gcd
(
a
,
b
)
def
frac
(
x
,
n
):
AA
=
0
BB
=
1
A
=
1
B
=
0
for
i
in
range
(
n
):
a
=
int
(
math
.
floor
(
x
))
try
:
x
=
1
/
(
x
-
a
)
AA
,
A
=
A
,
AA
+
a
*
A
BB
,
B
=
B
,
BB
+
a
*
B
except
:
return
yield
(
x
,
a
,
A
,
B
,)
class
TTWaveform
(
Waveform
.
Waveform
):
class
TTWaveform
(
Waveform
.
Waveform
):
def
get
(
self
,
what
):
def
get
(
self
,
what
):
return
self
.
__getattribute__
(
what
)
return
self
.
__getattribute__
(
what
)
...
@@ -34,6 +59,23 @@ class TTWaveform(Waveform.Waveform):
...
@@ -34,6 +59,23 @@ class TTWaveform(Waveform.Waveform):
return
(
s
/
lsb
)
.
astype
(
int
)
return
(
s
/
lsb
)
.
astype
(
int
)
def
generatePeriod
(
self
,
nbits
,
samples
,
fsr
):
A
=
self
.
amplitude
C
=
self
.
dc
# r1, r2 = list(frac(self.ratio, 7))[-1][2:]
# print r1, r2
#print 'Samples:', samples*self.ratio*r2
freq
=
2.
/
(
self
.
ratio
-
1.
)
t
=
arange
(
samples
*
freq
,
dtype
=
float
)
/
samples
s
=
A
*
sin
(
2
*
pi
*
t
)
+
A
*
sin
(
2
*
pi
*
self
.
ratio
*
t
)
+
C
lsb
=
fsr
/
(
2
**
nbits
)
return
(
s
/
lsb
)
.
astype
(
int
),
self
.
frequency
/
freq
def
scale
(
self
,
factor
):
def
scale
(
self
,
factor
):
"""Multiply the frequency by factor"""
"""Multiply the frequency by factor"""
self
.
frequency
*=
factor
self
.
frequency
*=
factor
...
...
PAGE/Waveform.py
View file @
f6bab201
...
@@ -11,9 +11,14 @@ class Waveform(Item):
...
@@ -11,9 +11,14 @@ class Waveform(Item):
"""Set an attribute value. Supports Pyro4."""
"""Set an attribute value. Supports Pyro4."""
self
.
__setattr__
(
what
,
how
)
self
.
__setattr__
(
what
,
how
)
"""A waveform must provide this method.
Create a numeric array which represents the wave."""
def
generate
(
self
,
nbits
,
frequency
,
samples
,
fsr
):
def
generate
(
self
,
nbits
,
frequency
,
samples
,
fsr
):
"""A waveform must provide this method.
Create a numeric array which represents the wave."""
return
array
([])
def
generatePeriod
(
self
,
nbits
,
samples
,
fsr
):
"""A waveform must provide this method.
Create a numeric array which represents a period of the wave."""
return
array
([])
return
array
([])
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment