02-02-2009 10:35 AM
Hi guys,
im trying to log data from multiple numeric indicators on my front pannel every second, i want to log them to a seperate colum in a tab file so they can be imported to excel.
I have got it working but the data is upside down, that is to say my first readings are at the bottom of the spread sheet and my last readings are at the top. How can i turn the array upside down before i write it to file.
Also i would like to add a header or title to identify each collum?
I have attached a picture of this part of the program. Cheers, Zac
Solved! Go to Solution.
02-02-2009 10:50 AM
Reverse all of the inputs on your build array. But the wire from the shift register on top and the wire from the local variable on bottom.
Do you need the local variables? Where is the data coming from? You might set yourself up for a race condition.
Rather than having all of those build arrays, you may want to build an array of the new data. Then put that data onto a single 2-D array that goes through the shift register. It will eliminate 12 of the 13 shift registers and a lot of wiring. You might not need the transpose array after that. You'll just have to check the way array gets built because rows may become columns and vice versa.
02-02-2009 12:49 PM
02-03-2009 03:13 AM
Thanks for the info guys, reversing the inputs works fine, how about adding some headder info / colum lables to the file ?
I tryed to right click the array elements but it says this item doesnt have any properties.
Zac
02-03-2009 03:14 AM
Oh, just to clarify, the data is comming from a PLC via an OPC server, onto front pannel indicators, then i'm logging to file every second.
Zac
02-03-2009 08:25 AM
Move your file path control outside the loop.
Use the the basic file functions on the file I/O palette to write out the header string. Feed the file path wire into the for loop and into the Write Spreadsheet File function with it set to append new data.
02-03-2009 08:51 AM
When i take the path outside the for loop and enable "append to file" on the write to spread sheet function it repeats the data in the file, so i get the same data saved a number of times.
still cant figure the header out, if i use write to text file to put a headder in the path/refnum out put can't be connected to the path input on my write to spreadshet file??
Thanks, Zac
02-03-2009 09:03 AM
What is the action of the Log Data button? Is it latched so that it only executes once per press, or is it switched so that it maintains its true state until you press it again? How often do you press the button?
What is happening in the false case of that case structure, nothing?
It looks like you are writing out your whole dataset each and every time the button is true and overwriting the file. If that button is true a lot, that seems like an inefficient way of storing your data, and there are more efficient ways of writing to a file.
However, what you can do is put the file I/O functions in that case structure and set the Write spreadsheet function to append data. Then when the button is true, the file is opened, the header is written to the beginning of the file, the data array is appended to that, then the file is closed.
02-03-2009 09:32 AM
The action of the log data button is switch. I want logging to take place every second whilst this button is pressed and stop when it is pressed a second time.
In the "false" case nothing happens. (yet, meby some error checking later)
As far as i understand it, i am (reading the current value of thoes variables into an array and saving them to a file once per second) whilst the log data button is down. (or i think so at leased)
I can't figue out how to wire the write "text file" function to the "write to spreadsheet file" function, so i can have a text headder above my collums of data (in the same file).
Thanks Zac
02-03-2009 10:14 AM - edited 02-03-2009 10:16 AM
Like this.
