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
Vehicle Position Log
Moderators: TomKerekes, dynomotion
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Vehicle Position Log
Hi Scott,
That should be possible. You would need to supply much more detail. Do you know how to program?
That should be possible. You would need to supply much more detail. Do you know how to program?
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Vehicle Position Log
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);
}
}
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);
}
}
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Vehicle Position Log
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
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
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Vehicle Position Log
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
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
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Vehicle Position Log
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.