Hi Curtis,
There isn't a simple way to have one Program load and execute another Program into another Thread as it isn't normally necessary.
Combine the two loops into a single loop at the end of your INIT program.
Regards
I have a scenario where my INIT program is in thread 1 and a "servo alarm/emergency stop" program is in thread 2. How would i go about running the program in thread 2 after my INIT program is ran in thread 1? For example, is there a way to call and run a C program at the end of my INIT file?
I have attached my INIT file (thread 1) and the ESTOP thread 2 program. The latest approach we have been trying is through a global persist variable but It just wont seem to work. There must be a simpler solution.
Any help would be appreciated,
Thanks.
-Curtis
ps. here is a video of what the kflop is powering: https://photos.app.goo.gl/ac2uA86gZTNDMDj73
Similar Threads:
Hi Curtis,
There isn't a simple way to have one Program load and execute another Program into another Thread as it isn't normally necessary.
Combine the two loops into a single loop at the end of your INIT program.
Regards
Regards
TK http://dynomotion.com
After some further research, I found this:
So I would presume that I could use void StartThread(int thread) in thread1 to call thread2.// M U L T I - T H R E A D S U P P O R T
// user threads are numbered 1 .. n
void StartThread(int thread); // starts a downloaded program at it's entry point
void PauseThread(int thread); // stops a thread from executing
int ResumeThread(int thread); // resumes a tread after a pause
void ThreadDone(void); // call to terminate current thread
extern int CurrentThread; // current thread that is/was executing 0 = Pri 1-7 = User Threads
Does this sound right? or is there a better way?
Hi Curtis,
StartThread() will allow you to start a Program in another Thread but the Program must be first somehow loaded into that Thread.
Its better to use the method I described in my previous post.
Besides running two User Threads would slow down the response and consume more DSP resources unnecessarily.
Regards
Regards
TK http://dynomotion.com
Thank you for your explanation,
so my plan would have been to have an ESTOP program and a soft limits program load into threads 2 and 3 on powerup. They would be started from my INIT in thread1. But I hear what your saying and your approach sounds more logical. I suppose I was trying to make minimal changes to my INIT file and I found it easier to debug with separate C programs. Is it the common approach for people to incorporate soft limits, E-stop etc.. into their INIT file?
Hi Curtis,
Yes it is common to service everything that need continous service in one loop. You can still debug as separate Threads if you wish but after they are working merge into the INIT Program Thread.
HTH
Regards
Regards
TK http://dynomotion.com
Hello. I also have a thread question. The Kflop controller supports 7 threads, that is, simultaneous start of 7 independent programs with equal priorities downloaded from C files, if it is necessary to use more than 7 programs, then some are deleted and others are written in their place? All possible variants of the CNC operation should be provided by only 7 programs, or you can write several programs in one thread and connect the necessary ones depending on the situation.
Completed, what is the purpose of the Var parameter in the Tool Setup Screen / User button?
Hi Lotreck,
You can download and execute any number of different C Programs. The 7 Thread limitation (+ 1 System Thread) limits you to having 7 User programs running at the same time.I also have a thread question. The Kflop controller supports 7 threads, that is, simultaneous start of 7 independent programs with equal priorities downloaded from C files, if it is necessary to use more than 7 programs, then some are deleted and others are written in their place? All possible variants of the CNC operation should be provided by only 7 programs, or you can write several programs in one thread and connect the necessary ones depending on the situation.
See also: KMotion/KFlop Multi-tasking
Note that each running User Thread reduces the cpu time available for the KFLOP System Thread so it is best to have a minimum number of Threads active. If a number of things need to be continuously serviced it is usually possible to service them all in a single loop in a single Thread. See also:
KFLOP C Programs - Dynomotion
Some Actions need to pass one or more parameters. The Var Setting determines which KFLOP persist.UserData Variables the parameters will be consecutively placed into before Executing the C Program. For Example M6 Tool Change Action passes the Tool Slot and Tool ID values into persist.UserData[Var] and persist.UserData[Var+1].what is the purpose of the Var parameter in the Tool Setup Screen / User button?
MCodes can pass PQR parameters. See:
MCodes with Parameters
If no parameter is associated with the particular Action then the Action Index is placed into the Variable specified by Var. This can sometimes be useful to have a Single C Program handle multiple Actions where the C Program can use the Action Index to determine which Action was invoked.
HTH
Regards
Regards
TK http://dynomotion.com
[QUOTEAlthough C Programs can be Flashed to KFLOP memory so they will be present in KFLOP Memory on Power up this is not normally recommended and not usually required. KFLOP normally powers up with no C Programs in Memory. Programs can be compiled, downloaded, and executed dynamically in Threads by Applications at run time. They do not need to be pre-loaded (or Flashed) into KFLOP Memory.][/QUOTE]
I correctly understood that it is not necessary to load each C-program into flash user memory, just specify the thread and click "Save, Compile, Download, Run" button?
Hi Lotreck,
Well I'm not sure exactly what you mean. To run a Program it does not need to be Flashed into KFLOP's Flash memory. It can just be loaded and executed by the PC.I correctly understood that it is not necessary to load each C-program into flash user memory, just specify the thread and click "Save, Compile, Download, Run" button?
Normally that Button and KMotion.exe is not used at all in your final application. KMotion.exe is only used while developing and testing. Instead a Button or MCode or other Action in KMotionCNC will automatically load and execute the necessary C Program when it is needed.
HTH
Regards
Regards
TK http://dynomotion.com
Is it necessary to load the axis configuration program into flash memory?
After installing the program Kmotion, to each thread is already connected some program, how to remove these not necessary programs, so that they do not strain the controller? Is it enough to just delete them from the file C: \ KMotion433\KMothionData\Threads or do we need some more manipulations?
Hi Lotreck,
It seems I wasn't clear in my last post. No. Programs do not need to be Flashed. Assign it to a User Button in KMotionCNC so it will be downloaded and executed when the button is pushed.Is it necessary to load the axis configuration program into flash memory?
Firstly the programs in the KMotion.exe Program Edit Windows are not necessarily in KFLOP. The edit windows on the PC and the memory in KFLOP are two different things.After installing the program Kmotion, to each thread is already connected some program, how to remove these not necessary programs, so that they do not strain the controller?
Secondly there is no need to remove programs from KFLOP. If they are not executing then the do not do anything or use any cpu resources. Whenever a new program is downloaded it will overwrite any previous program.
HTH
Regards
Regards
TK http://dynomotion.com
Thank you very much for your answers.