Advanced Search

Search Results (Searched for: )

  • kb0thn
  • kb0thn
Yesterday 11:31

Laser power scaling based on speed and direction

Category: HAL Examples

Much thanks to iforce2d for this implementation and write-up. I just deployed a slightly tweaked version of it to my 4x10' router that has a 40 watt laser as second spindle. 

I had to modify the component to force zero power output when there was no motion. It looks like the original first line of code can result in a NaN and then my machine was ending up with a 50% PWM output in that state. So I force NaN to zero. That worked okay in my testing at a fixed z height. But when running an actual program I retract Z between parts and I was finding that Z only motion was leaving the laser stuck on. So now I also force zero power output when X and Y motion are essentially zero.
component aprs_laserreg "";

pin in   float inpower    "Desired laser power at constant speed";
pin in   float reqspd    "Requested speed, connect to motion.requested-vel";
pin in   float curspd    "Current speed, connect to motion.current-vel";
pin in   float velx    "Current speed x component, connect to joint.0.vel-cmd";
pin in   float vely    "Current speed y component, connect to joint.1.vel-cmd";
pin in   float velz    "Current speed y component, connect to joint.1.vel-cmd";
pin in   float share    "Fraction of power given to pure Y movement, eg. 0.6";
pin out  float outpower "Scaled output laser power";

function _ fp "Update the laser power";

license "GPL";

;;

#include <math.h>

FUNCTION(_) {
	outpower = inpower * (curspd / reqspd);
	    
	float angle = atan2(fabs(velx), fabs(vely));  // angle away from y in radians
	float horz = angle / (0.5*M_PI);          // 1 when moving perfectly along x axis
	outpower *= share + (1-share) * horz;

	if ( outpower > inpower )
		outpower = inpower;        
	if ( outpower > 100 )
		outpower = 100;        
	if ( ( fabs(velx)<1e-6 && fabs(vely)<1e-6 ) || isnan(outpower) || outpower < 0 )
		outpower = 0;

}

I use a bunch of MESA cards including a 7I77 and a 7I76. And then some additional IO boards linked via serial. I never figured out how to get a hardware PWM output. So I am using software PWM for driving the laser. Here are the relevant sections of my custom.hal file showing how it all goes together:
# laser engraver
# software PWM
loadrt pwmgen output_type=0
addf pwmgen.update      servo-thread
addf pwmgen.make-pulses servo-thread # should be base-thread
setp pwmgen.0.enable TRUE
setp pwmgen.0.scale 65535

# based on https://forum.linuxcnc.org/47-hal-examples/54073-laser-power-scaling-based-on-speed-and-direction
loadrt lincurve personality=2
loadrt aprs_laserreg # for some reason the component gets renamed to aprs-laserreg (ie changes _ to -)

addf lincurve.0         servo-thread
addf aprs-laserreg.0    servo-thread # I don't seem to have a base-thread. I think because it is MESA


# Laser power mapping (0-100 -> 0-65535)
setp lincurve.0.x-val-00 0
setp lincurve.0.y-val-00 0

setp lincurve.0.x-val-01 100 
setp lincurve.0.y-val-01 65535 

net laser-requested-speed      motion.requested-vel    => aprs-laserreg.0.reqspd
net laser-current-speed        motion.current-vel      => aprs-laserreg.0.curspd
net laser-velx                 joint.0.vel-cmd         => aprs-laserreg.0.velx
net laser-vely                 joint.1.vel-cmd         => aprs-laserreg.0.vely
net laser-velz                 joint.2.vel-cmd         => aprs-laserreg.0.velz
setp aprs-laserreg.0.share     1.0 

net laser-percent              spindle.1.speed-out      => aprs-laserreg.0.inpower
net laser-regulated-percent    aprs-laserreg.0.outpower => lincurve.0.in
net laser-65535                lincurve.0.out           => pwmgen.0.value
net laser-pwm                  pwmgen.0.pwm             => optimat_o_laser_engraver_pwm

# second spindle we will always consider to be at speed
net laser-at-speed => spindle.1.at-speed
sets laser-at-speed true
  • Hakan
  • Hakan
Yesterday 10:59
Replied by Hakan on topic CiA 402 Folder Missing

CiA 402 Folder Missing

Category: EtherCAT

It is encoder pulses per mm, maybe your value isn't far off then.
It is suspicious if it start moving very fast. Use halshow to look at the
variables between cia402 and lcec and see if they look ok in size,
moves when they should etc.
  • Finngineering
  • Finngineering
Yesterday 09:45
Replied by Finngineering on topic Strange preview for circular arc (G2/G3)

Strange preview for circular arc (G2/G3)

Category: G&M Codes

Thank you Hannes. I made a bug report as you suggested:
github.com/LinuxCNC/linuxcnc/issues/3855

