Dynomotion

Group: DynoMotion Message: 10694 From: kovkaa Date: 12/19/2014
Subject: Problem with MainStatus in C programm.
Hi All.
Why the compiler generates an error "Undefined symbol MainStatus" to the next line?

printf("ThreadActive=%d \n",MainStatus.ThreadActive);

Best regards,

Alexander Kovylkin.


Group: DynoMotion Message: 10695 From: Tom Kerekes Date: 12/19/2014
Subject: Re: Problem with MainStatus in C programm.
Hi Alexander,

MainStatus is a temporary object that is filled in with KFLOP info and uploaded to the Host PC.  It shouldn't be accessed from KFLOP as KFLOP has all the information locally.  We shouldn't have declared that.  There is a global variable called ThreadActive that indicates which Threads are running.  Use that value instead.  See below:

Regards
TK


#include "KMotionDef.h"

extern volatile int ThreadActive;  // one bit for each thread   

main()
{
    printf("ThreadActive=%d \n",ThreadActive);
}

Group: DynoMotion Message: 10696 From: kovkaa Date: 12/20/2014
Subject: Re: Problem with MainStatus in C programm.
Hi. Tom.

Tanks for advice.
I have another question. How can I stop a thread from a с program on kflop. In the list of functions is only start, pause and resume to control threads.

Best regards,
Alexander Kovylkin.
Group: DynoMotion Message: 10697 From: Tom Kerekes Date: 12/20/2014
Subject: Re: Problem with MainStatus in C programm.
Hi Alexander,

Pause will work to kill a Thread.  It is usually better to have Threads terminate themselves if possible.  Killing a Thread unexpectedly runs the risk of leaving something partially completed if the Thread was last pre-empted in the middle of doing something.

Regards
TK

Group: DynoMotion Message: 10721 From: Tom Kerekes Date: 12/23/2014
Subject: Re: Problem with MainStatus in C programm.
Hi Alexander,

KMotionDef.h and PC-DSP.h header files list all the documented functions and variables for KFLOP.  We only document things that we feel would be useful to User Programs.

VersionAndSize is a member of the temporary status structure (MAIN_STATUS) filled in and uploaded to the Host PC to inform the PC about what to expect regarding the status structure of the Version of firmware running in KFLOP.  KFLOP already knows what version it is so I don't see a need for this.  KFLOP also has random access to all status directly.  So it wouldn't really make sense to package a status structure and send the status to itself.

ThreadActive was a special case where the same symbolic name referred to two different things in two different contexts.  One was the global variable.  The other was a member of the MAIN_STATUS Structure.

HTH
Regards
TK

Group: DynoMotion Message: 10722 From: kovkaa Date: 12/23/2014
Subject: Re: Problem with MainStatus in C programm.
Hi, Tom.

Thank you for your comprehensive answer. I have another question. How can I determine from a program on or off axis at the moment? For example, If you turn off the master axis MaksFollovingError, the slave axis remains active, which leads to an overload of the servo. Perhaps it would be logical that when you turn off the master axis and slave would be switched off, and vice-versa.

Best regards,
Alexander.