01-16-2009 04:13 PM
Solved! Go to Solution.
01-16-2009 05:08 PM
One problem is that you are inserting into a position that keeps incrementing with every loop. So you have a 15 element array, but wind up inserting into position 16, 17, 18, ...... Those are undefined positions. If you are doing something where you are inserting the new element at the top of the array, then you should always insert at position 0. If you are always wanting to put at the end, you should append to the end of the array and take a subset of the array from index 1 for the length of 15.
The real problem you never see anything but zeroes is that the wire going into the right shift register is the same as the one coming out the left. The changes you make by inserting into the array and taking the subset disappear on each iteration of the action engine and never make it to the array indicator
01-16-2009 05:47 PM
K thanks. Yes, I hadn't put a stop for the case where it reaches the array size that was initialized but I will. And quite a dumb mistake with the shift register :(. Basically what I want it to do is initialize an array of zeros. Lets say [0 0 0 0 0]. Each time it loops i want it to put a number into the array.
I.E. [num, 0 0 0 0] .........second iteration [num, num2, 0, 0, 0] , etc.
However, I want to then take a sub array and only plot that point so the zeros arent plotted.
so for the first iteration plot(x,num) second iteration plot (x,num) and (x,num2)
for the n iteration plot (x,num), (x,num 2)... (x,num n).
A
quick modifcation to my codeso it works would be appreciated. I'm
pretty sure I'm using the correct functions, but yes that shift
register will cause problems as I amnot returning the array after the
new value has been added...woops 
01-16-2009 05:54 PM
Ravens Fan wrote:One problem is that you are inserting into a position that keeps incrementing with every loop. So you have a 15 element array, but wind up inserting into position 16, 17, 18, ...... Those are undefined positions. If you are doing something where you are inserting the new element at the top of the array, then you should always insert at position 0. If you are always wanting to put at the end, you should append to the end of the array and take a subset of the array from index 1 for the length of 15.
The real problem you never see anything but zeroes is that the wire going into the right shift register is the same as the one coming out the left. The changes you make by inserting into the array and taking the subset disappear on each iteration of the action engine and never make it to the array indicator
Thanks as always ravens...thats all it took was moving the wire now ill just fix the other stuff so it doesn't try and fill an array with dimensions larger than what was initialized!
01-17-2009 08:31 AM
Could someone take a quick look at this. I fixed everything except the first 15 times it loops for an array of size 15 it fills liek I want it to. Then it gives me zeros for the next 15 iterations. After 30 iterations it starts doing waht I want it to. Why does it give me zeros for that period of time?
Again, im tossing away the oldest value and adding the newest one to the end of the array.
01-17-2009 09:05 AM
Some general pointers to make your VI more robust.
Ton
01-17-2009 09:12 AM
The problem is that before 15 elements, you are inserting into a position on the array which pushes all the zeroes down and grows the array to 30 elements, your 15 with numbers and the original 15 zeroes after it. Once you have 15 inserted, you are using split array. This eliminates the 1 off the top, but 29 remain. Array subset beginning at 1 and for 15 elements would be better.
See attached.
01-17-2009 10:27 AM
01-22-2009 02:58 PM - edited 01-22-2009 02:59 PM
01-22-2009 03:23 PM
Using Build.Array is a bad thing if you are worried about performance. Replace Element is much better.
Remove the 'Default' from the Case selector box for Initialize, if you add a state to the Enum (average for instance) your code will break and you know you have to edit something.
Replace the enum with a Type-def.
You have two controls with the same name (Temperature B), rename them to 'Temperature in' and Tempererature out'.
Why is the 'Write' action in the Action engine? You don't use any of the buffer data.
Rename the enum to Action. Make the control required on the connector pane.
Use less input/output terminals. I would create an action engine for every array one.
Feed the pointer counter directly to the case struecture. make 0..4999 case and a default case.
Ton