Plot problem.. ?? No sign at all

2010-07-05 Thread 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



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-06 Thread Ritchy lelis
On 6 jul, 16:18, Alan G Isaac  wrote:
> On 7/6/2010 8:05 AM, Ritchy lelis wrote:
>
> >  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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-06 Thread Ritchy lelis
On 6 jul, 17:29, Alan G Isaac  wrote:
> On 7/6/2010 12:11 PM, Ritchy lelis wrote:
>
> > 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).
>
> 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

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-10 Thread Ritchy lelis
On 7 jul, 08:38, Johan Grönqvist  wrote:
> 2010-07-06 19:18, Ritchy lelis skrev:
>
> > On 6 jul, 17:29, Alan G Isaac  wrote:
> >> 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.
>
> 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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-11 Thread Ritchy lelis
On 11 jul, 13:28, Johan Grönqvist  wrote:
> 2010-07-11 02:12, Ritchy lelis skrev:
>
> > On 7 jul, 08:38, Johan Grönqvist  wrote:
>
> > 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

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

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-13 Thread Ritchy lelis
On 11 Jul, 17:39, Ritchy lelis  wrote:
> On 11 jul, 13:28, Johan Grönqvist  wrote:
>
>
>
>
>
> > 2010-07-11 02:12, Ritchy lelis skrev:
>
> > > On 7 jul, 08:38, Johan Grönqvist  wrote:
>
> > > 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
>
> 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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-13 Thread Ritchy lelis
On 11 Jul, 17:39, Ritchy lelis  wrote:
> On 11 jul, 13:28, Johan Grönqvist  wrote:
>
>
>
>
>
> > 2010-07-11 02:12, Ritchy lelis skrev:
>
> > > On 7 jul, 08:38, Johan Grönqvist  wrote:
>
> > > 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
>
> 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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-13 Thread Ritchy lelis
On 11 Jul, 13:28, Johan Grönqvist  wrote:
> 2010-07-11 02:12, Ritchy lelis skrev:
>
> > On 7 jul, 08:38, Johan Grönqvist  wrote:
>
> > 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

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
-- 
http://mail.python.org/mailman/listinfo/python-list


Some success with the "Plot" problem :D

2010-07-14 Thread Ritchy lelis
Hello guys

On Following the development of my ADC (Analog-to-Digital converter
Residue function transference) i already got some progress with the
plot problem and (much thanks to colleagues who help me in this forum
and not only) i would like to show you all the progress that has
already got and take the opportunity to leave some doubt:

-
import numpy
import matplotlib.pylab as plt

Vref = numpy.arange(-20, 20, 0.2)
Vi = numpy.arange(-10, 10, 0.1)
V0 = numpy.arange(Vi.shape[0])
i = 0

while i < Vi.shape[0]:
if Vi[i] > Vref[i]/4:
V0[i] = 2*Vi[i]-Vref[i]
elif (-Vref[i]/4)<= Vi[i] and Vi[i] <= Vref[i]/4:
V0[i] = 2*Vi[i]
elif Vi[i] < -Vref[i]/4:
V0[i] = 2*Vi[i] + Vref[i]
i = i + 1

plt.plot(V0)  # this plot will make that seems stairs rising
plt.show()

-

For now i have a draw that seems cool to initialize the second part of
my objectives but anyway i would like to request some help because I'm
not getting on the waveform to start at origin of the coordinate axes.

I'm looking for a better way to create those initial vectors (Vi,
Vref, V0), any sujestions? Forword i want them to be implemented as a
function that in the start of the program, i ask the user the
dimention of the arrays that they want to use.

Also if you have any sujestions to improve the script you can drope it
here, is always welcome.

For who want's to help but don´t have much information about what i'm
doing here it's a link that is pretty cool:

http://www.eit.lth.se/fileadmin/eit/courses/eti220/files/lectures/2009/lec4.pdf

I'll be waiting.

Cheers.

Ritchy.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to implement a pipeline...??? Please help

2010-08-06 Thread Ritchy lelis
Hi guys

In the development of my ADC project i have a new new challenge.

First i need to implement a 10 Bit pipelineADC  that  will be the
basis to later implement any kind of pipeline arquitecture (i mean,
with 10 Bit, 16 Bit or any other configuration i want) i wish to...

