06-11-2015 03:14 PM
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.
Solved! Go to Solution.
06-11-2015 05:24 PM
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.
06-12-2015 08:02 AM
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.
06-12-2015 08:12 AM
@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).