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
Show 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):
def
command
(
self
,
what
):
'''Send a (list of) command(s) to the device: a command is a string, and
this function appends automatically a new line.'''
print
what
if
len
(
what
)
==
0
:
return
...
...
@@ -129,21 +130,29 @@ class Agilent33250A(Generator):
if
type
(
f
)
in
(
tuple
,
list
):
if
len
(
f
)
==
2
:
f
,
n
=
f
if
n
[
0
]
!=
':'
:
n
=
":"
+
n
else
:
return
else
:
n
=
''
if
type
(
f
)
!=
str
:
return
f
=
f
.
upper
()
if
' '
in
f
:
f
,
n
=
f
.
split
(
' '
)
else
:
if
n
[
0
]
!=
':'
:
n
=
":"
+
n
elif
':'
not
in
n
:
n
=
''
if
f
not
in
self
.
functionList
:
return
self
.
command
(
"FUNC
%
s
%
s"
%
(
f
,
n
))
self
.
command
(
"FUNC
%
s
%
s"
%
(
f
,
n
))
return
locals
()
...
...
PAGE/Generator.py
View file @
f6bab201
...
...
@@ -15,6 +15,8 @@ class Generator(Item):
# this dictionary is used to map data types into function which can
# translate such type of data into something the generator can understand.
adaptDict
=
{}
def
play
(
self
,
wave
):
return
def
adaptKeys
(
self
):
"""Returns all data types supported."""
...
...
PAGE/SineWaveform.py
View file @
f6bab201
...
...
@@ -31,6 +31,19 @@ class SineWaveform(Waveform.Waveform):
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
):
"""Multiply the frequency by factor."""
self
.
frequency
*=
factor
...
...
PAGE/TTWaveform.py
View file @
f6bab201
...
...
@@ -6,6 +6,31 @@ import Pyro4
import
Pyro4.util
import
sys
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
):
def
get
(
self
,
what
):
...
...
@@ -34,6 +59,23 @@ class TTWaveform(Waveform.Waveform):
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
):
"""Multiply the frequency by factor"""
self
.
frequency
*=
factor
...
...
PAGE/Waveform.py
View file @
f6bab201
...
...
@@ -11,9 +11,14 @@ class Waveform(Item):
"""Set an attribute value. Supports Pyro4."""
self
.
__setattr__
(
what
,
how
)
def
generate
(
self
,
nbits
,
frequency
,
samples
,
fsr
):
"""A waveform must provide this method.
Create a numeric array which represents the wave."""
def
generate
(
self
,
nbits
,
frequency
,
samples
,
fsr
):
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
([])
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