Vehicle Position Log

Moderators: TomKerekes, dynomotion

Post Reply
Snyggis
Posts: 28
Joined: Thu May 10, 2018 4:04 am

Vehicle Position Log

Post by Snyggis » Mon Mar 20, 2023 5:32 pm

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

User avatar
TomKerekes
Posts: 2566
Joined: Mon Dec 04, 2017 1:49 am

Re: Vehicle Position Log

Post by TomKerekes » Mon Mar 20, 2023 7:54 pm

Hi Scott,

That should be possible. You would need to supply much more detail. Do you know how to program?
Regards,

Tom Kerekes
Dynomotion, Inc.

Snyggis
Posts: 28
Joined: Thu May 10, 2018 4:04 am

Re: Vehicle Position Log

Post by Snyggis » Tue Mar 21, 2023 8:14 pm

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);
}
}

User avatar
TomKerekes
Posts: 2566
Joined: Mon Dec 04, 2017 1:49 am

Re: Vehicle Position Log

Post by TomKerekes » Tue Mar 21, 2023 9:30 pm

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
Regards,

Tom Kerekes
Dynomotion, Inc.

Snyggis
Posts: 28
Joined: Thu May 10, 2018 4:04 am

Re: Vehicle Position Log

Post by Snyggis » Thu Mar 23, 2023 6:59 pm

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

User avatar
TomKerekes
Posts: 2566
Joined: Mon Dec 04, 2017 1:49 am

Re: Vehicle Position Log

Post by TomKerekes » Thu Mar 23, 2023 10:42 pm

Hi Scott,

See also here and here.

Did you see the SimpleConsole example?
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply