# Linear power

The following procedure will allow you to define a linearization table for your Pockels’ cell so you can obtain a linear power change with equal steps in the value of the power slider in Scanbox.

During imaging the laser power is controlled by an 8-bit DAC that ranges from from 0V (at a DAC register value of 0) to 2V (when the DAC register value is 255).

The DAC provides the control voltage used by your Pockels driver. I have the Conoptics 302RM driver, which accepts a maximum of 2 Vpp as its control signal.  Other users may have different drivers, but the instructions below should apply for all of them.

The curve relating laser power to voltage depends on your driver, Pockels’ cell and laser wavelength.  The first step to compute your linearization table is to measure the power of the laser during imaging as a function of the DAC register value. Typically doing this measurement at steps of 8 or 16 is enough.

To do this you begin by resetting the default lookup table to the identity.  With Scanbox open (but not imaging), simply go to the Matlab command window and type:

```>> sb_pockels_lut_identity
```

Now, you can manually set the power to an arbitrary value by typing:

```>> sb_pockels(0,newValue)
```

This allows you to directly set the DAC register value to newValue.  Note that after resetting the LUT to the identity the range of the DAC will be from 0V to 2V for a DAC value of 255.

Set the DAC register to your desired newValue.  If you now get the microscope to scan, you can measure the average power at the newValue. Once you have obtained sufficient measurements at different levels, spanning the range 0 to 255,  you can interpolate and determine how the power depends on the DAC register value.

The result is likely to be a non-linear and non-monotonic curve, where the maximum power is obtained as some intermediate value and then it starts to decrease.  This is normal behavior.

From the interpolated curve you can calculate a linearization table such that changes in power will be linear and it will attain the maximum possible power for a setting of 255.

The final step is to include your linearization table in the Scanbox configuration file, which now includes a line that reads:

```sbconfig.pockels_lut = uint8([]);
```

Simply replace the empty array with your lookup table and it will be delivered to the firmware every time Scanbox starts up. The list must have exactly 256 entries or Scanbox will ignore it.

For this procedure to work you must first update your firmware (which you will find under the Yeti/drivers directory).

If you have any questions let me know!

Warning: Please make sure the maximum voltage you test is the one allowed by your driver!