09-02-2009 03:35 PM
hi all.... i am facing problem ..im tryin to read DC current values from two channels.. i modified the advanced scan vi example..
the read vi is not waiting for the scan to finish.... i used trigger vi outside a for loop and i want the readings to be taken for a number of times which is equal to the trigger count.... i even placed a time delay between the standard event vi and the read vi....the standard event register vi has been set for operation complete bit. Yet the read vi is not waiting.
so can anyone let me knw if the delay helps in waiting the read vi to finish the scan??
will the read vi give out the readings for each scan or will it just display random values??
im posting the vi here... i kept the scan count to be 15 and scan-scan interval as 1sec. ( so it implies that im using a timer source for triggering) I used a time delay of 0.9secs in between standard event register vi and the read vi.
i used a for loop insted of a while loop coz i need the number of readings = scan count. i placed the trigger vi outside the for loop.
can anyone have a look over this vi and help me out?
09-02-2009 03:48 PM - edited 09-02-2009 03:53 PM
Looking at the Standard Event Status function, I don't think it does any waiting at all. The example you started from says its necessary to wait for OPC. Try running this VI in a loop that exits when OPC is true.
If the function does not wait, this points out why it is important to understand how each function actually works and why you would need to double check the examples and functions when something does not work as expected.
09-02-2009 03:53 PM
HI Dennis,
Thanks for your reply. I am new to labview. Frankly speaking i did not understand what you said.
If you dont mind can you explain more about this?
Thanks
09-02-2009 04:04 PM
The OPC? (Operation Complete) is a pretty standard function in GPIB instruments. The Standard Event Status function can query this. It looks like all that is does is return the status - in other words, the scan operation may or may not be complete when you perform your read. The function returns an array of Booleans. I think bit 2 is the opc bit. If this returns false, you should not be doing a read.
Right click on the Standard Event Status function and select SubVI Node Setup. Check all of the options except 'Open front panel when loaded'. Run the top level VI. When called, the subVI will popup and be paused. Click on the run arrow and look at the 'Bits Set' Booleans. See if the OPC is set. If not, rerun the VI until it is set. Then click the continue button on the subVI (the up arrow next to the run arrow). See if your data makes sense.
You could also just skip the break and probe the 'Bits Set' output. You would need to create an indicator for this.
If the opc is not complete when you probe or set the break, you would place the function inside a while loop. Make the condition to stop the loop a True result from operation complete.
09-02-2009 04:13 PM
HI Dennis,
Thanks a lot. I will try what you said and i will let you know about the result.
How will i knw if the OPC is set or not? will the booleans show true? should i probe the 'bits set' output in the block diagram of the subvi?
09-02-2009 04:27 PM
When set, one of the Booleans will show true. I'm not sure which one in the array but it should be pretty obvious if a Boolean is true or not.
No need to probe the output in the block diagram of the subVI. If the front panel is open, you can just look at it. A probe would be used in the main VI and as I said, you would first have to create an indicator in the main before you could probe.
09-02-2009 04:56 PM
HI
i tried what you said and the opc is not set. I dont see the booleans showing true. Now what should i do to set the opc?
09-02-2009 05:00 PM
Please try to understand how the instrument works. You can't SET the opc. You have to wait for the instrument to set it. As I said, it means operation complete and in your case, the operation you are waiting to be complete is the scan.
If you don't know how to use a while loop like I described, place a big honking wait after you start the scan. Make it large enough so that you know the scan is complete before you do the read. Obviously this is not the optimum solution.
09-02-2009 05:59 PM
Sorry for troubling you.
what i did was placed the trigger vi outside a for loop, because i want the loop( or read vi) to run the number of times i scan. I am not using a while loop because i dont want it to run continuously. Now the main problem is that the operation is not complete( scanning) but the read function has finished running. If i use a while loop and keep the trigger vi inside the while loop, the instrument runs till i stop. and if i place the trigger vi outside the loop, the read vi will not stop till we stop.
So i used the for loop to control the instrument scan. now i inderstood how important it is to knw whether the operation is complete or not. I can see from the front panel that scan is not finished, but read operation is.
I have seen in the example that we need to place the standard event register vi to wait for the scan to finish. so thats the problem.09-02-2009 07:21 PM
Now I placed a while loop around the standard event register vi and i am running it till i get a true in the bits set output. this time i checked the parameter'operation complete bit' instead of setting it. Only then i can see true value on the bit set output or else false.
The bit 1 is true after some time (after scanning is done), but the instrument is showing -410 error. This error actually says ' a command was received which sends data to the output buffer, but the ouput buffer contained data from previous command(previous data is not overwritten).The output buffer is cleared when power has been off or after a bus Device Clear.'
What should i do? Can you tell whether what i did is right? I atached the vi which has while loop around the standard event register vi.