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
eaec8eef
Commit
eaec8eef
authored
Aug 19, 2011
by
Federico Asara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generic module describes generic waves and generator .
parent
9f4558a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
44 deletions
+70
-44
Generator.py
Pain/Generator.py
+0
-44
SineWaveform.py
Pain/Generic/SineWaveform.py
+70
-0
No files found.
Pain/Generator.py
deleted
100644 → 0
View file @
9f4558a2
import
serial
import
time
def
Property
(
func
):
return
property
(
**
func
())
"""This class should manage the Agilent 33250A waveform generator"""
class
Generator
(
serial
.
Serial
):
def
__init__
(
self
,
device
=
"/dev/ttyUSB0"
,
bauds
=
57600
,
to
=
2
,
interCharTimeout
=
1
):
serial
.
Serial
.
__init__
(
self
,
device
,
bauds
,
timeout
=
to
,
interCharTimeout
=
1
)
def
command
(
self
,
what
):
return
self
.
write
(
"
%
s
\n
"
%
what
)
@
Property
def
output
():
doc
=
"The person's name"
def
fget
(
self
):
self
.
command
(
"OUTP?"
)
output
=
self
.
read
(
2
)[
0
]
return
output
==
"1"
def
fset
(
self
,
status
):
if
type
(
status
)
is
not
bool
:
return
self
.
command
(
"OUTP
%
d"
%
(
1
if
status
else
0
))
return
locals
()
def
sine
(
self
,
frequency
,
amplitude
,
dc
=
0
,
freqm
=
'HZ'
,
ampm
=
'VPP'
,
dcm
=
'V'
):
self
.
command
(
"APPL:SIN
%.2
f
%
s,
%.2
f
%
s,
%.2
f
%
s"
%
(
frequency
,
freqm
,
amplitude
,
ampm
,
dc
,
dcm
))
def
sweep
(
self
,
interval
,
frequencies
,
amplitude
,
dc
=
0
,
freqm
=
'HZ'
,
ampm
=
'VPP'
,
dcm
=
'V'
,
callback
=
None
):
for
f
in
frequencies
:
self
.
sine
(
f
,
amplitude
,
dc
,
freqm
,
ampm
,
dcm
)
time
.
sleep
(
interval
)
if
callback
is
not
None
:
callback
(
f
)
Pain/Generic/SineWaveform.py
0 → 100644
View file @
eaec8eef
import
Waveform
def
Property
(
func
):
return
property
(
**
func
())
def
parse
(
value
,
s
):
if
type
(
value
)
is
str
:
value
=
value
.
split
(
" "
)
value
[
0
]
=
float
(
value
[
0
])
value
=
tuple
(
value
)
if
type
(
value
)
is
tuple
and
len
(
value
)
==
1
:
value
=
value
[
0
]
if
type
(
value
)
is
not
tuple
:
return
(
value
,
s
)
else
:
return
value
class
SineWaveform
(
Waveform
.
Waveform
):
def
apply
(
self
):
return
""
_freq
=
(
1
,
'KHZ'
);
_amp
=
(
0.1
,
'VPP'
);
_dc
=
(
0
,
'V'
);
@
Property
def
frequency
():
doc
=
"Frequency of the sinewave"
def
fget
(
self
):
return
self
.
_freq
def
fset
(
self
,
value
):
self
.
_freq
=
parse
(
value
,
'HZ'
)
def
fdel
(
self
):
del
self
.
_freq
return
locals
()
@
Property
def
amplitude
():
doc
=
"Amplitude of the sinewave"
def
fget
(
self
):
return
self
.
_amp
def
fset
(
self
,
value
):
self
.
_amp
=
parse
(
value
,
'HZ'
)
def
fdel
(
self
):
del
self
.
_amp
return
locals
()
@
Property
def
dc
():
doc
=
"Amplitude of the sinewave"
def
fget
(
self
):
return
self
.
_dc
def
fset
(
self
,
value
):
self
.
_dc
=
parse
(
value
,
'HZ'
)
def
fdel
(
self
):
del
self
.
_dc
return
locals
()
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