- Go 69.7%
- JavaScript 13.6%
- HTML 8.3%
- CSS 5.9%
- Batchfile 2.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| cmd/service | ||
| docs | ||
| internal | ||
| samples | ||
| .gitignore | ||
| build.bat | ||
| CLAUDE.md | ||
| config.ini | ||
| go.mod | ||
| go.sum | ||
| install.bat | ||
| keyence-laser-prd.md | ||
| README.md | ||
| uninstall.bat | ||
Keyence MD-X2000 Laser Control Service
A Windows service application for controlling and monitoring a Keyence MD-X2000 laser marking system via TCP/IP protocol.
Features
- Automated Marking Cycles: Triggers marking after configurable ready checks
- Real-time Status Monitoring: Continuous polling of laser status
- Web-based Control Panel: Modern web interface for monitoring and control
- Auto Error Recovery: Automatic error clearing and reconnection
- Configurable Parameters: All settings adjustable via INI file or web UI
- Windows Service: Runs as a background service with auto-start capability
- WebSocket Updates: Real-time status updates in the web interface
- Comprehensive Logging: Detailed operation and error logging
Requirements
- Windows 10/11 (64-bit)
- Go 1.21 or higher (for building from source)
- Network access to Keyence MD-X2000 laser (TCP port 50002)
Quick Start
Installation
-
Build the service (requires Go):
build.bat -
Install as Windows service (run as Administrator):
install.bat -
Access the web interface: Open your browser and navigate to
http://localhost:8080
Development Mode
To run the service in development mode without installing:
laser_service.exe -dev
How Marking Works
See docs/marking-flow.md (German: docs/marking-flow.de.md) for diagrams of where the marking text comes from
(config or CSV), how the laser program is chosen (trigger mapping, e.g. SDH1234+3 → program 0003), and the full marking cycle.
Configuration
Edit config.ini to configure the service:
[Connection]
LaserIP = 192.168.1.100 # Laser IP address
LaserPort = 50002 # TCP port (usually 50002)
ConnectionTimeout = 5000 # Connection timeout in ms
RetryAttempts = 3 # Number of reconnection attempts
[Monitoring]
PollInterval = 1000 # Status check interval in ms
RequiredReadyChecks = 10 # Ready checks before marking
EnableAutoRecovery = true # Auto-clear errors
[Marking]
MarkingDuration = 5000 # Marking cycle duration in ms
ProgramNumber = 0001 # Laser program to use
Service Management
Start Service
laser_service.exe -start
Stop Service
laser_service.exe -stop
Uninstall Service
uninstall.bat
Web Interface
The web interface provides:
- Real-time laser status display
- Manual marking trigger
- Auto mode toggle
- Error clearing
- Emergency stop
- Configuration editor
- Live log viewer
- Statistics tracking
TCP Protocol
The service communicates with the laser using these commands:
| Command | Request | Response | Description |
|---|---|---|---|
| Status Check | RX,Ready\r |
RX,OK,0\r |
0=Ready, 1=Error, 2=Busy |
| Start Marking | WX,StartMarking\r |
WX,OK\r |
Triggers marking |
| Clear Errors | WX,ErrorClear\r |
WX,OK\r |
Clears error state |
| Select Program | WX,ProgramNo=XXXX\r |
WX,OK\r |
Sets program number |
Project Structure
keyence-laser-control/
├── cmd/service/ # Main service entry point
├── internal/
│ ├── config/ # Configuration management
│ ├── laser/ # TCP client for laser communication
│ ├── monitor/ # Status monitoring logic
│ ├── marking/ # Marking cycle controller
│ └── web/ # Web server and API
│ └── static/ # Web UI (HTML/CSS/JS), embedded into the exe
├── config.ini # Configuration file
├── build.bat # Build script
├── install.bat # Installation script
└── uninstall.bat # Uninstallation script
Troubleshooting
Service Won't Start
- Check Windows Event Viewer for error messages
- Verify laser IP address and port in
config.ini - Ensure no firewall is blocking port 50002
- Run in development mode (
-dev) to see console output
Connection Issues
- Ping the laser IP address to verify network connectivity
- Check that port 50002 is open on the laser
- Verify network cable connections
- Try increasing
ConnectionTimeoutin config
Web Interface Not Loading
- Check that port 8080 is not in use by another application
- Verify the service is running in Services Manager
- Check Windows Firewall settings for port 8080
Error Codes
Common Keyence error codes:
- S021: Program Not Registered
- S029: Mark Data Request Error
- S087: 2D Code Reading Error
- 1xxx: System errors
- 2xxx: Warnings
- 3xxx: I/O errors
- 4xxx: Software errors
License
This software is provided as-is for controlling Keyence laser marking systems.
Support
For issues or questions, refer to:
- Keyence MD-X2000 manual for laser-specific information
- Windows Event Viewer for service logs
laser_service.logfor detailed operation logs