I've been studying the source code for the basic LinuxCNC system. One that
doesn't require external intelligent hardware to augment a 4 core 2 GHz 64 bit
processor. In other words the parallel port based system.
Perhaps someone with more experience with the system can answer a few questions?
Starting with this from the HAL file:
# Originally generated by stepconf 1.1 at Mon May 27 15:08:43 2019
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD
servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt hal_parport cfg="0 out"
loadrt stepgen step_type=0,0,0,0
The important constants come from the INI file:
[EMCMOT]
EMCMOT = motmod
BASE_PERIOD = 24000
SERVO_PERIOD = 1000000
A BASE_PERIOD value like 24,000 nanoseconds is the same as 24 Microseconds
which works out to a real time rate of almost 42kHz or in other words something
can happen every 24 uSeconds or up to 41,666.7 times per second.
Have I got that right? Is the real time component of Linux CNC running all
the tasks that are started with the loadrt with a 24uS period? In other
words all loaded "loadrt tasks" have to finish within 24uS or the system will
start to have jitter or miss events.
The following lines configure that real time task stepgen to produce our
stepping motor pulses and the values are also nanoseconds..
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 0
Both values inside the motmod and parallel port tasks appear to set it to that
value or the minimum BASE_PERIOD. Whichever is shorter. At least that is how
I interpret it.
Is that correct?
What that would mean is that although it wants a 1nS step length the reality is
the minimum period is 24uS and since a step pulse is exactly that, a pulse, the
step space is also 24uS. So that implies the fastest step rate possible is
24uS ON and 24uS OFF or 48 uS minimum period which gives a 20.833kHz stepping
rate.
For a stepping motor driver with 10uStep per step that's still pretty well
faster than it can actually turn. For a Servo motor with a 2500 line encoder
it's way too slow so a step multiplier or encoder divider would be required.
The time to change direction is probably a bit more reasonable.
setp stepgen.0.dirhold 45000
setp stepgen.0.dirsetup 45000
The 45uS I believe ends up being rounded up to the next integral BASE_PERIOD
tick so in fact 45,000 becomes 48,000 for setup and hold values.
Now the trajectory planner. Am I correct when I interpret that the trivkins
planner runs at the BASE_PERIOD rate every 24 uS but uses the SERVO_PERIOD of
1mS (1000000nS) for trajectory updating.
Once every 1mS a new velocity is calculated for each of the axis based on where
the axis is supposed to be. An example here perhaps.
To move the target point along a 45 degree angle the X and Y axis each move the
exact same distance. If the position-scale is the same for each then each will
receive a step pulse at the same time. And if their maxaccel is the same then
they will also accelerate up to that stepping rate and decelerate at the same
rate to reach the end position.
The stepgen.c file using the function make_pulses(void *arg, long period){…}
does the work to do all this.
But I've not yet figured out how the G-Code line, if X and Y are 0.000,
G01 X1.0 Y1.0 F60
turns into the stepping pulses.
The Feed Rate is 60 IPM (assuming imperial units) which is 1 inch per second.
If each axis requires 10,000 steps per inch then the stepping rate will be
10,000 steps per second.
That's a step pulse every 100 microseconds. So make_pulses() will generate
pulses along the line of
1 0 0 1 0 1 0 0 0
1
0.0000 0.000024 0.000048 0.000072 0.000096 0.000120 0.000144 0.000168
0.000192 0.000216
There's a jitter of 20uS and then 16 uS that drops by 4uS each step pulse.
BTW. This is where the external step generators based on FPGAs do so well since
they can be programmed to have a 1mHz base period clock and can be programmed
to create stepping pulses in intervals of 100 x 1uS for much less jitter.
But back to my final question for this post. Is the Servo Period the time
interval used to calculate the next motor velocity?
So the acceleration is actually based on changing the velocity every 1mS for
that 1000000nS SERVO_PERIOD value?
Thanks
John Dammeyer
"ELS! Nothing else works as well for your Lathe"
Automation Artisans Inc.
www dot autoartisans dot com
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users