No description
  • Go 69.7%
  • JavaScript 13.6%
  • HTML 8.3%
  • CSS 5.9%
  • Batchfile 2.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Laser Service df868d188c Release v1.2.2: bump version in web UI footer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 09:11:54 +01:00
cmd/service Read debug flag under lock and set it before startup 2026-10-27 09:36:42 +01:00
docs Select the program on every marking and write the text into it 2026-10-29 09:11:48 +01:00
internal Release v1.2.2: bump version in web UI footer 2026-10-29 09:11:54 +01:00
samples Initial commit: Implement CSV reading and interlock error handling 2025-11-26 12:28:42 +01:00
.gitignore Ignore dist/ and fix -debug hint in build.bat 2026-10-27 10:17:03 +01:00
build.bat Ignore dist/ and fix -debug hint in build.bat 2026-10-27 10:17:03 +01:00
CLAUDE.md Select the program on every marking and write the text into it 2026-10-29 09:11:48 +01:00
config.ini Select the program on every marking and write the text into it 2026-10-29 09:11:48 +01:00
go.mod Initial commit: Implement CSV reading and interlock error handling 2025-11-26 12:28:42 +01:00
go.sum Initial commit: Implement CSV reading and interlock error handling 2025-11-26 12:28:42 +01:00
install.bat Initial commit: Implement CSV reading and interlock error handling 2025-11-26 12:28:42 +01:00
keyence-laser-prd.md Initial commit: Implement CSV reading and interlock error handling 2025-11-26 12:28:42 +01:00
README.md Add German translation of the marking flow docs 2026-10-27 11:15:32 +01:00
uninstall.bat Initial commit: Implement CSV reading and interlock error handling 2025-11-26 12:28:42 +01:00

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

  1. Build the service (requires Go):

    build.bat
    
  2. Install as Windows service (run as Administrator):

    install.bat
    
  3. 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 ConnectionTimeout in 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.log for detailed operation logs