Page 1 of 1
Vehicle Position Log
Posted: Mon Mar 20, 2023 5:32 pm
by Snyggis
Greetings,
I am using a trying to make a live serial or ethernet stream displaying the current position for the 0 Axis on my machine. Does anyone know if this is possible?
Thanks,
Scott
Re: Vehicle Position Log
Posted: Mon Mar 20, 2023 7:54 pm
by TomKerekes
Hi Scott,
That should be possible. You would need to supply much more detail. Do you know how to program?
Re: Vehicle Position Log
Posted: Tue Mar 21, 2023 8:14 pm
by Snyggis
Hi Tom,
I think I figured out how to make a separate application send the data from a text file. I just need to make a user program that will poll the axis position and write it to a text file every 0.1 seconds. It has to overwrite the existing data, not append.
Does this look correct?
#include "KMotionDef.h"
#define T 0.1
main()
{
for (;;) // loop forever
{
double PO,T0,CurTime;
FILE *f=fopen("C:\\Wave Position\\Current.txt","wt"); //Open TXT file
T0=Time_sec(); //Take time stamp
while((T0+T)>Time_sec()); //Wait to sample position
PO = ch0->Position; //Sample position
printf("%f",PO); // Write value to disk
fclose(f);
}
}
Re: Vehicle Position Log
Posted: Tue Mar 21, 2023 9:30 pm
by TomKerekes
Hi Scott,
I think you might have problems synchronizing the PC and KFLOP. If one is writing and the other is reading the same file at the same time things can get corrupted. I think this would also use a lot of command bandwidth to create, write, and close a file every 0.1 seconds.
I think a better approach would be to have your PC App poll the Axis position itself using a script command "PosX" where X is the axis number. The WriteLineReadLine function can be used to send the command and receive the response. See the SimpleConsole Example.
HTH
Re: Vehicle Position Log
Posted: Thu Mar 23, 2023 6:59 pm
by Snyggis
Tom,
Could you give me a bit more detail on the script command? Is that something that can be done from the command prompt? I have mainly worked with C programs on the KFlop side of things.
Scott
Re: Vehicle Position Log
Posted: Thu Mar 23, 2023 10:42 pm
by TomKerekes
Hi Scott,
See also
here and
here.
Did you see the SimpleConsole example?