Data acquisition
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
Re: Data acquisition
On Oct 25, 6:29 pm, Nick Dokos 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Data acquisition
On Oct 25, 6:43 pm, John Gordon 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Data acquisition
On Oct 25, 6:15 pm, Jean-Michel Pichavant 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Data acquisition
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 -- http://mail.python.org/mailman/listinfo/python-list