Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA skips certain commands

Solved!
Go to solution

I'm writing a small automation script for a Tektronix DSA8200 Oscilloscope. Part of my script involves setting up the MATH channels 1-4 and setting their vertical position and scale. Then, it's supposed to set reference 1 to math1. However, the scope has been skipping these steps. I've used NI I/O Trace to make sure that the commands are being sent without error, which they are. They just don't actually happen on the scope. I am able to use the NI communicator to manually run the operations after the script has completed, and they work just fine. I've tried setting "*WAI" all around my different commands trying to see if there's a SYNC issue, but it's done nothing. What could be happening? 

 

I've included my nitrace file in case that helps at all. 

0 Kudos
Message 1 of 4
(4,912 Views)
Solution
Accepted by topic author sawyermx

I ran into this very issue with a TDS3000 series scope.  What I observed was that the scope would miss commands while it was processing the math stuff (and other "long" processes).  My cure was the Magic Wait Fairy.  I litterally added 500ms waits between commands to allow the scope to run all of its math and what not.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 4
(4,900 Views)

I actually fixed this last night. I'll add snippets of my code and what I actually did for the sake of others. 

 

TCL:

 

set MathList [list 1 2 3 4]
	foreach math $MathList {
		#Write equation to corresponding math 
		switch $math {
			1 {scope::write "MATH1:DEFine \"((C${SCOPE_HEADA1}+C${SCOPE_HEADA2})/2)\""}
			2 {scope::write "MATH2:DEFine \"((C${SCOPE_HEADB1}+C${SCOPE_HEADB2})/2)\""}
			3 {scope::write "MATH3:DEFine \"((C${SCOPE_HEADA1}+C${SCOPE_HEADA2})/2-R1)\""}
			4 {scope::write "MATH4:DEFine \"((C${SCOPE_HEADB1}+C${SCOPE_HEADB2})/2-R2)\""}
		}
		scope::write "SELECT:MATH${math} ON"
		scope::write "*WAI"
		after 1000
		scope::write "MATH${math}:POSITION 0"
		scope::write "MATH${math}:SCALE 0.5"
		scope::write "SAVE:WAVEFORM MATH${math},MAIN,REF${math}"
	}

So apparently MATH definitions take really long to process, even if they're somewhat short. The "after 1000" tells the script  to wait 1000ms. Also, I found out, turning the math waveforms on autoscales them, and removes any sort of windowing or scaling that was previously applied to them. So all scaling here is done AFTER the waveform is turned on. 

0 Kudos
Message 3 of 4
(4,887 Views)

@sawyermx wrote:
Also, I found out, turning the math waveforms on autoscales them, and removes any sort of windowing or scaling that was previously applied to them. So all scaling here is done AFTER the waveform is turned on. 

That is exactly what made me add those 500ms delays.  The scales were applied, then the math channel completed and autoscaled (throwing out the scaling I already told it to use).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(4,882 Views)