What's a 10 Bit pipiline ADC?

This link with a draw will help have a perfect view of what is it:
 
http://t3.gstatic.com/images?q=tbn:ANd9GcQK_Pwz3ssk1yoDDFwGjJ5FWAwcqr1mV9EwdndlHCEvOMdTOa4&t=1&usg=__-TsH7dnNdJm4GZTuWCxjvajZhfk=

To have a 10 Bit pipiline ADC we need 9 stages, where 8 of them are a
1.5 bit configuration and the last one have a 2 Bit configuration.

How it works?

When we inject a input voltage (at the first block), it will be
computed in the first 1.5 Bit stage and when finished the compute it
will generate a output voltage who served of input voltage for the
second 1.5 Bit stage which in his turn generate also a output voltage
who served of input voltage in the third stage ... and successively
continuing until the ninth stage. The ninth stage it's a 2 Bit stage
and it will receive the last output voltage from the eighth stage and
in his turn it will compute a final output signal.

I already implemented the 1.5 Bit/stage and the 2 Bit/stage functions
with good results (i already watch their plot's and they are cool to
me) but my Pipeline function try don't seems that good.

After the 2 Bit compute i expect a output signal like the drawing on
the link below but more stretched.
http://t3.gstatic.com/images?q=tbn:ANd9GcQGQYDW0iLCSXfMMurIksWsgklsvtj26IBtQRacFtY7ifu9RQA&t=1&usg=__-yHJFMatnCPcf9jWQv3kaxM0brE=

Instead of have a lot of steps one after the another, it will have
something like a single step only. Why? That it's because when we have
a pipeline with a lot of stage's the final output voltage until the 2
Bit stage it's very "dense" and long and that nearly saturating the
last block ( the 2 Bit stage).

Next i will leave the code that I have done so far for my Pipeline
function:

---
---

from flash1b5 import flash1b5
from flash1b5 import *
from flash2b import flash2b
from flash2b import *
import matplotlib.pyplot as plt
import numpy as np
from pylab import *

if __name__ == "__main__":

Inc = raw_input("Valor do Incrimento = ")

Vref = np.linspace(1,1, Inc)
Vi = np.linspace(-1,1, Inc)

Cs = np.linspace(3e-12, 3e-12, Inc)
Cf = np.linspace(3e-12, 3e-12, Inc)

f1 = flash1b5(Vi, Vref, Cs, Cf)

Vin1 = f1[0]
Vt1 = f1[1]
Vd1 = f1[2]


f2b = flash2b(Vt1, Vref)

Vin2 = f2b[0]
Vd2 = f2b[1]


hold(True)

fig2 = figure(1,figsize=(8,5))
ax2 = fig2.add_subplot(111, autoscale_on=False, xlim=(-1,1),
ylim=(-0.5,2.5))
ax2.plot(Vin2, Vd2, lw=2, color='blue')
grid (True); xlabel('V_ent');ylabel('Vout_Digital')


plt.show()
---

The 1.5 Bit function:

import numpy as np
from pylab import *


def flash1b5(Vi, Vref, Cs, Cf):

Vin = np.zeros(Vi.shape, dtype=np.float)
Vt = np.zeros(Vi.shape, dtype=np.float)
Vd = np.zeros(Vi.shape, dtype=np.float)

if any(Vi > Vref/4):
mask1 = (Vi > Vref/4)
np.putmask(Vin, mask1, Vi)
Vs= (1+Cs/Cf)*Vin - (Cs/Cf)*Vref
np.putmask(Vd, mask1, [2])
np.putmask(Vt, mask1, Vs)

##
if any(-Vref/4 <= Vi) and any( Vi<= Vref/4):
mask2 = (-Vref/4 <= Vi) & (Vi <= Vref/4)
np.putmask(Vin, mask2, Vi)
Vs = (1+(Cs/Cf))*Vin
np.putmask(Vd, mask2, [1])
np.putmask(Vt, mask2, Vs)

##
if any(Vi < -Vref/4):
mask3 = (Vi < -Vref/4)
np.putmask(Vin, mask3, Vi)
Vs= (1+Cs/Cf)*Vin + (Cs/Cf)*Vref
np.putmask(Vd, mask3, [0])
np.putmask(Vt, mask3, Vs)

