gnea / grbl

An open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on a straight Arduino
https://github.com/gnea/grbl/wiki
Other
4.09k stars 1.61k forks source link

$30, $31, $32 setup for laser #1256

Open Marmadoc opened 2 months ago

Marmadoc commented 2 months ago

I use GRBL 1.1 with laser cutter. I do not understand $30, $31 and $32 $31 and $32 is almost understandable, but $30 is not clear. Why my laser is working with 100% all time when $32? how exactly $30 number is related to PWM of laser. Some suggestion $32 to 0, some to 1, some to 255 or even 1000. Please help me to understand this. Thx in advance

breiler commented 2 months ago

And you have read this? https://github.com/gnea/grbl/wiki/Grbl-v1.1-Configuration#30---max-spindle-speed-rpm

Marmadoc commented 2 months ago

Of course I read it - and I try to understand it in relation to laser, not spindle. $30 - "if you want to set 10000rpm at 5V, program $30=10000. For 255rpm at 5V, program $30=255" But how it works if I need 100% laser power - I understand at 5V - ? is 1000rpm the same as 100% power? $31 - if set to 0 - it is 0% laser power? $32 - My Gcode use M3 and M5 - I understand it is M3-laser ON, M5 - laser OFF. If laser is ON with power set by software 50% - how it is translates to set up $30. I'm very sorry if my questions are unprofessional, but I'm not programmer. Thx in adavnce

breiler commented 2 months ago

is 1000rpm the same as 100% power?

If you are setting $30=1000 then the gcode M3 S1000 would run your laser at 100%. If you are setting $30=10000 then the gcode M3 S1000 would run your laser at 10%.

$31 - if set to 0 - it is 0% laser power?

If you are setting $31=0, then M3 S0 would run your laser at 0%. If you are setting $31=10, then M3 S10 would run your laser at 0%.

$32 - My Gcode use M3 and M5 - I understand it is M3-laser ON, M5 - laser OFF. If laser is ON with power set by software 50% - how it is translates to set up $30.

By setting $32=1 you've made your controller a laser controller which will sync the laser output with the motion. Any rapid motion commands (G0) will turn off the laser. Any motion command (G1, G2, G3) in conjunction with M3 will run the laser at the defined speed S<value>.

Farukguelle commented 2 months ago

Hey first of all it's nice to see one more Laser Engraver newbie :) As for your issue let me explain a bit about the max spindle/(laser) speed. Since GRBL is made for CNC aswell as Laser you need to translate the definition of some settings but in general it's the same for the max spindle speed. It is nothing else than the max power or your Laser. If you configure it as "1000" you need to make sure your software (LaserGRBL or Lightburn) is set to that "maximum power". If you now want for example 10% you would have a value of 100. Usually the software sends this code itself. If you set your max spindle speed to 255 it just changes the numbers you need to type in. So for 10% Laser Power you'd need to set it to 25 (as 25 is roughly 10% of 255) I personally prefer keeping it at 1000 since it's easier to calculate the values of x%.

Marmadoc commented 2 months ago

Thank you Breiler and Farukguelle very much - it is now much easier to understand that.

Marmadoc commented 2 months ago

Hi Farukguelle - could you please contact me by email aszczurowski@hotmail.com - Thank you

Farukguelle commented 2 months ago

Sure, I am glad to help. May I ask why the contact via Mail? In case you have open questions let me know and I'd be glad to help here :]

Also one more information that can't be told enough is to handle the Laser with caution. I dont know how much your Laser's output is but since it must be enough to engrave I assume it to be dangerous enough to damage the eyes if not taken proper care. If you want to test the Intensity of the Laser make sure you have it pointed to something non reflecting, not burning down or causing a fire, etc... Also always wear Laser goggles of the OD (Optical Density) specific for your Laser. I personally wear OD4+ glasses, besides from already 2 protective glasses surrounding the Laser head. I only have one pair of eyes and its just a matter of seconds if something goes wrong so please be safe.

Marmadoc commented 2 months ago

Thx for info. I thought that some mine questions are not exactly related to GRBL, so I wasn't sure if this is right place to ask. Actually my biggest problem I already solved. After your explanation - finally I understood $30 setup, but my laser didn't go for 100%. I changed to GRBL laser and it was working fine, but not in Lightburn. I find out that Lightburn has its own setup not tighten to GRBL $30. The default setup for laser max power to 255. So if grbl was set to 100, 100% in Lightburn was actually 1/4 of full power. Now I have all OK. I like to ask question about grbl controller. I have CNC arduino shield. On other group I have been told to change for belter (32bit) controller, but I do not know why. The last think - glasses - I do not have one, but my laser has protective extension to almost working surface. Thx again a lot.

Farukguelle commented 2 months ago

