Plot problem.. ?? No sign at all

R

Ritchy lelis

hello guys..

I'm new at python programming and i'm having some problems with a
script that i have been developing for my final project of my
graduation.

I have a script that is supposed to make a plot of a
"Residuo" (waveform) witch is an output of a ADC ( Analogic To Digital
Converter) for the first stage of the Flash pipiline ADC
structure.This script doesn't show any syntax errors but it doesn't
show no waveform at all at the plot window.

I'm worried about this situation so I came here looking for help since
I am new to the Python language.


-----------------------------------------------------------------------

from pylab import*

Vref = arange(1, 20, 0.02)
Vi = arange(1, 10,0.1)

for i in Vref:
for n in Vi:
if n > i/4:
V0 = 2*n-i
elif (-i/4) <= n and n <= i/4:
V0 = 2*n
elif Vi < -i/4:
V0 = 2*n+i
else:
print "Try Again"
##print V0
plot (V0)boboz10

--------------------------------------------------------------------------------
 
M

MRAB

Ritchy said:
hello guys..

I'm new at python programming and i'm having some problems with a
script that i have been developing for my final project of my
graduation.

I have a script that is supposed to make a plot of a
"Residuo" (waveform) witch is an output of a ADC ( Analogic To Digital
Converter) for the first stage of the Flash pipiline ADC
structure.This script doesn't show any syntax errors but it doesn't
show no waveform at all at the plot window.

I'm worried about this situation so I came here looking for help since
I am new to the Python language.


-----------------------------------------------------------------------

from pylab import*

Vref = arange(1, 20, 0.02)
Vi = arange(1, 10,0.1)

for i in Vref:
for n in Vi:
if n > i/4:
V0 = 2*n-i
elif (-i/4) <= n and n <= i/4:
V0 = 2*n
elif Vi < -i/4:
V0 = 2*n+i
else:
print "Try Again"
##print V0
plot (V0)boboz10
Only the first 2 'if' conditions are ever true, so nothing is ever
plotted.

Also, I don't know what you're trying to do here:

elif Vi < -i/4:

because Vi is an array and i is a float. If Python ever tried to execute
it there would be a ValueError exception:

ValueError: The truth value of an array with more than one element is
ambiguous.
Use a.any() or a.all()
 
R

Ritchy lelis

 1 - "import numpy as np
      import matplotlib.pyplot as plt"
      In what help's me making the call's of the libraries that way?
http://bytebaker.com/2008/07/30/python-namespaces/

 2 - What's the instruction linspace means/does?

 >>> help(np.linspace)
         Help on function linspace in module numpy.core.function_base:

         linspace(start, stop, num=50, endpoint=True, retstep=False)
             Return evenly spaced numbers over a specified interval.

             Returns `num` evenly spaced samples, calculated over the
             interval [`start`, `stop` ].
 3 - Last but more important: "V0 = ... #create an array" if I
 understood, there i'm supposed to introduce the for loop as in my
 initial example. correct?

It is better to create your arrays without looping,
if possible.  But create it however you wish.
(Note than numpy arrays have a fixed length;
create a Python list if you wish to append to it.)

Cheers,
Alan Isaac

-------------------------------------------------

