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
3269c97e
Commit
3269c97e
authored
Jan 30, 2011
by
Juan David Gonzalez Cobas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an ideal ADC transfer function to generate data sets
parent
95d851b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
ideal.py
ideal.py
+40
-0
No files found.
ideal.py
0 → 100644
View file @
3269c97e
#! /bin/sh
# coding: utf-8
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
def
ideal_adc
(
vals
,
N
,
Vmin
,
Vmax
,
mid_tread
=
False
):
"""computes an ideal ADC characteristic function
vals is a vector of values to be converted by an
ideal ADC whose characteristic is defined by the Vmin and Vmax full
scale range, and the N number of bits. The optional mid_tread
parameter allow to use the mid_tread convention as per
IEEE 1241 sec. 1.2.
A vector of converted vals object is returned, taking into account
saturation at both ends of scale
"""
FS
=
float
(
Vmax
-
Vmin
)
lsb
=
FS
/
2
**
N
if
mid_tread
:
vals
=
vals
+
lsb
/
2
t
=
(
vals
-
Vmin
)
/
lsb
print
vals
,
t
code
=
array
(
t
,
dtype
=
int
)
code
[
code
<
0
]
=
0
code
[
code
>
(
2
**
N
-
1
)]
=
2
**
N
-
1
return
code
if
__name__
==
'__main__'
:
from
numpy
import
*
from
matplotlib
import
pyplot
as
pl
v
=
linspace
(
-
1.0
,
11
,
3000
)
print
v
my_adc
=
ideal_adc
(
v
,
4
,
0
,
10.0
,
mid_tread
=
1
)
pl
.
plot
(
v
,
my_adc
)
pl
.
show
()
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