Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #14970 > unrolled thread

Data acquisition

Started byspintronic <sidorenko.andrey@gmail.com>
First post2011-10-25 08:51 -0700
Last post2011-10-26 19:35 +0200
Articles 13 — 7 participants

Back to article view | Back to comp.lang.python


Contents

  Data acquisition spintronic <sidorenko.andrey@gmail.com> - 2011-10-25 08:51 -0700
    Re: Data acquisition Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-10-25 18:15 +0200
      Re: Data acquisition spintronic <sidorenko.andrey@gmail.com> - 2011-10-25 10:35 -0700
    Re: Data acquisition Nick Dokos <nicholas.dokos@hp.com> - 2011-10-25 12:29 -0400
      Re: Data acquisition spintronic <sidorenko.andrey@gmail.com> - 2011-10-25 10:22 -0700
        Re: Data acquisition Dietmar Schwertberger <news@schwertberger.de> - 2011-10-25 23:31 +0200
    Re: Data acquisition John Gordon <gordon@panix.com> - 2011-10-25 16:43 +0000
      Re: Data acquisition spintronic <sidorenko.andrey@gmail.com> - 2011-10-25 10:31 -0700
        Re: Data acquisition John Gordon <gordon@panix.com> - 2011-10-25 18:34 +0000
    Re: Data acquisition "Paul Simon" <psimon@sonic.net> - 2011-10-25 15:06 -0700
    Re: Data acquisition Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-10-25 17:08 -0700
    Re: Data acquisition spintronic <sidorenko.andrey@gmail.com> - 2011-10-26 08:58 -0700
      Re: Data acquisition Dietmar Schwertberger <news@schwertberger.de> - 2011-10-26 19:35 +0200

#14970 — Data acquisition

Fromspintronic <sidorenko.andrey@gmail.com>
Date2011-10-25 08:51 -0700
SubjectData acquisition
Message-ID<362e368f-829e-4477-bcfc-c0650d231029@j7g2000yqi.googlegroups.com>
Dear friends,

I have a trouble with understanding the following. I have a very short
script (shown below) which works fine if I "run" step by step (or line
by line) in Python shell (type the first line/command -> press Enter,
etc.). I can get all numbers (actually, there are no numbers but a
long string, but this is not a problem) I need from a device:

'0.3345098119,0.01069121274,0.02111624694,0.03833379529,0.02462816409,0.0774275008,0.06554297421,0.07366750919,0.08122602002,0.004018369318,0.03508462415,0.04829900696,0.06383554085, ...'

However, when I start very the same list of commands as a script, it
gives me the following, which is certainly wrong:

[0.0, 0.0, 0.0, 0.0, 0.0,...]

Any ideas? Why there is a difference when I run the script or do it
command by command?

===========================
from visa import *

mw = instrument("GPIB0::20::INSTR", timeout = None)

mw.write("*RST")
mw.write("CALC1:DATA? FDATA")

a=mw.read()

print a
===========================
(That is really all!)


PS In this case I use Python Enthought for Windows, but I am not an
expert in Windows (I work usually in Linux but now I need to run this
data acquisition under Windows).

[toc] | [next] | [standalone]


#14971

FromJean-Michel Pichavant <jeanmichel@sequans.com>
Date2011-10-25 18:15 +0200
Message-ID<mailman.2212.1319559327.27778.python-list@python.org>
In reply to#14970
spintronic wrote:
> Dear friends,
>
> I have a trouble with understanding the following. I have a very short
> script (shown below) which works fine if I "run" step by step (or line
> by line) in Python shell (type the first line/command -> press Enter,
> etc.). I can get all numbers (actually, there are no numbers but a
> long string, but this is not a problem) I need from a device:
>
> '0.3345098119,0.01069121274,0.02111624694,0.03833379529,0.02462816409,0.0774275008,0.06554297421,0.07366750919,0.08122602002,0.004018369318,0.03508462415,0.04829900696,0.06383554085, ...'
>
> However, when I start very the same list of commands as a script, it
> gives me the following, which is certainly wrong:
>
> [0.0, 0.0, 0.0, 0.0, 0.0,...]
>
> Any ideas? Why there is a difference when I run the script or do it
> command by command?
>
> ===========================
> from visa import *
>
> mw = instrument("GPIB0::20::INSTR", timeout = None)
>
> mw.write("*RST")
> mw.write("CALC1:DATA? FDATA")
>
> a=mw.read()
>
> print a
> ===========================
> (That is really all!)
>
>
> PS In this case I use Python Enthought for Windows, but I am not an
> expert in Windows (I work usually in Linux but now I need to run this
> data acquisition under Windows).
>   

Just in case you have a local installation of visa and it silently fails 
on some import,

try to add at the begining of your script:
import sys
sys.path.append('')

When using the python shell cmd line, '' is added to sys.path by the 
shell, that is one difference that can make relative imports fail in 
your script.

If it's still not working, well, it means the problem is somewhere else.

JM

[toc] | [prev] | [next] | [standalone]


#14977

Fromspintronic <sidorenko.andrey@gmail.com>
Date2011-10-25 10:35 -0700
Message-ID<8692a942-5e33-4063-a55f-7c02f3690b4a@hv4g2000vbb.googlegroups.com>
In reply to#14971
On Oct 25, 6:15 pm, Jean-Michel Pichavant <jeanmic...@sequans.com>
wrote:
> spintronic wrote:
> > Dear friends,
>
> > I have a trouble with understanding the following. I have a very short
> > script (shown below) which works fine if I "run" step by step (or line
> > by line) in Python shell (type the first line/command -> press Enter,
> > etc.). I can get all numbers (actually, there are no numbers but a
> > long string, but this is not a problem) I need from a device:
>
> > '0.3345098119,0.01069121274,0.02111624694,0.03833379529,0.02462816409,0.0774275008,0.06554297421,0.07366750919,0.08122602002,0.004018369318,0.03508462415,0.04829900696,0.06383554085, ...'
>
> > However, when I start very the same list of commands as a script, it
> > gives me the following, which is certainly wrong:
>
> > [0.0, 0.0, 0.0, 0.0, 0.0,...]
>
> > Any ideas? Why there is a difference when I run the script or do it
> > command by command?
>
> > ===========================
> > from visa import *
>
> > mw = instrument("GPIB0::20::INSTR", timeout = None)
>
> > mw.write("*RST")
> > mw.write("CALC1:DATA? FDATA")
>
> > a=mw.read()
>
> > print a
> > ===========================
> > (That is really all!)
>
> > PS In this case I use Python Enthought for Windows, but I am not an
> > expert in Windows (I work usually in Linux but now I need to run this
> > data acquisition under Windows).
>
> Just in case you have a local installation of visa and it silently fails
> on some import,
>
> try to add at the begining of your script:
> import sys
> sys.path.append('')
>
> When using the python shell cmd line, '' is added to sys.path by the
> shell, that is one difference that can make relative imports fail in
> your script.
>
> If it's still not working, well, it means the problem is somewhere else.
>
> JM

Hi!

Thanks! I have just tried. Unfortunately, it does not work ...

Best,
AS

[toc] | [prev] | [next] | [standalone]


#14973

FromNick Dokos <nicholas.dokos@hp.com>
Date2011-10-25 12:29 -0400
Message-ID<mailman.2214.1319560789.27778.python-list@python.org>
In reply to#14970
spintronic <sidorenko.andrey@gmail.com> wrote:

> Dear friends,
> 
> I have a trouble with understanding the following. I have a very short
> script (shown below) which works fine if I "run" step by step (or line
> by line) in Python shell (type the first line/command -> press Enter,
> etc.). I can get all numbers (actually, there are no numbers but a
> long string, but this is not a problem) I need from a device:
> 
> '0.3345098119,0.01069121274,0.02111624694,0.03833379529,0.02462816409,0.0774275008,0.06554297421,0.07366750919,0.08122602002,0.004018369318,0.03508462415,0.04829900696,0.06383554085, ...'
> 
> However, when I start very the same list of commands as a script, it
> gives me the following, which is certainly wrong:
> 
> [0.0, 0.0, 0.0, 0.0, 0.0,...]
> 
> Any ideas? Why there is a difference when I run the script or do it
> command by command?
> 
> ===========================
> from visa import *
> 
> mw = instrument("GPIB0::20::INSTR", timeout = None)
> 
> mw.write("*RST")
> mw.write("CALC1:DATA? FDATA")
> 
> a=mw.read()
> 
> print a
> ===========================
> (That is really all!)
> 
> 
> PS In this case I use Python Enthought for Windows, but I am not an
> expert in Windows (I work usually in Linux but now I need to run this
> data acquisition under Windows).
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

Shot in the dark: could it be that you have to add delays to give the
instrument time to adjust? When you do it from the python shell, line by
line, there is a long delay between one line and the next.

Nick

[toc] | [prev] | [next] | [standalone]


#14975

Fromspintronic <sidorenko.andrey@gmail.com>
Date2011-10-25 10:22 -0700
Message-ID<db028e09-db69-4b64-a61d-47f14330f533@g16g2000yqa.googlegroups.com>
In reply to#14973
On Oct 25, 6:29 pm, Nick Dokos <nicholas.do...@hp.com> wrote:
> Shot in the dark: could it be that you have to add delays to give the
> instrument time to adjust? When you do it from the python shell, line by
> line, there is a long delay between one line and the next.
>
> Nick

Hi, Nick!

Thanks! You are right but it was the first thing I thought about. So I
have tried to delay using sleep(t) from the time module (I also sent
"*OPC?" or "*WAI" commands to a device for synchronization). However,
it does not help ...

Best,
AS

[toc] | [prev] | [next] | [standalone]


#14983

FromDietmar Schwertberger <news@schwertberger.de>
Date2011-10-25 23:31 +0200
Message-ID<j879sn$gr0$1@online.de>
In reply to#14975
Am 25.10.2011 19:22, schrieb spintronic:
> On Oct 25, 6:29 pm, Nick Dokos<nicholas.do...@hp.com>  wrote:
>> Shot in the dark: could it be that you have to add delays to give the
>> instrument time to adjust? When you do it from the python shell, line by
>> line, there is a long delay between one line and the next.
> Thanks! You are right but it was the first thing I thought about. So I
> have tried to delay using sleep(t) from the time module (I also sent
> "*OPC?" or "*WAI" commands to a device for synchronization). However,
> it does not help ...

RST is resetting all data and CALC is somehow calculating and returning
data. Without a trigger between RST and CALC, I would not expect any
data...

Maybe the equipment is triggering continuously e.g. every second.
When you were using the shell, you had a good chance to see a trigger
between RST and CALC. With a script, it's not so likely.
OPC won't help, as it would wait for completion of a measurement, but if
you don't trigger, it won't wait.

What kind of instrument are you using? Check for the trigger command.
It may be something like INIT:IMM

Regards,

Dietmar

[toc] | [prev] | [next] | [standalone]


#14974

FromJohn Gordon <gordon@panix.com>
Date2011-10-25 16:43 +0000
Message-ID<j86ovu$khh$1@reader1.panix.com>
In reply to#14970
In <362e368f-829e-4477-bcfc-c0650d231029@j7g2000yqi.googlegroups.com> spintronic <sidorenko.andrey@gmail.com> writes:

> Any ideas? Why there is a difference when I run the script or do it
> command by command?

Are you running the same python program in both cases?

Are you in the same directory in both cases?

Does PYTHONPATH and/or sys.path have the same value in both cases?

Show us an exact transscript of both executions.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#14976

Fromspintronic <sidorenko.andrey@gmail.com>
Date2011-10-25 10:31 -0700
Message-ID<86e6bfb8-17e1-4544-97ba-7299db8a8140@p16g2000yqj.googlegroups.com>
In reply to#14974
On Oct 25, 6:43 pm, John Gordon <gor...@panix.com> wrote:

Thanks, John!

> Are you running the same python program in both cases?

Yes, the same.

> Are you in the same directory in both cases?
> Does PYTHONPATH and/or sys.path have the same value in both cases?

It looks that yes but how can it matter? All I need it is to import
the visa module and it works well.

> Show us an exact transscript of both executions.

There is nothing but "numbers". Or do you mean something else? I do
not receive any errors, only different results ...

Best,
AS

[toc] | [prev] | [next] | [standalone]


#14978

FromJohn Gordon <gordon@panix.com>
Date2011-10-25 18:34 +0000
Message-ID<j86vg1$24k$1@reader1.panix.com>
In reply to#14976
In <86e6bfb8-17e1-4544-97ba-7299db8a8140@p16g2000yqj.googlegroups.com> spintronic <sidorenko.andrey@gmail.com> writes:

> > Are you in the same directory in both cases?
> > Does PYTHONPATH and/or sys.path have the same value in both cases?

> It looks that yes but how can it matter? All I need it is to import
> the visa module and it works well.

If you run the two cases from different directories, and the current
directory is in PYTHONPATH or sys.path, and one of the directories
contains a python file named "visa.py" and the other doesn't, that
culd account for the difference in output.

Do you have access to the visa.py source code?  Can you add a simple
print statement near the top of the module so that we know the same
visa.py module is being imported in both cases?

> > Show us an exact transscript of both executions.

> There is nothing but "numbers". Or do you mean something else? I do
> not receive any errors, only different results ...

I was more interested in the exact commands you used to run both cases,
rather than the output.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#14985