This was a real use case and a toolpath I intended to use immediately. I was trying for an hour or so, wondering how I can mess up or misunderstand such a simple command. I then gave up and made this thread some time later. I would think I had the command right from the start, just that incorrect preview threw me off. And I did have a fair bit of confidence in the preview, because I had previously used several somewhat complicated CAM generated programs, and the preview always looked fine. Well, at least I know the reason now.
  • Konstantin
  • Konstantin
Yesterday 07:57
Replied by Konstantin on topic CiA 402 Folder Missing

CiA 402 Folder Missing

Category: EtherCAT

About the cia402.0.pos-scale, I wrote 100 000 to just start with some value. My encoders are 23bit, therefore 8 388 608 pulses per motor revolution. On my current plasma machine I have a 1:10 planetary gearbox that I plan to use when I upgrade the machine motors to servo motors and LinuxCNC. The rack gear pitch diameter is 50 mm, therefore the circumference is 157.07963267949 mm. This the linear distance that the axis will travel for 1 revolution of the rack gear or 10 revolutions of the motor.

Therefore the cia402.0.pos-scale = ((encoder res * gear ratio)/distance per rev). I am not sure what value I should use for distance per rev - is it the linear distance per the rack gear revolution or the linear distance per motor revolution(that is linear distance per rack gear revolution / gear ratio)?
  • grandixximo
  • grandixximo's Avatar
Yesterday 06:52 - Today 07:44
Replied by grandixximo on topic Ethercat random jitter fix

Ethercat random jitter fix

Category: EtherCAT

It sounds like you get gravel in the servo motors from time to time.
Or you get click sounds from the motors. It repeats itself with a few or many minutes apart.
The first thing to do is to enable syncToRefClock and enable DC mode for the servos,
this will keep the servo loop in sync with the DC.

What grandixximo is doing here is fixing an effect that despite DC and servo loop are synchronized,
the two loops have been started with an undetermined/unfortunate phase between them.
The gravel sound is there all the time and it doesn't go away until linuxcnc is restarted.