##
out = [Vin, Vt, Vd]
return out
---

The 2 Bit function:

import numpy as np
from pylab import *


def flash2b(Vi, Vref):

Vin = np.zeros(Vi.shape, dtype=np.float)
Vt = np.zeros(Vi.shape, dtype=np.float)
Vd = np.zeros(Vi.shape, dtype=np.float)

if any(Vi > Vref/2):
mask1 = (Vi > Vref/2)
np.putmask(Vin, mask1, Vi)
np.putmask(Vd, mask1, [3])

if any(Vi > 0) and any(Vref/2 >= Vi):
mask2 = (Vref/2 >= Vi) & (Vi > 0)
np.putmask(Vin, mask2, Vi)
np.putmask(Vd, mask2, [2])

if any(Vi <= 0) and any(-Vref/2 < Vi):
mask3 = (-Vref/2 < Vi) & (Vi <= 0)
np.putmask(Vin, mask

Re: How to implement a pipeline...??? Please help

2010-08-10 Thread Ritchy lelis
On 7 Ago, 07:30, Dennis Lee Bieber  wrote:
> On Fri, 6 Aug 2010 16:47:58 -0700 (PDT), Ritchy lelis
>  declaimed the following in
> gmane.comp.python.general:
>
> > Guys i'm asking if it's possible for a generic function for a
> > pipeline, all the suggestions ideas are welcome.
>
>         I've not done metaclasses, so don't know if a metaclass would be of
> use... Since it appears one would have to have something that generates
> functions on the fly based upon inputs...
>
>         I look at details on what you are trying to create and see a
> series-parallel circuit architecture with clocked stages and delay lines
> for the summing of the outputs. That is, when the clock ticks, every
> stage in the unit does its processing and provides and output... On the
> next tick, those outputs become inputs to the subsequent stage and the
> process repeats
>
> > Also if you have a specific solution for my problem I will be grateful
> > for it here.
>
>         I'm still blinking at the thought of doing analog to digital
> conversion in Python! I sure wouldn't hold out much hope of real-time
> signal processing. There is a reason ADC and DAC are done in hardware,
> even if the intermediate processing is with general purpose processors.
>
>         I'm also not sure I understand the
>
> np.linspace(1,1, Inc)...
>
>         Looking up documentation implies you are trying to create a vector
> of "inc" length, evenly populated by values between 1 and 1... which
> means a vector of all 1s... Might it not be faster to just
>
>         v = [1] * inc
>
> and pass v to some numpy method for conversion from Python list to numpy
> vector?
>
> (the -1 to 1 at least makes sense)
>
>         Me? I'd probably create a class in which the __init__() takes a
> value specifying the number of stages. It would than create suitable
> lists to track values, some sort of counter (c), a Semaphore (s)
> [initialized at 0 -- ie, already acquired/block],  a thread for EACH
> stage, and an Event (e) object
>
>         Each stage thread, initialized with its position in the pipeline.
> The threads perform an e.wait() call. They also, after the wait is
> released, perform an e.clear() call. As their processing, they each grab
> from the pipeline "input" list the current value for their position.
> After processing they update their position in the "output" list(s),
> they decrement the counter c (maybe put a lock around access to c). The
> thread that decrements c to 0 is responsible for "releasing" the
> semaphore.
>
>         The main code of the class instance is responsible for a loop that
> does: set up the "input" list based on current value of stage outputs,
> initialize c to the count of stages (minus 1?), e.set() to signal all
> stage threads to process the current conditions, s.acquire() to block
> until the last processed thread (by c hitting 0) does s.release(). It
> then collects the output lists, does whatever shifting is needed to
> prepare for the next cycle...
>
>         Actually, that "loop" may not be a loop so much as a method off the
> class like
>
>         digitalOutput = adcInstance.step(analogInput)
>
> which is, itself, in a loop.
>
> That is, something like...
>
> myADC = ADC(stages=10)
> while True:
>         voltage = getNextAnalogInput()
>         digital = myADC.step(voltage)
>         outputDigitalValue()
>
>         Obviously I've not taken the time to actually lay out all the
> instance lists needed for inputs and outputs, nor the code of threads
> (while one can create the first "stages-1" threads with a loop, the
> final stage needs a discrete creation)
>
>         When one finds that the threading solution is really slow (though
> understandable in terms of the hardware circuit -- one thread per stage
> makes the stages easy to code), THEN one might try to figure out how to
> implement an iterative version... I suspect using numpy would be the
> third optimization -- removing iteration by using parallel vector
> operations.
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/


Hi

First of all i would like to thank you for your time and help.

I appreciate your suggestions and they seems very good to me... The
only problem it's that i'm newbie at python programming, but still
interested to learn more and more...

I already got a solution through harsh but it worked. at least I got
the wave form i wanted.

Next i'm going to let you'll my solution here. It's rudimentary but it
work's.

Seem

Re: How to implement a pipeline...??? Please help

2010-08-24 Thread Ritchy lelis
On 11 Ago, 01:01, Ritchy lelis  wrote:
> On 7 Ago, 07:30, Dennis Lee Bieber  wrote:
>
>
>
>
>
> > On Fri, 6 Aug 2010 16:47:58 -0700 (PDT), Ritchy lelis
> >  declaimed the following in
> > gmane.comp.python.general:
>
> > > Guys i'm asking if it's possible for a generic function for a
> > >pipeline, all the suggestions ideas are welcome.
>
> >         I've not done metaclasses, so don't know if a metaclass would be of
> > use... Since it appears one would have to have something that generates
> > functions on the fly based upon inputs...
>
> >         I look at details on what you are trying to create and see a
> > series-parallel circuit architecture with clocked stages and delay lines
> > for the summing of the outputs. That is, when the clock ticks, every
> > stage in the unit does its processing and provides and output... On the
> > next tick, those outputs become inputs to the subsequent stage and the
> > process repeats
>
> > > Also if you have a specific solution for my problem I will be grateful
> > > for it here.
>
> >         I'm still blinking at the thought of doing analog to digital
> > conversion in Python! I sure wouldn't hold out much hope of real-time
> > signal processing. There is a reason ADC and DAC are done in hardware,
> > even if the intermediate processing is with general purpose processors.
>
> >         I'm also not sure I understand the
>
> > np.linspace(1,1, Inc)...
>
> >         Looking up documentation implies you are trying to create a vector
> > of "inc" length, evenly populated by values between 1 and 1... which
> > means a vector of all 1s... Might it not be faster to just
>
> >         v = [1] * inc
>
> > and pass v to some numpy method for conversion from Python list to numpy
> > vector?
>
> > (the -1 to 1 at least makes sense)
>
> >         Me? I'd probably create a class in which the __init__() takes a
> > value specifying the number of stages. It would than create suitable
> > lists to track values, some sort of counter (c), a Semaphore (s)
> > [initialized at 0 -- ie, already acquired/block],  a thread for EACH
> > stage, and an Event (e) object
>
> >         Each stage thread, initialized with its position in thepipeline.
> > The threads perform an e.wait() call. They also, after the wait is
> > released, perform an e.clear() call. As their processing, they each grab
> > from thepipeline"input" list the current value for their position.
> > After processing they update their position in the "output" list(s),
> > they decrement the counter c (maybe put a lock around access to c). The
> > thread that decrements c to 0 is responsible for "releasing" the
> > semaphore.
>
> >         The main code of the class instance is responsible for a loop that
> > does: set up the "input" list based on current value of stage outputs,
> > initialize c to the count of stages (minus 1?), e.set() to signal all
> > stage threads to process the current conditions, s.acquire() to block
> > until the last processed thread (by c hitting 0) does s.release(). It
> > then collects the output lists, does whatever shifting is needed to
> > prepare for the next cycle...
>
> >         Actually, that "loop" may not be a loop so much as a method off the
> > class like
>
> >         digitalOutput = adcInstance.step(analogInput)
>
> > which is, itself, in a loop.
>
> > That is, something like...
>
> > myADC = ADC(stages=10)
> > while True:
> >         voltage = getNextAnalogInput()
> >         digital = myADC.step(voltage)
> >         outputDigitalValue()
>
> >         Obviously I've not taken the time to actually lay out all the
> > instance lists needed for inputs and outputs, nor the code of threads
> > (while one can create the first "stages-1" threads with a loop, the
> > final stage needs a discrete creation)
>
> >         When one finds that the threading solution is really slow (though
> > understandable in terms of the hardware circuit -- one thread per stage
> > makes the stages easy to code), THEN one might try to figure out how to
> > implement an iterative version... I suspect using numpy would be the
> > third optimization -- removing iteration by using parallel vector
> > operations.
> > --
> >         Wulfraed                 Dennis Lee Bieber         AF6VN
> >         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
>
> Hi
>
> Firs

Re: How to implement a pipeline...??? Please help

2010-08-30 Thread Ritchy lelis
On 26 Ago, 08:52, Dennis Lee Bieber  wrote:
> On Tue, 24 Aug 2010 22:21:34 -0700 (PDT), Ritchy lelis
>  declaimed the following in
> gmane.comp.python.general:
>
> > hi friend Dennis Lee Bieber
>
> > I have watching your code sujestion and now i can understand more of
> > what you have there..
>
>         Take warning -- I think I had a major flaw in the summation part of
> the logic... It's probably easier just to use a list of lists (one list
> per stage, and each list as long as the number of stages) and sum the
> diagonal
>
>         result = sum([list_of_lists[i][i] for i in range(number_of_stages)])
>
> > i would like to show you them but i need to now if you still
> > interested in the challenge it self and also in helping me with your
> > extraordinary tips.
>
> > Can i count on your help? I hope so gratefully.
>
>         My apologies... much more help and I'll have done the work for you
> (though I'm still perplexed at simulating a hardware A/D converter when
> the input is already a floating point digital, and the output is integer
> digital)
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/