My intention with de for loop was to iterate each point of the arrays
Vi and Vref at the math calculations. The V0 it's the result of the
math expressions between the Vi and Vref. I can't just create one V0
by a function set by parametters (i don't see how).

Could you give a clue?

Cheers

Ritchy
 
R

Ritchy lelis

Unfortunately I cannot make sense of the code you posted.
Provide a detailed description in words (or psuedocode)
of what you are trying to accomplish.  Be very careful
and detailed is you want a useful response.

Alan Isaac

hummm...

ok, i will try to make that detailed description. Maybe i have not
been so clear because my inglish suck's :D
However i have a tutorial and another document that my teacher gave
me, i could send you it if you allowed me. It's the 2 best document's
i've seen about ADC.

Ritchy
 
J

Johan Grönqvist

2010-07-06 19:18, Ritchy lelis skrev:
hummm...

ok, i will try to make that detailed description.

I can tell you why I do not understand from your posted code what you
are trying to do.

Firstly, I do not understand if you are trying to plot a surface, a set
of curves, or a curve, or just a set of points? In your posted code, the
plot command is part of the else clause, and my guess is that you never
intend the else-clause to be executed at all.

In your code snippet you loop over two arrays (Vi and Vref), compute a
scalar value V0, and all plot-commands you issue are of the form
plot(V0). This will probably draw a line of one point (for each value in
Vi and Vref), which may not be what you want, and if it draws anything
at all, then all points will be drawn at the same x-value, which is also
probably not what you want.

Secondly, how are the Vi and Vref related to your axes? I assume you
want to plot all values you compute for V0, but as a function of what?
When I use the plot command, I usually give it (at least) two arguments,
where the first is the x-axis, and the second is the y-axis.

After I have understood those things, the next question would be about
the maths relating the Vi and Vref values to the V0 values, but I do not
think I will understand those until after the above points are explained
clearer.

I definitely think your english is not a problem here.



Johan
 
R

Ritchy lelis

2010-07-06 19:18, Ritchy lelis skrev:


I can tell you why I do not understand from your posted code what you
are trying to do.

Firstly, I do not understand if you are trying to plot a surface, a set
of curves, or a curve, or just a set of points? In your posted code, the
plot command is part of the else clause, and my guess is that you never
intend the else-clause to be executed at all.

In your code snippet you loop over two arrays (Vi and Vref), compute a
scalar value V0, and all plot-commands you issue are of the form
plot(V0). This will probably draw a line of one point (for each value in
Vi and Vref), which may not be what you want, and if it draws anything
at all, then all points will be drawn at the same x-value, which is also
probably not what you want.

Secondly, how are the Vi and Vref related to your axes? I assume you
want to plot all values you compute for V0, but as a function of what?
When I use the plot command, I usually give it (at least) two arguments,
where the first is the x-axis, and the second is the y-axis.

After I have understood those things, the next question would be about
the maths relating the Vi and Vref values to the V0 values, but I do not
think I will understand those until after the above points are explained
clearer.

I definitely think your english is not a problem here.

Johan

hi Johan

Thanks for the interest in my problem... really appreciate.

About the plot draw it's a curve that it's a set of points wich it's
the result of the comput of the Vref and Vi together. I don't know if
i had to make a break instruction (like in other's languages) after
the "If" instructions if i want the else-condition to be executed? ...
(do you have some sujestions?)
Anyway i have a picture of a tuturial that i found but in this forum i
can't post it. That pic would show what a really want...

Relatively to the axis, the Vi takes the x-axis and the Vref takes the
y-axis.

As i said, i have a good 2 pic of a doc that has the information about
this ADC that i'm developing.

I would appreciate more of your help, if you permit me i could send
you those 2 pic and i guarantee that you would got the certain vision
of the problem.

I'll be waiting for your answer, i thing that you can help me.

Cheers.

Ritchy Lelis
 
J

Johan Grönqvist

2010-07-11 02:12, Ritchy lelis skrev:
About the plot draw it's a curve that it's a set of points wich it's
the result of the comput of the Vref and Vi together. I don't know if
i had to make a break instruction (like in other's languages) after
the "If" instructions if i want the else-condition to be executed? ...
(do you have some sujestions?)

I would have expected a code structure similar to this:

(NOTE: This is a very inefficient solution, and not the one suggested
earlier, but it is closer to the code snippet you posted originally, and
it does produce a plot.)

----------------------
import numpy as np
import matplotlib.pyplot as plt
Vref = np.linspace(1,20, 100)
Vi = np.linspace(1,10,100)

for ref in Vref: # Loop over Vref and Vi
for i in Vi:
if i > ref/4: # Compute V0
V0 = 2*i-ref
elif (-ref/4) <= ref and ref <= ref/4:
V0 = 2*i
elif i < -ref/4:
V0 = 2*i+ref
plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
plt.show() # Display the plot in a window
----------------------

Anyway i have a picture of a tuturial that i found but in this forum i
can't post it. That pic would show what a really want...

Can you give a link?
Relatively to the axis, the Vi takes the x-axis and the Vref takes the
y-axis.


To me this sound like you want to make a 3D-plot, as there is the
x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?
As i said, i have a good 2 pic of a doc that has the information about
this ADC that i'm developing.

I looked on wikipedia
<http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
figures. Is any of those similar to what you look for?

I see that they have (Vi - Vref) on the x-axis, and the computed value
on the y-axis.

Regards

Johan
 
R

Ritchy lelis

2010-07-11 02:12, Ritchy lelis skrev:



I would have expected a code structure similar to this:

(NOTE: This is a very inefficient solution, and not the one suggested
earlier, but it is closer to the code snippet you posted originally, and
it does produce a plot.)

----------------------
import numpy as np
import matplotlib.pyplot as plt
Vref = np.linspace(1,20, 100)
Vi = np.linspace(1,10,100)

for ref in Vref: # Loop over Vref and Vi
     for i in Vi:
         if  i > ref/4: # Compute V0
             V0 = 2*i-ref
         elif (-ref/4) <= ref and ref <= ref/4:
             V0 = 2*i
         elif i < -ref/4:
             V0 = 2*i+ref
         plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
plt.show() # Display the plot in a window
----------------------


Can you give a link?




To me this sound like you want to make a 3D-plot, as there is the
x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?




I looked on wikipedia
<http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
figures. Is any of those similar to what you look for?

I see that they have (Vi - Vref) on the x-axis, and the computed value
on the y-axis.

Regards

Johan

Hi

Yes those fig look's familiar to me but for now the objective its to
get that residue transfer function (1.5-Bit-Per-Stage Pipelined ADC).

I found in http://amesp02.tamu.edu/~sanchez/ADC-pipeline_lecture.PDF
there are some fig and explanations on page's 9-13. Can you take a
look there please?

Also you can take a look in http://www.maxim-ic.com/app-notes/index.mvp/id/1023
(I think there it´s more information than the first link i gave you).

I'll be waiting for sujestions.

Thank's
 
R

Ritchy lelis

Hi

Yes those fig look's familiar to me but for now the objective its to
get that residue transfer function (1.5-Bit-Per-Stage Pipelined ADC).

I found inhttp://amesp02.tamu.edu/~sanchez/ADC-pipeline_lecture.PDF
there are some fig and explanations on page's 9-13. Can you take a
look there please?

Also you can take a look inhttp://www.maxim-ic.com/app-notes/index.mvp/id/1023
(I think there it´s more information than the first link i gave you).

I'll be waiting for sujestions.

Thank's- Ocultar texto citado -

- Mostrar texto citado -

hi

This is how looks like the flash residue transference function that i
was talking about...

http://www.iadc.ca/Imran_ADC_tutorial_files/image048.gif

I'm suposed to obtain a figure like that in my plot.

Somebody help me please.

Cheers
 
R

Ritchy lelis

Hi

Yes those fig look's familiar to me but for now the objective its to
get that residue transfer function (1.5-Bit-Per-Stage Pipelined ADC).

I found inhttp://amesp02.tamu.edu/~sanchez/ADC-pipeline_lecture.PDF
there are some fig and explanations on page's 9-13. Can you take a
look there please?

Also you can take a look inhttp://www.maxim-ic.com/app-notes/index.mvp/id/1023
(I think there it´s more information than the first link i gave you).

I'll be waiting for sujestions.

Thank's- Ocultar texto citado -

- Mostrar texto citado -

hi

This is how looks like the flash residue transference function that i
was talking about...

http://www.iadc.ca/Imran_ADC_tutorial_files/image048.gif

I'm suposed to obtain a figure like that in my plot.

Somebody help me please.

Cheers
 
R

Ritchy lelis

2010-07-11 02:12, Ritchy lelis skrev:



I would have expected a code structure similar to this:

(NOTE: This is a very inefficient solution, and not the one suggested
earlier, but it is closer to the code snippet you posted originally, and
it does produce a plot.)

----------------------
import numpy as np
import matplotlib.pyplot as plt
Vref = np.linspace(1,20, 100)
Vi = np.linspace(1,10,100)

for ref in Vref: # Loop over Vref and Vi
     for i in Vi:
         if  i > ref/4: # Compute V0
             V0 = 2*i-ref
         elif (-ref/4) <= ref and ref <= ref/4:
             V0 = 2*i
         elif i < -ref/4:
             V0 = 2*i+ref
         plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
plt.show() # Display the plot in a window
----------------------


Can you give a link?




To me this sound like you want to make a 3D-plot, as there is the
x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?




I looked on wikipedia
<http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
figures. Is any of those similar to what you look for?

I see that they have (Vi - Vref) on the x-axis, and the computed value
on the y-axis.

Regards

Johan

hi

This is how looks like the flash residue transference function that i
was talking about...

http://www.iadc.ca/Imran_ADC_tutorial_files/image048.gif

I'm suposed to obtain a figure like that in my plot.

Somebody help me please.

Cheers
 
J

Johan Grönqvist

Hi Ritchy,

This is the first time I am doing this, but it's a standard response
given on lists like this.

2010-07-13 18:17, Ritchy lelis skrev:
This is how looks like the flash residue transference function that i
was talking about...

http://www.iadc.ca/Imran_ADC_tutorial_files/image048.gif

I'm suposed to obtain a figure like that in my plot.

From the hints you have been given, and your answers to those hints, my
conclusion is that the issue is not with the programming, but with your
understanding of the problem.

I get the feeling you do not understand what you are trying to do, and
therefore our programming hints do not help you.

Based on the "we will not do your homework"-principle, I will therefore
not read up on your theory, and therefore not produce your plot for you.
That will not change until you show better understanding for the plot
you are trying to generate.

Regards

Johan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top