Skip to content

First pass at laser control including dynamic power control#431

Open
mhlong10 wants to merge 3 commits into
synthetos:edgefrom
mhlong10:longm-laser
Open

First pass at laser control including dynamic power control#431
mhlong10 wants to merge 3 commits into
synthetos:edgefrom
mhlong10:longm-laser

Conversation

@mhlong10

@mhlong10 mhlong10 commented Nov 23, 2019

Copy link
Copy Markdown
Contributor

This is a simple set of changes which are be beginnings of my attempt at laser control. This uses a tool (tool 32 for now) to specify laser mode and M3 for immediate control and M4 for dynamic laser power based on velocity.

I'm not sure if this is the best approach but it works really well and is simple.

I've change my settings to run the PWM at 2khz and scale the power from 0 to 100% using S0 to S100. None of this is required to make this work, however the segments are run at about 1.5ms so updates to the PWM are at this rate. It doesn't make sense to have PWM at frequencies below 1/1.5ms. In fact 2khz is only slightly above nyquist... and segment times can run quicker. Here are my PWM and spindle settings:

{p1:n}
{"r":{"p1":{"frq":2000,"csl":0,"csh":100,"cpl":0,"cph":1,"wsl":0,"wsh":100,"wpl":0,"wph":1,"pof":0}},"f":[1,0,8]}
{"sr":{"stat":4}}

{sp:n}
{"r":{"sp":{"mo":2,"ph":1,"de":0,"sn":0,"sm":1000,"ep":1,"dp":0,"oe":0,"o":0,"c":0,"s":0}},"f":[1,0,8]}
{"sr":{"stat":4}}

Note - I'm new to working with this project so not sure of best process to simply show people changes. I created a PR thinking it was going to be against my fork. I don't know git that well and have never used forks before.

@giseburt giseburt self-requested a review November 23, 2019 15:25
@giseburt

Copy link
Copy Markdown
Member

This is fascinating. A pull request is the ideal way to bring this up. Thank you.

I’ll look this over as soon as I can.

@mhlong10

Copy link
Copy Markdown
Contributor Author

My comment in #422 shows a couple of pictures and a video of this running (if you stay to the very end there is a close up of the resulting laser marking - very clean).

Comment thread g2core/canonical_machine.cpp Outdated
Comment thread g2core/spindle.cpp Outdated
Comment thread g2core/spindle.cpp Outdated
@justinclift

Copy link
Copy Markdown
Member

Note - I'm new to working with this project so not sure of best process to simply show people changes. I created a PR thinking it was going to be against my fork. I don't know git that well and have never used forks before.

You've set up the PR correctly (eg from a branch of your fork, to a target branch - edge - here), so no stress. 😄

It sometimes takes people a few goes to get the hang of the forking/branching model GitHub uses, but it looks like you got it right first time around. 😁

Comment thread g2core/spindle.cpp
spinup_delay = true;
if (cm_is_laser_tool() && spindle.direction == SPINDLE_CCW) {
// Since dynamic laser mode relies on spindle override to scale
// the power, ensure it is initialize when transitioning into this state.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialize -> initialized

Comment thread g2core/spindle.cpp Outdated
// if (fabs(spindle_override - spindle.override_factor) >= 0.01) {
// Only update if the change is worth while (at least 1%)
spindle.override_factor = spindle_override;
pwm_set_duty(PWM_1, _get_spindle_pwm(spindle, pwm));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This is where I would adjust the i2c code if we were controlling a digital pot for plasma power settings.

@tomashx

tomashx commented Apr 6, 2022

Copy link
Copy Markdown

@mhlong10 this change, is it working for your CNC laser? Do you have a router also on your CNC?

@mhlong10

mhlong10 commented Apr 6, 2022

Copy link
Copy Markdown
Contributor Author

@tomashx I use the same CNC machine with a router and laser. This code has been working fine for a couple years now.

@kbrown73

Copy link
Copy Markdown

Hello @mhlong10. I've only just found this yesterday and have also read #422. Sounds like you've cracked the Da Vinci gcode for g2core laser engravers :) I'm curious if you're still using this or has there been other more "official" advancements recently?

I've recently converted my old Chinese CNC 3040Z-DQ to use Arduino Due + gShield and g2core. I've bolted a 5W diode laser head to the spindle holder as well and have hard wired the the setup electronically so that CW direction signal enables the spindle and CCW enables the laser head. Does this sound similar to your setup?

Also what is the best way of getting your changes? Your fork looks untouched for a number of years now.

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants