How to Optimize GRBL Firmware on the Longer Ray5 20W
Introduction
The Longer Ray5 20W ships with a GRBL-based firmware optimized for laser engraving out of the box, but there is significant untapped performance hidden in the controller. Custom GRBL parameters, firmware updates, and performance tuning can improve engraving speed, cut quality, and motion smoothness. This guide covers everything firmware-related for the Ray5: stock firmware updates, custom GRBL parameter optimization, backup and restore procedures, and the settings that make the difference between good and professional-grade output.
What You Need
- Longer Ray5 20W powered on and connected via USB-C cable
- Computer running Windows 10/11, macOS, or Linux
- LightBurn or LaserGRBL installed
- GRBL 1.1f or 1.1h firmware binary (from Longer or compiled custom)
- Arduino IDE or XLoader (for flashing)
- Terminal access (LightBurn console or LaserGRBL)
- USB-C data cable (the included cable may be charge-only; verify data capability)
- CH340 driver installed on your computer
Step 1: Identify Your Current Firmware Version
- Connect the Ray5 to your computer via USB-C.
- Open LightBurn and connect to the laser (choose the correct COM port).
- Open the Console tab and type: $I then press Enter.
- The controller responds with version information. Look for:
- VER: GRBL version number (e.g., 1.1f, 1.1h)
- OPT: Compile options showing enabled features
- Longer Ray5 20W specific identifier in the version string
Document this output. If a flash goes wrong, you need to know your baseline.
Step 2: Read and Document All GRBL Parameters
Before changing anything, back up your complete configuration.
- In the LightBurn console, type: $$ and press Enter.
- The controller dumps all stored EEPROM parameters ($0 through $132+ depending on version).
- Copy this entire output and save it to a text file named Ray5_GRBL_Backup_YYYYMMDD.txt.
Critical: This backup is your recovery path. If a parameter change ruins performance, you can restore every value individually.
Step 3: Stock Firmware Update Procedure
Longer periodically releases firmware updates that fix bugs, add features, or improve motion planning. Always update before reporting problems or doing custom tuning.
Method A: XLoader (Windows, Easiest)
- Download the official firmware .hex file from Longer's support site.
- Download XLoader from the GRBL wiki or Arduino site.
- Close LightBurn and any other software that may hold the COM port.
- Open XLoader:
- Select the .hex file
- Set device to Uno(/w GRBL)
- Select the correct COM port (check Device Manager if unsure)
- Set baud rate to 115200
- Click Upload. The status bar fills and reports bytes uploaded.
- When complete, open LightBurn and verify with $I that the new version is active.
Method B: Arduino IDE (All Platforms)
- Install Arduino IDE from arduino.cc.
- Add GRBL as a library: Sketch > Include Library > Manage Libraries > search GRBL.
- Connect the Ray5 via USB-C.
- Select Tools > Board > Arduino Uno.
- Select the correct COM port under Tools > Port.
- Open File > Examples > GRBL > grblUpload.
- Click Upload. The IDE compiles and flashes the firmware.
After flashing: The EEPROM is reset to GRBL defaults. You must restore Ray5-specific parameters (Steps/mm, max rates, accelerations) from your backup or re-tune from scratch.
Step 4: Optimize GRBL Parameters for the Ray5 20W
These parameters are specific to the Longer Ray5 20W hardware (LEKN-CZ V2.0 board, NEMA 17 steppers, M8 threaded rod Z-axis). Enter each in the LightBurn console with the format $NNN=VALUE then press Enter. The controller confirms with OK.
Step Calibration ($100, $101, $102)
- $100=160.000 (X steps/mm for GT2 belt, 20T pulley, 1/16 microstepping)
- $101=160.000 (Y steps/mm, same as X)
- $102=400.000 (Z steps/mm for M8 threaded rod)
To verify: jog 100 mm in X and Y, measure with calipers. If actual movement is 99.8 mm, adjust: new_value = (commanded_distance / actual_distance) * current_value. Repeat until accurate within 0.1 mm over 100 mm.
Maximum Feed Rates ($110, $111, $112)
- $110=12000.000 (X max rate, mm/min — Ray5 can reliably do 200 mm/s in rapid moves)
- $111=12000.000 (Y max rate)
- $112=1000.000 (Z max rate, conservative for the threaded rod)
Accelerations ($120, $121, $122)
- $120=3000.000 (X acceleration, mm/sec^2 — higher = faster direction changes but more vibration)
- $121=3000.000 (Y acceleration)
- $122=200.000 (Z acceleration)
Optimal acceleration note: For fine engraving with detailed images, reduce to 2000 mm/sec^2 for smoother motion. For cutting jobs where speed matters, 4000 mm/sec^2 works if the machine is on a solid surface.
Junction Deviation ($11)
- $11=0.010 — Controls how much the machine slows for direction changes. Lower = tighter corners but slower overall. Higher = faster but rounded corners. 0.010 is a good balance for laser work.
Arc Tolerance ($12)
- $12=0.002 — How closely GRBL follows arcs with line segments. Lower = smoother arcs but more G-code data. 0.002 mm is sufficient for laser work.
Step Pulse and Idle Delay ($0, $1)
- $0=10 — Step pulse width in microseconds. 10 us is stable for the Ray5's drivers.
- $1=25 — Step idle delay in milliseconds. Motors hold position for 25 ms after movement stops, then de-energize. This prevents overheating during long engraves.
Step Port Invert Mask ($2)
- $2=0 — Leave at 0 unless you have reversed motor wiring. If a motor runs backward, change $3 instead.
Direction Port Invert ($3)
- $3=4 — Binary mask for motor direction. If an axis moves the wrong way after flashing, toggle the bit: 1=X, 2=Y, 4=Z. Add values for multiple axes.
Homing Cycle ($22, $23, $24, $25, $26, $27)
- $22=1 — Enable homing cycle (1=on, 0=off)
- $23=3 — Homing direction invert mask (3 = invert X and Y to home toward front-left)
- $24=50.000 — Homing feed rate (slow approach), mm/min
- $25=1500.000 — Homing seek rate (fast approach), mm/min
- $26=250 — Homing debounce delay in milliseconds
- $27=1.000 — Homing pull-off in mm (backs off 1 mm after hitting the limit switch)
Spindle/Laser Mode ($30, $31, $32)
- $30=1000 — Maximum spindle speed (maps to 100% laser power in LightBurn)
- $31=0 — Minimum spindle speed (0% power)
- $32=1 — Laser mode enabled (1=laser, 0=spindle). Critical: Laser mode must be on for clean raster engraving. With $32=0, GRBL pauses at power changes, leaving dark dots.
Step 5: Laser Power Calibration via Firmware
The Ray5's 20W diode output may not match LightBurn's 0-100% scale linearly. You can verify and calibrate this through GRBL parameters.
- In LightBurn, create a power test: a series of lines at 10%, 20%, 30%... 100% power.
- Engrave on black-anodized aluminum or tile at constant speed (1000 mm/min).
- Examine the result. If 10% is barely visible and 50% is already near-white, the response is non-linear.
Adjusting $30 for linear response:
- If the laser reaches full power at 70% in LightBurn, lower $30 proportionally: $30 = 1000 * 0.70 = 700
- Re-test and fine-tune. The goal is 100% in LightBurn = maximum physical laser output with visible gradation across the range.
Step 6: Enable and Test Limit Switches
- Verify your Ray5 has limit switches installed on X and Y (stock on newer units, optional on early units).
- Type $21=1 to enable hard limits.
- Trigger each limit switch manually by hand while the machine is idle. The controller should alarm and require a reset ($X to clear alarm, then $H to home).
- If triggering a limit causes no alarm, check wiring or enable soft limits ($20=1) as a fallback.
Soft Limits ($20)
- $20=1 — Enable soft limits (software boundary protection)
- $130=400.000 — X max travel in mm (Ray5 400x400 work area)
- $131=400.000 — Y max travel in mm
- $132=40.000 — Z max travel in mm
Step 7: Advanced Tuning - Dynamic Laser Power and Scanning Offset
Scanning Offset Adjustment (LightBurn Setting)
At high speeds, the laser head may lag slightly behind the commanded position due to mechanical inertia. This causes the engraved image to shift slightly on reverse passes. Fix this in LightBurn:
- Edit > Machine Settings > Scanning Offset Adjustment
- Engrave a test pattern of 1 mm vertical lines at various speeds (100, 200, 300, 400 mm/s)
- Measure the offset between forward and reverse pass lines at each speed
- Enter the measured offset values for each speed in the table
- LightBurn automatically compensates by shifting the laser timing
Global Offset (Bi-directional Lettering Test)
If text appears doubled or shadowed on bi-directional fills:
- Create a grid of small text at 100 mm/s, 200 mm/s, 300 mm/s
- Measure the gap between forward and reverse strokes
- Enter the offset in Edit > Device Settings > Global Offset
Step 8: Backup and Restore Complete Configuration
To backup:
- Connect to the Ray5 in LightBurn
- Open Console, type $$ and press Enter
- Copy the complete parameter dump to a text file
- Save with a descriptive name: Ray5_GRBL_Optimized_2026-05-07.txt
To restore:
- Open your backup file
- For each line ($100=160.000, etc.), type the complete line into the console and press Enter
- Verify by running $$ again and comparing to your backup
Batch restore via macro:
In LightBurn, you can create a macro button that pastes all parameters at once. Go to Tools > Macros, create a new macro named Restore, paste your complete $$ output, and save. Clicking the macro restores all settings in seconds.
Step 9: Firmware Recovery - If the Flash Goes Wrong
If the controller becomes unresponsive after a bad flash:
- Power off the Ray5 completely.
- Disconnect USB.
- Press and hold the controller's reset button (small button on the LEKN-CZ board, may require removing the bottom cover).
- While holding reset, connect USB and power on.
- Release reset. The controller enters bootloader mode.
- Flash the known-good firmware using XLoader or Arduino IDE.
- After successful flash, restore parameters from backup.
Tips for Firmware Stability
- Document every change: Keep a log of which parameter you changed, the old value, and the new value. This lets you undo one change without reverting everything.
- Change one parameter at a time: If you change five things and performance degrades, you cannot identify the culprit.
- Reboot after major changes: Some GRBL parameters only take full effect after a controller power cycle. Power off, wait 5 seconds, power on.
- Never flash during a job: Interrupting a flash bricks the controller. Close LightBurn before running XLoader or Arduino IDE.
- Verify checksums: Download firmware from official sources only. Verify MD5 or SHA256 checksums when available.
- Keep stock firmware: Before flashing custom firmware, save the stock .hex file. If custom firmware has issues, you can always revert.
Conclusion
The Longer Ray5 20W is capable of significantly better performance than its stock configuration suggests. By optimizing GRBL parameters for its specific hardware, calibrating laser power response, enabling limit switches, and compensating for high-speed scanning offsets, you transform the Ray5 from a stock laser into a precision instrument. Document your configuration, back up before changes, and tune incrementally. With optimized firmware, the Ray5 produces engraving quality that rivals machines costing three times as much.
Related Guides
- How to Optimize GRBL Firmware on the WolfPawn 4040 Pro
- Constant Power vs Dynamic Power (M3 vs M4) in GRBL Lasers: What It Actually Changes
- Longer Ray5 20W — Machine Reference & Connection Guide
- Speed Optimization in LightBurn — Cut Order and Travel Reduction
- Longer Ray5 20W Complete Setup Guide: Assembly, LightBurn, Focus, and First Engrave
- Longer Ray5 20W Wood Cutting and Engraving Settings: Plywood, Pine, MDF, Basswood, and Hardwoods
- Longer Ray5 20W Acrylic Cutting: Settings, Tips, and Speeds
- Longer Ray5 20W Leather Engraving: Settings and Techniques