My apologies... much more help and I'll have done the work for you

   Until now you were the only person who helped me so far...
your help has served a lot.
   Already learned a lot with you so please do not stop
helping me.

To show you that you have not done it alone, i'll show you that i have
made some arrangements.

About the pipeline Class still have some errors and i'm working on it.
Hope this link help.

http://www.eetimes.com/design/automotive-design/4010021/SIGNAL-CHAIN-BASICS-Part-8--Flash-and-Pipeline-Converter-Operation-Explored

though I'm still perplexed at simulating a hardware A/D converter when
> the input is already a floating point digital, and the output is integer
> digital

I believe that de residuals that we're getting at the output,
already are the wave forms that we should get if we had a Oscilloscope
and analyzing the behavior of a A/D hardware and the digital parts is
to quantify the analog input ie first we analyze and translate the
analog input to a known residue and then quantifies to the digital
output.

I already initialized the "non linear" issues with the Class
Calculate, and after this we will start to see how A/D converter
really works.
I would love you to help me at this one to

Class Calculate:

1 - http://www.national.com/appinfo/adc/files/ABCs_of_ADCs.pdf

2 - http://www.atmel.com/dyn/resources/prod_documents/doc2559.pdf

And now my new arrangements:

# -*- coding: cp1252 -*-
###ADC#

