06-17-2019 01:16 PM
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.
06-17-2019 01:28 PM - edited 06-17-2019 01:39 PM
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:
06-17-2019 01:36 PM
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
06-17-2019 01:41 PM
06-17-2019 02:16 PM
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
06-17-2019 03:00 PM