Zer0 Posted July 28, 2015 Report Posted July 28, 2015 (edited) Hello everyone, I'm new to your community, so firstly I'd like to say hello to everyone I guess the topic was repeated several times and I have read many examples, but most of them were concentrated on auto fill of array with random values. I however need to set values into array manually, memorize them, and if possible to go back and make changes in case of a mistake. These values are given from Tasti WB630 keyboard and determine line feed for each of electrical linear drive. In my vision UP / DOWN keys set index number which corresponds to a subsequent piston, LEFT / RIGHT keys set value of feed for currently indexed piston. After setting a correct value for desired piston I hit OK and the value is stored into array. But here my vision ends, because LabVIEW somehow doesn't want to memorize all of the input data except the last one given index and value.The code for now works like this: Array: set + OK[0] 280[1] 0[2] 0[3] 0[4] 0 set + OK[0] 0[1] 50[2] 0[3] 0[4] 0 set + OK[0] 0[1] 0[2] 135[3] 0[4] 0 etc. I'd like to make it work like this: Array: set + OK [0] 280[1] 0[2] 0[3] 0[4] 0 set + OK[0] 280[1] 50[2] 0[3] 0[4] 0 set + OK[0] 280[1] 50[2] 135[3] 0[4] 0 etc. So, can anyone help me out? EDIT: I've added my source files with code needed for the emulation of Tasti keyboard and my work so far. Main VI: tasti_emul.vi, SubVI's: Tasti_LR.viTasti_OK2.viTasti_UD.vi Edited July 28, 2015 by Zer0 Quote
hooovahh Posted July 28, 2015 Report Posted July 28, 2015 So you can use the initialize array, providing the data type (double) and the maximum size. Then wire that to a while loop, turning the tunnel into a shift register. This keeps data between loop iterations. Wire it to the right, and the next while loop iteration will use that new data on the left. So now you can use the replace array subset, replacing the index specified and the value. You might be able to use the iteration terminal (i) of the FOR or WHILE loops if each iteration you replace the next value. Quote
Zer0 Posted July 28, 2015 Author Report Posted July 28, 2015 Thank you for your quick reply My previos code looks like this: And this one works as I desrcibed - it memorizes only the last index and value. Every previos input is nullified. Even if I rewire some connctions to fit your advice, my code still doesn't work: Quote
infinitenothing Posted July 28, 2015 Report Posted July 28, 2015 Every time you start the outer while loop, you're going to start with the same initialized array coming into the wire. If you want labview to remember something from one iteration to the next, you need to put a shift register on that loop. The inner while loop does nothing as far as I can tell and probably should be removed. Quote
hooovahh Posted July 28, 2015 Report Posted July 28, 2015 Yup what he said. The shift register should be on the first while loop, and remove the inner while loop all together. You've probably seen these training things before but you should check them out if you haven't already. Learn NI Training Resource Videos 3 Hour LabVIEW Introduction 6 Hour LabVIEW IntroductionSelf Paced training for studentsSelf Paced training beginner to advanced, SSP RequiredLabVIEW Wiki on Training Quote
Zer0 Posted July 28, 2015 Author Report Posted July 28, 2015 (edited) Thanks for all the tutorials and advices. Indeed the inner while loop was unnecessary. I've done the code like in the pic below and it works fine for me Edited July 28, 2015 by Zer0 Quote
hooovahh Posted July 28, 2015 Report Posted July 28, 2015 While what you posted works, I will tell you for a forth time in this thread, to USE A SHIFT REGISTER (sorry for yelling). Quote
infinitenothing Posted July 28, 2015 Report Posted July 28, 2015 (edited) Zer0, where do you initialize (write zeros to) the array? I'm guessing you have a race condition. Using a shift register will fix that race condition Edited July 28, 2015 by infinitenothing Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.