84 lines
3.2 KiB
Markdown
84 lines
3.2 KiB
Markdown
# Sapphire ESP32 Laser Controller
|
|
|
|
A robust, web-based controller for Coherent Sapphire lasers built on the ESP32 platform. This project provides a real-time telemetry dashboard and control interface for multiple Sapphire lasers via RS232 serial communication.
|
|
|
|
## Features
|
|
|
|
- **Multi-Port Support**: Control up to 3 Sapphire lasers simultaneously (2 implemented, 1 planned).
|
|
- **Real-Time Telemetry**: Monitor power, current, temperatures (base, diode, controller), and operational status via WebSockets.
|
|
- **Interactive Control**: Set laser power levels and send raw serial commands directly from the web interface or USB serial.
|
|
- **Automatic Discovery**: Smart state machine handles connection, initialization, and fault recovery for each laser port.
|
|
- **OTA Updates**: Seamless firmware updates over-the-air using [ElegantOTA](https://github.com/ayushsharma82/ElegantOTA).
|
|
- **Responsive Web Dashboard**: Built-in HTML/CSS interface served directly from the ESP32.
|
|
|
|
## Hardware Requirements
|
|
|
|
- **ESP32 Development Board**
|
|
- **RS232 to TTL Converters**: One for each laser port (Sapphire lasers use RS232 levels).
|
|
- **Coherent Sapphire Laser(s)**
|
|
|
|
## Serial Pinout
|
|
|
|
The ESP32 communicates with the lasers at **19200 baud (8N1)**.
|
|
|
|
| Port | RX Pin | TX Pin | UART Peripheral | Notes |
|
|
| :--- | :--- | :--- | :--- | :--- |
|
|
| **Serial 1** | GPIO 26 | GPIO 27 | UART2 | Primary laser port |
|
|
| **Serial 2** | GPIO 32 | GPIO 33 | UART1 | Secondary laser port |
|
|
| **Serial 3** | GPIO 18 | GPIO 19 | UART1 (Remapped) | Optional/Planned |
|
|
|
|
*Note: GPIO 1 is used for Debug/USB Serial (115200 baud).*
|
|
|
|
## Software Dependencies
|
|
|
|
Ensure you have the following libraries installed in your Arduino IDE or PlatformIO environment:
|
|
|
|
- `ESPAsyncWebServer`
|
|
- `AsyncTCP`
|
|
- `ElegantOTA`
|
|
- `ArduinoJson`
|
|
- `WiFi` (Standard ESP32 library)
|
|
|
|
## Installation & Setup
|
|
|
|
1. **Clone the Repository**:
|
|
```bash
|
|
git clone <repository-url>
|
|
```
|
|
2. **Configure WiFi**:
|
|
Open `Sapphire_ESP32.ino` and update the WiFi credentials:
|
|
```cpp
|
|
const char* ssid = "Your_SSID";
|
|
const char* password = "Your_Password";
|
|
```
|
|
3. **Flash the ESP32**:
|
|
Upload the sketch using the Arduino IDE or your preferred tool.
|
|
4. **Connect Hardware**:
|
|
Connect the RS232 converters to the designated GPIO pins and the Sapphire lasers.
|
|
|
|
## Usage
|
|
|
|
### Web Interface
|
|
Once connected to WiFi, the ESP32 will print its IP address to the Serial Monitor. Navigate to this IP in your web browser to access the **Sapphire Controller Dashboard**.
|
|
|
|
- **Main Dashboard**: View telemetry and control power.
|
|
- **Firmware Update**: Access `http://<ip-address>/update` to upload new firmware binaries.
|
|
|
|
### Serial Console
|
|
You can also interact with Port 1 directly via the USB Serial Monitor (115200 baud). Any text entered will be sent as a command to the laser on Port 1.
|
|
|
|
## Protocol Support
|
|
|
|
The driver implements the Sapphire serial protocol, supporting commands such as:
|
|
- `?P`: Read output power
|
|
- `?C`: Read laser current
|
|
- `?STA`: Read system status
|
|
- `P=XXX.X`: Set laser power in mW
|
|
- `?FF`: Read fault flags
|
|
|
|
## Firmware Versioning
|
|
The current firmware version is defined in the source code. Please increment `FIRMWARE_VERSION` in `Sapphire_ESP32.ino` when making changes.
|
|
|
|
---
|
|
*Developed for high-precision laser control applications.*
|