LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop doesn't record all data

Solved!
Go to solution

@bcooke wrote:

You know, there is really no need to be so rude about this. I told you that I am new at this. A group of us are trying to write this code for an experiment we are doing in class. None of us have background in LabView and our professor taught us nothing about it. We have to figure it all out for ourselves. I'm sure you all were like this when you first starting learning LabView as well.

 

About how I said we tested it before: we were getting data points in our file that were saying the same frequency (which seemed to show that the inner loop was taking data more than once) so it looked like it was working.


Rudness wasn't intented.  We've all seen clients and customers with the exact same "The problem can't be there I Know that works fix your code" problems before.  These become little gems for conversation when we sit down over beverages.  As far as what my first LabVIEW project looked like..... Well if you've ever seen spaghetti that has been regurgitated that comes close......


"Should be" isn't "Is" -Jay
0 Kudos
Message 21 of 31
(959 Views)

Ok, let's go to the beginning.  What instruments are you using?  What commands are you sending them?  And I want specifics so I can go look up the instrument and make sure you are interacting with it correctly.  Because you are not getting data during the second iteration, I think there is a problem with your setup.


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 22 of 31
(956 Views)

Jeff·Þ·Bohrer wrote:We've all seen clients and customers with the exact same "The problem can't be there I Know that works fix your code" problems before.

For me, it was VHDL programmers I had to work with:

Them: "We changed a bunch of stuff.  It isn't working.  You broke it."

Me (and other test engineers): "Wait a minute.  It was working before.  It isn't working now.  I changed nothing.  You changed a bunch of stuff.  So is that my fault?"


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 23 of 31
(955 Views)

I am using a Keithley Model 6221 AC and DC Current Source and using the command SYST:KEY 45, which, when we have the machine on the screen for changing the frequency, moves it up by 10 Hz each time. The machine we are talking to in the inner loop is an SR830 lock-in amplifier and the command we are using is SNAP? 1,2,9

0 Kudos
Message 24 of 31
(934 Views)
Solution
Accepted by bcooke

Ok, the Keithley is not going to keep sending data.  It needs a request for data.  It might be sending data when you send the SYST:KEY 45 command.  This is why the inner loop works on the first iteration, but not the rest (only 1 read is available).  Move the read of the Keithley to the outer loop after sending the command.


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 25 of 31
(895 Views)

Moving the Keithley read to the outer loop did fix the inner loop! Thank you so much! Now there is another problem showing up. The inner loop runs as many times as I tell it to, but now the outer loop will stop after one loop. Is this also because of the Keithley read?

0 Kudos
Message 26 of 31
(869 Views)

Hi bcooke,

 

maybe you could examine this by using simple debugging techniques like highlighting? It's pretty easy...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 27 of 31
(866 Views)

Can you upload your latest code?  I'm sure you've made some major changes since the last upload you provided.


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 28 of 31
(863 Views)

Sorry. I thought I had posted it. Here you go.

0 Kudos
Message 29 of 31
(856 Views)

Ok, first let's talk about some tweaks.

  1. Use a FOR loop for the inner loop.  You can enable the Conditional Terminal in order to stop if there's an error.
  2. Use a FOR loop for the outer loop.  Works the same at the inner loop.
  3. Use shift registers (been discussed plenty in this thread) to propagate your errors between loop iterations.  I would use shift registers for the VISA and file references as well.
  4. Use I32 representation for your number of loops to perform.  There's no need to have them be a floating point double.


Now let's talk about your immediate problem.  You will notice that your stop condition for the inner loop is being ORed as part of the stop condition of the outer loop.  That is why the out loop only executes once.  If you take my advice above about changing to FOR loop, your ORs for combining the error condition and the number of loops to run will become not needed.

 

I took the liberty of cleaning up your code with the suggestions I made above.


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 30 of 31
(832 Views)