LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

missing array values

hi,
i have an application that tries to communicate with 2 instruments (a power supply and an ammeter). i was able to get the correct number of readings for voltage array (based on the readings on the instrument screen itself), but for the current one, the first reading was always the last reading from the previous run. The middle readings are correct as in corresponding to the voltage's readings. The last reading was always zero, when the instrument's screen registers another value.. how do i solve this problem?

thanks,
adeline
0 Kudos
Message 1 of 8
(3,215 Views)
Adeline,

I have not worked with GPIB recently, but I suspect that one of your instruments does not return a value for each iteration of the loop and the array contains the default value (zero). Compare the return count output of the the VISA Read functions to see if the requested data is actually returned.

Also, Wait ms function might be better that Wait Until next ms Multiple in that it will assure your that the full wait time occurs for each GPIB opreration.

Consider learning about state machines (while loop with case statement inside). They are very powerful and versatile for applications such as yours. Look through the examples and search the archives for "state machine".

Lynn
0 Kudos
Message 2 of 8
(3,215 Views)
I suspect the problem is in your sub-vi for the ammeter. I don't know which instrument you are using, but does it correctly respond to the VISA CLR command? Also, you are writing "X" to the device. Are you sure this is the right command? Usually you have to send a command with a question mark to initiate a read, like "VOUT?". Check your GPIB commands. The main vi looks OK. Try using MAX to communicate with the ammeter, issue commands, and look at the responses. Hope this helps.
- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 8
(3,215 Views)
yes, lynn,
u r correct. i checked my return count. my ammeter is not returning some of the values for the last few values. I tried testing with other numbers, and found that it is not just the last reading that is registering zero, sometimes the second last reading is also zero.. i am puzzled.
my power supply which sets and reads the voltage is doing fine.
i tried the wait ms, but it does not seem to have any differnece.
so since the ammeter is not reading sometimes, what should i do to solve the prob? thanks
adeline
0 Kudos
Message 4 of 8
(3,215 Views)
my instrument is keitheley 450 pico-ammeter.. i tried using the MAX using X, it is able to give me readings, so i assume it is a correct code? but even so, i still could not solve the problem...
any suggestions?
0 Kudos
Message 5 of 8
(3,215 Views)
sorry, it should be 485, not 450
0 Kudos
Message 6 of 8
(3,215 Views)
I am not familiar with that instrument, sorry. Things you can check is the ammeter sub-vi: Byte count on VISA Read, maybe not enough and some bytes are remaining in buffer. Substring with offset=4, length=14, make sure these values are correct. Try running the sub-vi stand alone to see if you get values that match the instrument readout. Also, try turning on the highlight execution light bulb and look at the values that are produced along the way. Use probes to look at output values, might be easier. The problem lies around where the discrepancies are spotted. Good luck.
- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 8
(3,215 Views)
I just noticed something. On your main vi, the string output of the top sub-vi is indexed coming out of the loop. The bottom sub-vi string output is not indexed. You are not getting an array of values, only the last value read. Maybe this is the problem.
- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 8
(3,215 Views)