-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First pass at laser control including dynamic power control #431
base: edge
Are you sure you want to change the base?
Conversation
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. |
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). |
You've set up the PR correctly (eg from a branch of your fork, to a target branch - 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. 😁 |
@@ -180,6 +180,11 @@ static void _exec_spindle_control(float *value, bool *flag) | |||
spindle.direction = control; | |||
spindle.state = control; | |||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize -> initialized
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)); |
There was a problem hiding this comment.
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.
@mhlong10 this change, is it working for your CNC laser? Do you have a router also on your CNC? |
@tomashx I use the same CNC machine with a router and laser. This code has been working fine for a couple years now. |
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! |
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}}
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.