synthetos / g2

g2core - The Next Generation
Other
622 stars 296 forks source link

First pass at laser control including dynamic power control #431

Open mhlong10 opened 4 years ago

mhlong10 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

My comment in https://github.com/synthetos/g2/issues/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).

justinclift commented 4 years ago

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. :smile:

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. :grin:

tomashx commented 2 years ago

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

mhlong10 commented 2 years ago

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

kbrown73 commented 4 months ago

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!