”emcmotController()“

More
10 Mar 2015 20:25 #56616 by socrassi
Hi:
I'm reading the source code of the LinuxCNC.



As showed above, the function emcmotController() is called at regular intervals,..But i cannot find the caller loop anywhere..

is there anyone knowing where's the caller loop to emcmotController()???


Best regards.
Attachments:

Please Log in or Create an account to join the conversation.

More
10 Mar 2015 21:22 #56623 by andypugh

is there anyone knowing where's the caller loop to emcmotController()???


It is called by the realtime system in the servo thread.

If you look in your HAL config you will see (typically)
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES

Which calls the module specified in the INI file [EMCMOT] section every SERVO_PERIOD.

(This is actually a bit untidy, as really emcmot has no business _starting_ the realtime threads)
The following user(s) said Thank You: socrassi

Please Log in or Create an account to join the conversation.

More
10 Mar 2015 21:23 #56624 by dgarrett
$ 	find . -type f -iname '*.c' -exec grep -H emcmotController {} \;
./emc/motion/control.c:*   emcmotController() is the main loop running at the servo cycle
./emc/motion/control.c:  emcmotController() runs the trajectory and interpolation calculations
./emc/motion/control.c:void emcmotController(void *arg, long period)
./emc/motion/motion.c:    retval = hal_export_funct("motion-controller", emcmotController, 0	/* arg
$ halcmd show funct
Exported Functions:
Owner   CodeAddr  Arg       FP   Users  Name
...
 00021  b734d943  00000000  YES      1   motion-command-handler
 00021  b7350979  00000000  YES      1   motion-controller
 ...

see motion.c init_threads()
The following user(s) said Thank You: socrassi

Please Log in or Create an account to join the conversation.

More
11 Mar 2015 07:25 #56657 by socrassi
Thank you.

There's some stuff i cannot understand.

Is there no codes written to explain the loop caller to emcmotController() ?
or just uses a "loadrt"? how do the "loadrt" work??

is there no relation with the function of init_threads() or hal_export_funct() in motion.c?

Please Log in or Create an account to join the conversation.

More
11 Mar 2015 15:54 #56661 by andypugh

Is there no codes written to explain the loop caller to emcmotController() ?
or just uses a "loadrt"? how do the "loadrt" work??


That is the whole basis of the Realtime system.

Consider a simple HAL component:

git.linuxcnc.org/gitweb?p=linuxcnc.git;a...24c4e0800617;hb=HEAD

This is a very short comp that doesn't do anything that needs to be done any more, but makes a simple example.

Line 199 contains a call to "hal_export_funct()" which defines "update_supply()" as a realtime function.

Then, in the HAL file "loadrt update_supply" adds a pointer to the "update_supply()" function to the calling list.

When the realtime system is started then exactly every servo-period every function in the calling list is run once in strict sequence

So there isn't an outer-loop as such. It is more like an interrupt-driven system, with time-based interrupts.

Please Log in or Create an account to join the conversation.

More
11 Mar 2015 18:09 #56664 by socrassi
Thank you. I see. You are so enthusiastic.
There are two "addf .. to servo thread' in the *.hal file after the "loadrt" sentence..That’s where the emcmotController () function added to the servo thread.

Regards.

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum