LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does the replace string block only work once?

Hi there

I am currently working on a GUI, where the user can press a series of buttons to get the gain or set the gain values of a system.  When either button is pressed, the gain values of each channel would then be returned to the user, through the microcontroller.  In total there are 2 boards and 4 channels and the gain of each channel is 16 bits.  However right now I have a problem.  When I press one button (let's say get gain), the values would be returned normally and sorted into the matrix (according to board number and channel number).  However when I press another button the matrix is then filled with zeroes.  I placed an indicator at the string and result string node of the replace substring block and I found that the string indicator has the correct string, but the replace substring does not have anything, in other words it does not cut the string up into a substring with a length of 2.  I am not sure why this is happening and I am wondering if someone could help.  

0 Kudos
Message 1 of 3
(1,960 Views)

I think your problems are much deeper.

 

You start out with an empty 2D array of strings that you convert to integer, then to dbl, then to a matrix. You end up with an empty matrix. That makes litttle sense. 

 

If you want to keep the matrix data between iteration of the outer loop, you also need a shift register in the outer loop, else you always start from scratch with a blank array

 

Can you show us a typical "read buffer" string and tell us what output you want.  Your code is pure gibberish to me.

 

(Also your sequence structure is not needed. the same execution order is determined by dataflow anyway. Why is there a 50ms delay in the inner loop? ...)

0 Kudos
Message 2 of 3
(1,945 Views)

Like Altenbach, I find it a bit hard to understand what your code is doing, but it looks to me like the problem is that you globablly initialize the feedback node.  That means it only gets initialized once.  When you click a button the second time, that feedback node contains whatever was leftover from the first call; it does not contain the data on the wire coming into it (that happens only on the first execution).  If you move the initializer terminal two loops out, I think you will get the results you expect.

0 Kudos
Message 3 of 3
(1,942 Views)