Hello All,
I am trying to keep track of the robot's position real time. One way to do this was to create an array and store values from $POS_ACT.X in the array for the X-axis positions of the robot.
I am unsure as to how I would read/bring up/output these positions/array contents for me to see on-screen or load up to a file.
Any ideas?
Thank you for your time!
-iK!_!KA
Checking current array index and array content
-
iK!_!KA -
October 12, 2017 at 5:50 PM -
Thread is marked as Resolved.
-
-
Simplest way: Declare a very large array in your .DAT file, and assign initial values to each member of the array in the .DAT file, like so:
CodeDECL REAL PosXArray[1000] PosXArray[1] = 0.0 PosXArray[2] = 0.0 PosXArray[3] = 0.0 ... PosXArray[1000] = 0.0
It helps to create this in Excel, then copy&paste into the text editor you're using to make your .DAT file.
Then, write your program to index through the array and record $POS_ACT_MES.X into PosXArray[IndexNumber].
(Probably should run a quick FOR loop at the very beginning of the program to reset all the array values to 0 again. Otherwise, you're liable to get stale data left in your file)
Once you're done, you can access the .DAT file and copy&paste the new contents of the array into Excel, or whatever you're using.
Assuming you have KSS 8 (better 8.3 than 8.2) you can write a subroutine that will take all the data from the array and write it into a text file, and you can create your own format. You can look up the keywords 'krl_fwriteln' and 'krl_fputs' in the forum archives to find a lot of discussion and examples.
One caveat: I would advise against trying to write to the text file "live" -- the file-access commands aren't very fast, and can vary in execution speed enough to make your program timing unreliable. I would recommend storing to an array, then dumping the array to a text file at the end of your test program. -
Thank you Skyefire! That helps alot.
Would you happen to know how to dump the array content into a text file? May be within a program? I do not know how to code that. -
can you use forum search function? this was discussed many times