From"Paul Simon" <psimon@sonic.net>
Date2011-10-25 15:06 -0700
Message-ID<4ea7331e$0$1715$742ec2ed@news.sonic.net>
In reply to#14970
"spintronic" <sidorenko.andrey@gmail.com> wrote in message 
news:362e368f-829e-4477-bcfc-c0650d231029@j7g2000yqi.googlegroups.com...
> Dear friends,
>
> I have a trouble with understanding the following. I have a very short
> script (shown below) which works fine if I "run" step by step (or line
> by line) in Python shell (type the first line/command -> press Enter,
> etc.). I can get all numbers (actually, there are no numbers but a
> long string, but this is not a problem) I need from a device:
>
> '0.3345098119,0.01069121274,0.02111624694,0.03833379529,0.02462816409,0.0774275008,0.06554297421,0.07366750919,0.08122602002,0.004018369318,0.03508462415,0.04829900696,0.06383554085, 
> ...'
>
> However, when I start very the same list of commands as a script, it
> gives me the following, which is certainly wrong:
>
> [0.0, 0.0, 0.0, 0.0, 0.0,...]
>
> Any ideas? Why there is a difference when I run the script or do it
> command by command?
>
> ===========================
> from visa import *
>
> mw = instrument("GPIB0::20::INSTR", timeout = None)
>
> mw.write("*RST")
> mw.write("CALC1:DATA? FDATA")
>
> a=mw.read()
>
> print a
> ===========================
> (That is really all!)
>
>
> PS In this case I use Python Enthought for Windows, but I am not an
> expert in Windows (I work usually in Linux but now I need to run this
> data acquisition under Windows).

I'm almost certain that there is a turnaround timing issue that is causing 
the problem.  These are common problems in data aquisition systems.  The 
simplest solution is to loop and wait for end of line from the sending end 
and if necessary put in a time delay.  After receiving the data, check the 
received data for correct format, correct first and last characters, and if 
possible, check sum.  I've worked through this problem with rs-485 data 
collection systems where there is no hand shaking and would not be surprised 
to expect the same even with rs-232.

Paul Simon 

[toc] | [prev] | [next] | [standalone]


#14989

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2011-10-25 17:08 -0700
Message-ID<mailman.2220.1319587812.27778.python-list@python.org>
In reply to#14970
On Tue, 25 Oct 2011 08:51:27 -0700 (PDT), spintronic
<sidorenko.andrey@gmail.com> declaimed the following in
gmane.comp.python.general:

> script (shown below) which works fine if I "run" step by step (or line
> by line) in Python shell (type the first line/command -> press Enter,
> etc.). I can get all numbers (actually, there are no numbers but a
> long string, but this is not a problem) I need from a device:

	<snip> 

> However, when I start very the same list of commands as a script, it
> gives me the following, which is certainly wrong:
> 
> [0.0, 0.0, 0.0, 0.0, 0.0,...]

	<snip> 
> mw = instrument("GPIB0::20::INSTR", timeout = None)
>
	Does "timeout=None" mean "wait forever", or "return with whatever is
available"?

	If the latter, it would mean the script is running too fast for the
device to respond, and you should add some sleeps.

>From the PyVisa documentation:

doc> Here, my device may be a device, an interface or whatever, and its
timeout is set to 25 seconds. Floating-point values
doc> are allowed. If you set it to zero, all operations must succeed
instantaneously. You must not set it to None. Instead, if
doc> you want to remove the timeout, just say
doc> del my_device.timeout
doc> Now every operation of the resource takes as long as it takes, even
indefinitely if necessary.

Note the warning: "YOU MUST NOT SET IT TO NONE"

> mw.write("*RST")
> mw.write("CALC1:DATA? FDATA")
>
	Does the write() buffer? Do you need to flush the output (something
that may be occurring in the background with the interactive session).
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#15004

Fromspintronic <sidorenko.andrey@gmail.com>
Date2011-10-26 08:58 -0700
Message-ID<1059c1c4-4581-412d-ad08-6fba6289444d@l12g2000vby.googlegroups.com>
In reply to#14970
Dear friends!

Thank you for the discussion. It was really helpful. As mentioned, it
was necessary to have a longer delay. Previously I have used a delay
of 5 and 10 s but it was not long enough. Now it is 25 s and
everything works fine.

Thank you again!

Best,
AS

[toc] | [prev] | [next] | [standalone]


#15008

FromDietmar Schwertberger <news@schwertberger.de>
Date2011-10-26 19:35 +0200
Message-ID<j89gco$mdk$1@online.de>
In reply to#15004
Am 26.10.2011 17:58, schrieb spintronic:
> Thank you for the discussion. It was really helpful. As mentioned, it
> was necessary to have a longer delay. Previously I have used a delay
> of 5 and 10 s but it was not long enough. Now it is 25 s and
> everything works fine.
If you use the correct sequence of trigger and OPC/WAIT, I'm sure
you can reduce the waiting time to the required minimum time and
still your script will be more robust...

Regards,

Dietmar

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web