10-14-2016 12:23 PM
Wollee,
I am using LV 2013 and your VI is 2015.
Thanks,
SM
10-14-2016 12:25 PM
Give this a try.
10-14-2016 01:02 PM
Matt,
Yeah it didn't really work... It caused so many issues with my program including causing LV to crash several times... I think it was the WHILE loop that messed it up, but I can't be sure. I didn't write the initial program that this is being implemented in and it is very fragile... Is there another way to do it, like with a case structure or something instead of a while loop? It also wasn't writing to my text file at all, even just putting in 1 message...
Thanks,
SM
10-14-2016 01:04 PM
Can you post your code? That was just a simple example and the while loop is not necessary. I have no idea what youre working with ha
10-14-2016 01:09 PM
Unfortunately I cannot post my code, due to several things... But here is the format of the incoming message:
[ABB Robot] [Abb Motion] [Set Target] [[0~0~0]~[0.96593~-0.25882~0~0]~[1~0~0~0]~[150~50]] [Pending] [0] [1]
Attached is a screenshot of where I am writing to the file if it helps...
Thanks,
SM
10-14-2016 01:17 PM
I really cant give you a lot of help. Thats a small portion of the code. The write to spreadsheet vi is great, but you have to realize it is going to open/create and close that file every time you run it. I cant tell when the message you want to store is created or the rest of the vi, but assuming you have a while or for loop in the main architecture in your application. You should try to store the messages in a shift register, you can use the logic i provided inside the while loop in my example to keep the last 5 messages, and when you are ready to shutdown the application you can use that write to spreadsheet vi to write those 5 messages.
Other than that i cant give much advice without seeing the code.
10-14-2016 01:21 PM
Bob,
Regarding your message:
"The simplest solution is to simply wait until the end of the program and then do any file I/O that you want (it would be up to you how many messages you save -- you could even save them all and simply write out the last 5, or use a circular buffer of length 5)."
Do you have an example of this?
Thanks,
SM
10-14-2016 01:26 PM
Bob said to use something like the example i provided or to store all of the messages in the shift register, i only keep 5 in the example i provided, or to use a circular buffer, which is provided in this link.
http://www.ni.com/tutorial/7188/en/
10-14-2016 01:36 PM
Matt,
I kind of played around a bit with your code and I believe I am getting close. Instead of going into any kind of loop, I just added all that straight to my code (see attached screenshot). The problem is, it only stores the last message, not the last 5 messages. How do I store the messages in a register or whatever?
Thanks,
SM
10-14-2016 01:43 PM
I see now that you have a cluster in a while loop.
1.So to that cluster add a string array, call that your last msgs or something. Unbundle that and feed that array into the delete from array function.
2.You should remove the concatenate and number to decimal string, that was just for the example, but your last message should go into that build array node on the bottom.
3. Bundle the build array output back into the cluster.
4. Delete the write to file, and just use write to spreadsheet there and feed the array of messages into that.
There are better ways to log but this will work for if you dont mind opening and closing the file every time you iterate that case.