That's great to hear that I was able to help you guiding towards the right troubleshooting. As for the max Laser Power in Lightburn: Yeah its a setting spmewhere in the settings of lightburn but it seems like you solved it :] Regarding the 32 Bit Controller, I wouldn't know why, since for the basic laser engraving you won't need anything more.

I personally run it on a self designed Mainboard PCB with the same controller as the Arduino and some silent stepper drivers. I once was planning on writing some code to make it read G Codes from a SD card and show me the result on a Display but I am already working on some projects which made me focus on them rather than the already functioning Laser.

Edit: my profile picture was engraved with the same mainboard as I use now (altho a newer version is on its way) and I think it looks totally decent for a DIY Laser engraver. I might also upload the Gerber files and everything around it in the future. Especially since the silent stepper drivers (TMC2208) do a perfect job.

Marmadoc commented 2 months ago

Thank You. I didn't close this because I have one more problem to understand. As laser - laser is connected to Z axis and $32 = 1. If it is CNC Z axis works Up/Down and spindle is attached to spindle pins on CNC shield. I use my machine also as a plotter. In this case Z axis works as pen Up/Down but I need modified version of GRBL (for z axis) How it all is related to PWM? Can I use regular GRBL and control servo or stepper by Z axis? Can you help me in this matter?

Farukguelle commented 2 months ago

If I understand it correctly you want to add a servo motor in order to change the Knife's direction since the sharp edge is on one side, is that the issue? If so you'd need to replace a digital pin with a function that changes it's value depending on the DIR and STEP pins for the x and y axis (Digital Pin 5 and 6). The function is really dependant on your hardware design though as it will also decide which values to choose for having the knife straight to the front or any other direction.

Marmadoc commented 2 months ago

No exactly. It is not for knife. It is for pen plotter. Pen plotter must lift the pen and lower the pen. Mechanically it is done by Stepper motor or servo motor. If the stepper motor is used it is controlled by Z driver on CNC shield. In case of the servo motor - it is controlled by Z+ axis (on CNC shield) - but in this case modified GRBL is used. I know it is related to PWM - but do not know how. What is different between PWM used by Z+ for laser and PWM used by Z+ for servo motor.

lalo-uy commented 2 months ago

Laser PWM goes fron 0 to 100% Servo motors use a narrow and time specific range.

https://naylampmechatronics.com/img/cms/Blog/tutorial%20servo/se%C3%B1al%20pwm%20servomotor,%20tiempos.PNG

The pen may need less tha 180 degrees travel.

Maybe PWM and Gcode may be tunned to get it.

El El vie, 20 set. 2024 a la(s) 10:53, Marmadoc @.***> escribió:

No exactly. It is not for knife. It is for pen plotter. Pen plotter must lift the pen and lower the pen. Mechanically it is done by Stepper motor or servo motor. If the stepper motor is used it is controlled by Z driver on CNC shield. In case of the servo motor - it is controlled by Z+ axis (on CNC shield) - but in this case modified GRBL is used. I know it is related to PWM - but do not know how. What is different between PWM used by Z+ for laser and PWM used by Z+ for servo motor.

— Reply to this email directly, view it on GitHub https://github.com/gnea/grbl/issues/1256#issuecomment-2363796325, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACXBW4N3LM73FLBUH7TANV3ZXQSGXAVCNFSM6AAAAABN5RJU4CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRTG44TMMZSGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Marmadoc commented 1 month ago

If laser is connected to Z+ on CNC shield - it is adjusted by voltage. 0% = 0V 100%=12V (laser is 12V) $32=1 So in this case it is nothing with PWM. If Servo motor is connected to Z+ $32=0 this GRBL 1.1 doesn't work. I think it is no other way but use modified GRBL software - or instead of servo use Stepper motor

lalo-uy commented 1 month ago

You can setup for pwm and modify G-code to send M3 xxx for PenUp and M3 yyy for PenDown. Just find xxx and yyy for the desired angles in the servo. Need PWM freq of 50hz aprox.

El El lun, 23 set. 2024 a la(s) 14:13, Marmadoc @.***> escribió:

If laser is connected to Z+ on CNC shield - it is adjusted by voltage. 0% = 0V 100%=12V (laser is 12V) $32=1 So in this case it is nothing with PWM. If Servo motor is connected to Z+ $32=0 this GRBL 1.1 doesn't work. I think it is no other way but use modified GRBL software - or instead of servo use Stepper motor

— Reply to this email directly, view it on GitHub https://github.com/gnea/grbl/issues/1256#issuecomment-2368887912, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACXBW4NFQ2E4T5MHHSXS3WDZYBD33AVCNFSM6AAAAABN5RJU4CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRYHA4DOOJRGI . You are receiving this because you commented.Message ID: @.***>

Marmadoc commented 1 month ago

I'm still learning and trying. Now I like to ask about $31 - minimum S value for minimum (Lightburn). I read that it could be 0 or 5. I'm not sure if I'm right when I set it to 5 for my laser/engraver. Again thx in advance