LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency Sweep and Read from a Serial Instrument

Hello dear members, 

 

 My code assigns a frequency to a serial instrument(an LCR meter), and reads the corresponding capacitance-resistance values. It is a frequency sweep program, so it does the same task for all the frequency values in the predetermined interval. It is working nicely, except one thing. The first values for resistance and capacitance are zero somehow. If i change the location of wait_ms in the sequential logic, then the first values become the last values of the previous run of the program. I know that I assign them as zero as the initial value of the shift register, yet I have used a very similar code for getting data from a DAQ and it was working perfectly there. The program is in the attachment, I do not know what is the issue here, if you could help it is much appreciated. 

0 Kudos
Message 1 of 6
(2,281 Views)

Hi Kellec,

 

The first values for resistance and capacitance are zero somehow.

Because you are using BytesAtPort!

Get rid of that property node and wire a constant value, larger than the largest message you expect!

 

(You are sending a command and try to read the BytesAtPort immediatly - even before your device has a chance to process the command and send the answer. Instead there are zero bytes in the buffer and VISARead starts to read zero bytes…)

 

Don't use so many local variables.

Don't use InsertIntoArray when you could use BuildArray!

Don't use BuildArray when you could use autoindexing at loop borders!

Don't use sequence structures when you can use wires to enforce DATAFLOW!

I recommend to use FormatIntoString instead of ConvertFloatToString, followed by a larger ConcatString function…

After some modifications:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(2,269 Views)

Hi GerdW, 

 

Thank you very much for the advice. Now what happens is that, the initial values becomes the last value of the previous run. 

 

best

 

kellec

0 Kudos
Message 3 of 6
(2,262 Views)

Hi Kellec,

 

then you need to initialize your device in a more robust way.

As you clear the buffer it seems the device is sending the last measurement value upon your request (which doesn't make a lot of sense to me)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(2,254 Views)

Without BytesAtPort, I always get that hexadecimal error at visa read. If I attach a constant such as 99, the code doesn't run. I've implemented all the modifications you have made, still the same. The code is much more compact and computationally effective though 🙂

 

Best

 

kellec

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

Hi kellec,

 

what is a "hexadecimal error"?

 

Please use VISASerialPortInit and choose the correct TermChar (as described in your device manual). Then VISARead should work as expected...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(2,231 Views)