User Tools

Site Tools


pwm_intensity_curve_linearization

PWM Intensity curve linearization

1 August 2016

I have written a C++ program to collect data for color correction. My strategy is to use a DSLR as the measurement device, as cameras have built in intensity response to make images appear natural to humans. This way I don't need to worry about how to convert from physical intensity to perceived brightness. It needs an image of the particle at each PWM value from 0-255, for each laser (RGB). That is 768 images total, but I can take 3 at a time if I'm okay with some inaccuracy introduced by one laser being picked up by multiple CCD channels. This reduces the time the particle needs to be held for.

The program controls the Arduino (running the same program we use to draw images with), using serial commands. The camera is controlled through a program called gphoto2, which runs in Linux (not Windows). I'm running this as a command-line program from my program, not as a library (which may be introducing some extra delays).

Currently, brightness values are calculated by summing all pixel values in a fixed-size region around the particle. Pixel values below 2 are discarded in this sum, because I found that almost all the background noise is in that range. There can be a big variation between channels in the total amount of noise, so it's best to filter it out.

I will likely end up using MATLAB to do a regression on the data, because it has some significant noise. Here is an example:


25 April 2016

We are using PWM to drive the RGB lasers. This normally results in a roughly linear intensity vs PWM curve, however I have noticed with our lasers that it is not exactly linear. In particular, the red laser reaches a maximum brightness somewhere around 150 and then starts decreasing steadily to 255. We will eventually want to correct for this to produce brightness variations that are steady across the entire range. Also, the eye perceives brightness logarithmically with respect to actual intensity/optical power. So in the end we will want something that looks like an exponential intensity-to-PWM curve.

I plan to create a LabView VI to automatically measure the intensity at each PWM level, and then convert that data into an array for the arduino code. The array would map brightness levels from 0-255 to PWM levels from 0-255. There would be a separate array for each of the 3 colors. This approach will allow for the best results given varying responses of different lasers, and it will be easy to update the correction array if we switch out the lasers at any time.

When using the optical power meters to measure intensity while stepping up the PWM, you need to have it set to the Bandwidth HI setting. If you let it automatically switch between the low and high settings, it will have trouble at the boundary between the two and you get inaccurate measurements.

Note: I have tried using a DC voltage on the TTL modulation inputs of the RGB lasers, and it did not work for modulating the brightness. Basically, there was a threshold voltage at which the lasers turned on all the way, and below which they were completely off. Additionally, even if we were able to modulate the current through the lasers, we may have trouble getting a steady decrease in brightness down to zero, because there is a threshold current for lasing.

pwm_intensity_curve_linearization.txt · Last modified: 2016/08/01 16:07 by erichn