Surprisingly, yesterday Sasha Ittner popped up in the PR log and mentioned he had been working
on a complete redesign of the DC system, eliminating all these problems (don't know details)
grandixximo seems to have reviewed that work and decided to adopt Sasha's work.
grandixximo will have to say himself. And if you don't know, Sasha Ittner is the author of linuxcnc-ethercat
from many (>10) years ago. 
 


After reviewing on real hardware today, I found my original PR works better than what Sascha Ittner did in his repo, I reverted back to the original state before I started reviewing Sasha's work.
If anyone wants to help me test, I'd love feedback on the code in my repo, because for me this is what works.
github.com/grandixximo/linuxcnc-ethercat
But I need more data from other testers.
To prove the system works, you should get grinding noise, if you set sync0shift of your drive to be half your max servo latency, open halscope and scope your servo-thread and open a couple of glxgears to induce latency in the servo thread, this should induce the grinding noise, and the noise will not be anywhere else.
  • Hakan
  • Hakan
Yesterday 06:22
Replied by Hakan on topic CiA 402 Folder Missing

CiA 402 Folder Missing

Category: EtherCAT

Initcmds can be used to set a configuration at startup github.com/linuxcnc-ethercat/linuxcnc-et...er/examples/initcmds

your cia402.0.pos-scale is very large. Double-check that one.

Set a negative value for refClockSyncCycles="–1", that switches on the PLL to synchronize
servo loop with DC clock. You also have "did not sync in 5000 cycles" in dmesg. I have no
good way of fixing that, eventually the drives will sync their time though.
 
  • rodw
  • rodw's Avatar
Yesterday 05:46

current latest download of LinuxCNC V2.9.8 will not install GRUB on several PC's

Category: Installing LinuxCNC

that looks like its looking on the cd/DVD. If this is not on installation, edit your sources file to remove the CD/DVD settings
  • Konstantin
  • Konstantin
Yesterday 05:23
Replied by Konstantin on topic CiA 402 Folder Missing

CiA 402 Folder Missing

Category: EtherCAT

I talked to the manufacturer of the drives and they told me that the PDO mapping should be set in the control device on each start of the machine.

With the above mentioned configuration I tested the homing and it seems the motor find the index pulse but then it starts rotating very fast and following error is reported.

But the synchronization error is still present.
  • Marcos DC
  • Marcos DC's Avatar
Yesterday 04:30

Separating CiA402 Logic from EtherCAT (lcec): Modular Adapter + Drive Stub Valid

Category: EtherCAT

Hi @NWE,

No worries — things have been a bit busy on my side too

Over the last days I focused on validating the CiA402 logic layer in simulation using a HAL drive stub. The main pieces are behaving as expected now (PDS state machine, controlword composition, homing supervision, etc.).

I also added a small gantry supervisor component on top of the CiA402 layer to experiment with safe decouple/recouple behaviour when drives perform internal motion like CiA402 homing.

At the moment everything is running inside HAL with two simulated drives.
Next step is reconnecting this to the EtherCAT side through an adapter layer.

I'm also planning to write a small Python CLI diagnostic tool to read the HAL signals and print a quick snapshot of the CiA402 state to help with testing.

Your Lichuan drive with 4 axes in one unit is quite interesting — that could be a very good test case once the EtherCAT adapter is wired.

I might also open a separate thread later describing the small framework this is turning into and include your two drives as example adapters.

No rush at all
  • hmnijp
  • hmnijp
Yesterday 04:23 - Yesterday 04:42
Replied by hmnijp on topic motion channels for robotic atc library

motion channels for robotic atc library

Category: General LinuxCNC Questions

I saw this in a recent PR sent by Sascha Ittner:

github.com/sittner/linuxcnc/pull/70

github.com/LinuxCNC/linuxcnc/pull/3845/c...7ac47d8c5d436a843202

Description: joint_ctrl_main.c
* Standalone HAL realtime component for single-joint control.
*
* Provides: homing, keyboard jogging, jogwheel jogging, trapezoidal
* trajectory planning, following-error monitoring, limit-switch
* handling, and backlash compensation — all as a self-contained
* HAL component independent of the full LinuxCNC motion controller.
  • fts
  • fts
10 Mar 2026 03:09 - 10 Mar 2026 03:16

current latest download of LinuxCNC V2.9.8 will not install GRUB on several PC's

Category: Installing LinuxCNC

If the installation fails and you want to see what is going on, go back to "Configure the package manager."

Hit Ctrl Alt F4.

You will likely see something like the attached output scrolling down the screen. What is odd in my situation is that even with the network cable plugged in, I am able to ping the host that it claims to be unable to reach.

Hit Ctrl Alt F5, and that will take you back to the GUI where it has gone on to the GRUB installation portion and likely failed at this point.

This is an odd issue to have!
  • rock861261
  • rock861261
10 Mar 2026 02:37
Replied by rock861261 on topic El5101 Config

El5101 Config

Category: EtherCAT

any other suggestions? I can get my enc-index-c-enable to trigger once but I have to turn it on in hal each time. it will also freeze unless i connect the latch. does linuxcnc only care about the Z or does it need a/b as well
  • NWE
  • NWE's Avatar
10 Mar 2026 02:16

Separating CiA402 Logic from EtherCAT (lcec): Modular Adapter + Drive Stub Valid

Category: EtherCAT

Sorry for the late reply — I was a bit busy the last days.


 

Same here. It'll be several more days till I get back to this project.
  • dbtayl
  • dbtayl
10 Mar 2026 01:27
Replied by dbtayl on topic Spindle Motor Advice

Spindle Motor Advice

Category: Milling Machines

Definitely check the torque curve on whatever motor you want to use, DMM or otherwise. Also: inertia mismatch between the spindle and motor is a thing. I think I ran into that when I initially tried to use a smaller motor, but hard to tell amongst my other tuning issues.

I've got the 1 KW 86mm motor (86M-DHT-A6MK1) on my baby BT30 machine (~14x8x10 XYZ travels and ~500 lbs, IIRC). It's geared ~1:1.5 (motor:spindle), so I can go up to ~7500 RPM at the spindle. After finally getting the tuning right (see below), I'm still finding where the limits actually are, but:

Aluminum: Have gone up to ~3 cubic inches/minute, with 1/4" and 3/8" tools. Haven't had issues.

Mild steel: No issues. I don't remember hard numbers for anything aside from drilling a couple holes in 1018 steel with a 6mm carbide drill. 5000 RPM, ~20 IPM, no problem.

Stainless: I've cut 304 and 17-4 H925. Both cut without issue. I don't remember MRRs for either.

Hardened steel: I modified a screwless vise body, which is probably ~60HRC. Mix of 1/4 and 3/8 tools IIRC, cut fine, albeit with light cuts.

All of the cutting I've done has been within the motor's "continuous" operation power range, per HSMAdvisor (well worth the price, IMO). Just about all of my non-finishing operations are HSM toolpaths, so I can't really comment on slotting.

This may also be of interest for tuning a DMM DYN4: www.forum.linuxcnc.org/38-general-linuxc...dle-servo-tuning-tip
  • rodw
  • rodw's Avatar
09 Mar 2026 23:00

current latest download of LinuxCNC V2.9.8 will not install GRUB on several PC's

Category: Installing LinuxCNC

I've recently cloned and built the linuxCNC live builder and created and installed a couple of ISO's without drama. If there are issues with Grub, I suspect I will be due to uefi/secure boot. This is outside of control in our ISO as its pure Debian! But then again Debian 13 has good uefi support.Try and disable it in your BIOS.

The only other issue I had was not finding a couple of obsolete firmware modules sometimes which broke the build process.
firmware-b43-installer
firmware-b43legacy-installer

Apparently, these are a wrapper around a download from flakey servers that have a history of failing. This broke the build process. I just deleted them. There are a number of other very old and probably obsolete Debian non-standard firmware drivers that seem to have been carried over from old builds which I suspect could also be removed.
Displaying 46 - 60 out of 18311 results.
Time to create page: 0.451 seconds
Powered by Kunena Forum