LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SR400 while loop doesn't work

Solved!
Go to solution

Hi,

 

I am using LabVIEW to control SR400 through a GPIB card.

 

I use SR400 to count the number of signal in one second, wait for 0.05s, then count the signal again, wait for 0.05s again, and so on.

 

However the while loop didn't iterate. When I started the program, it only iterated once.

 

In highlight execution mode, when one iteration is finished, it waited for a long time to start the next. In the normal mode, it didn't iterate. 

 

Also when I clicked the stop button, it remained clicked. However when I wrote a very simple program, the stop button operated normally.

 

Anyway the button issue is not very important. I don't care whether the program iterates forever or not. I just want to make it iterate. 

 

I searched the board and hadn't couldn't any related problem.

 

Is it better to attach my VI? The VI is in my lab computer.

 

Thank you so much!

 

 

0 Kudos
Message 1 of 6
(3,009 Views)

Yes, please attach the VI when you get a chance.

0 Kudos
Message 2 of 6
(2,997 Views)

Here is the attachment. It seems that the computer is really old. The CPU is always 100% when I was operating the VI.

 

Thank you.

0 Kudos
Message 3 of 6
(2,965 Views)
Solution
Accepted by topic author PbZhang

That code just smells bad. 😞

 

(No real error handling, deeply stacked sequences, FOR loops that are hardwired to iterate once, controls on the right and right-to-left wiring, weird code to average the last 10 elements  (Hint: mean ptbypt with a sample lenght of 10 would do it!). If you would use the error wire, the sequences would not even be needed)

 

If the stop button does not reset, it means that the loop iteration does not complete. It can only complete if both sequence structures complete.

Have you tried running in execution highlighting mode while watching the diagram? Most likely one of the communications is stalling. For example, does the instrument really send 6 bytes at the end? Where do you set the global timeout and what is it?

0 Kudos
Message 4 of 6
(2,952 Views)

Wow actually in highlight execution mode, the upper sequence is much slower than the lower one.

 

I will try to delete that one and see if it runs well. If it is integer, should be 4 bytes, right?

 

I don't know how to check whether the machine sends 6 byte or not, I guess I should try 1, 2, 3, 4, 5, 6 and see whether it runs well.

 

Thank you!

0 Kudos
Message 5 of 6
(2,938 Views)

I delated the first sequence and it works well! Although it is inefficient.

 

I will try to solve the problem of the first sequence.

 

And I should add something that stop the program when an error occurs. 

 

If I finally get it, I will accept your post as solution.Smiley Happy

0 Kudos
Message 6 of 6
(2,925 Views)