##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Incluir as
Bibliotecas>>>>>>>>>>>>>>>>>>>>>>>>
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import *
from numpy.fft import *
from pylab import *
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>CLASS
ADC>>>>>>>>>>>>>>>>>>>>>>>>>>>>
class ADC(object):

   def __init__(self, Inc, V_in, V_ref, Cs, Cf):

  ##Guarda o número de estágio e a tensão de
referência
  ## Stores the number of stage and reference
voltage
  self.Inc = Inc
  self.V_ref = V_ref
  self.Cs = Cs
  self.Cf = Cs

  ##calcula os limiares da tensão do comparador
  ##calculates the threshold voltage of the
comparator
  self.V_H = self.V_ref * 0.25
  self.V_L = -self.V_H
  self.V_in = V_in

  #define dois array de "Inc" elementos todos a
uns e zeros respectivamente
  ##sets two array "Inc" elements all the ones and
zeros respectively
  self.ones = np.ones(Inc, dtype=np.float)
  self.zeros = np.zeros(Inc, dtype=np.float)

   ##função flash 1.5 bit
   ##1.5 bit flash function
   def flash1b5(self):

  # calcula as posições onde a tensão de entrada
excede o limiar alto
  ## calculates the positions where the input
voltage exceeds the high threshold
  highBits = np.where(self.V_in > self.V_H,
self.ones, self.zeros)

  #