> For the complete documentation index, see [llms.txt](https://zapit.gitbook.io/user-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zapit.gitbook.io/user-guide/installation-and-setup/configuring-zapit/laser-power-calibration.md).

# Laser Power Calibration

These settings are used for analog input control to the laser.&#x20;

#### `laser`

* `laserMinMaxControlVolts` should be the maximum and minimum analog input values that your laser will accept. Set to 5V max for the Obis.&#x20;
* `laserMinMax_mW` is the maximum and minimum power your laser will produce. We will change these in the next section. Leave them alone for now.&#x20;
* `name` is just for information purposes at the moment. Change it to the model name of your laser.
* `maxValueInGUI` is the maximum control value accessible in the GUI. You will be photoactivating in the range of about 1 to 10 mW but you might want more power for the scanner calibration stage. The default maximum power that can be set in the GUI is 30 mW but you can alter it by changing this setting. &#x20;

*Save the settings file and restart Zapit before carrying on*.&#x20;

#### Calibrating the laser

The Zapit GUI allows the user to specify power in mW at the sample. In order to achieve this, the laser must be calibrated using a power meter. A suitable power sensor and meter would be a ThorLabs [S121C](https://www.thorlabs.com/thorproduct.cfm?partnumber=S121C) and [PM100D](https://www.thorlabs.com/thorproduct.cfm?partnumber=PM100D). You can also buy the [PM103A](https://www.thorlabs.com/thorproduct.cfm?partnumber=PM103A) if you want a cheaper unit with the disadvantage that it requires a PC (this unit has an analog output, which you may need so **do not** buy the cheaper [PM100USB](https://www.thorlabs.com/thorproduct.cfm?partnumber=PM100USB)).&#x20;

For lasers such as the Obis, where output power is linear as a function of the control signal only the following linear calibration procedure is necessary. For systems using an EOM or AOM, where power output is non-linear as a function of control voltage, an additional step is needed. This is described below and require Zapit version 1.0.4 or later.&#x20;

* Start Zapit.
* Turn on the laser and wait half an hour for it to warm up and settle.&#x20;
* Place the power sensor where the sample will be and turn on the beam with the "Off/On" control located in the "Laser power (mW)" section of the GUI. <img src="/files/kyP6dLAH2EPV8Z0BhiPX" alt="" data-size="original">
* Set your power meter to the wavelength of your laser and set the scale to the 100s of milliwatts so it does not change range automatically during the process.  Point the beam at the sensor. Make sure you can obtain a reading.&#x20;
* Set the laser to maximum power using the command line. For the Obis this is 5V so we issue at the CLI:\
  `>> hZP.setLaserPowerControlVoltage(5)`
* Read off the value on the power meter. Let's say you read 41.1 mW.&#x20;
* You can now tell Zapit what this maximum value is in mW by entering at the command line: `>> hZP.settings.laser.laserMinMax_mW=[0,41.1];` \
  This updates the YAML settings file so you do *not* need to edit it. This step is for both linear and non-linear laser.

#### Finalising linear power calibrations

* For linear system, such as most small diode lasers like the Obis, test the calibration by asking for a laser power in mW `>> hZP.setLaserInMW(10)` You will likely find it accurate to within about about 0.1 or 0.2 mW.&#x20;
* Try a few different values. If your lower power values in particular are off by more than about 0.2 mW, you can probably improve the things by adding a small offset to the low mW value. e.g. `hZP.settings.laser.laserMinMax_mW(1)=0.04;` Do that by trial and error and things should improve.

#### Nonlinear power calibrations

If you have a laser with a **nonlinear** power/control curve you will need to measure this using a photodiode, such as a [ThorLabs PDA100A2](https://www.thorlabs.com/item/PDA100A2), or a power meter with an analog output. Then:

* Connect the NI DAQ AI0 terminal to the analog output of the sensor.
* Turn on the photodiode or power meter and point the beam at it.
* Run `hZP.generateLaserCalibrationCurve` This will record a calibration curve and plot the results.
* The measured curve is now active. An interactive CLI prompt will appear asking if you want to save the curve for future use.&#x20;
* The `hZP.loadLaserFit` method will re-load a previously saved calibration (only one can be saved). `hZP.saveLaserFit` will save the currently active calibration.&#x20;
* As for the linear case, try setting the laser power to a range of values to ensure the fit works.&#x20;

**NOTE** this measurement step measures the *shape* of the calibration curve. The scale (max/min values) were set previously where you assigned values to `hZP.settings.laser.laserMinMax_mW`&#x20;

Please [file an Issue](https://github.com/Zapit-Optostim/zapit/issues/new/choose) if you have problems with this process or it does not work.<br>

#### Checking power day to day

Put the power meter under the objective and set up as before. Set the power in the GUI or at the command line (e.g. `hZP.setLaserInMW(10)`) and confirm the reading with a power meter. If it is off, repeat the above steps.&#x20;
