# How to convert pixel map to voltage/angles?

My end goal is trying to get something rendered using lasers and a MEMS scanning mirror. There are not that many resources online for this, but it seems like the basic idea is pretty applicable to general embedded systems principles. I am building the driver from scratch and having trouble with part of it, and hopefully can get some direction on what to learn and make sure my thought process/approach is correct? The idea is straight forward:

1. Render a element and generate a ppm file to define each pixel value
2. Convert that to a set of voltages for the DAC
3. Based on the data sheet I can generate a look up table for voltage -> angles for the mirror

My main question is figuring out how to generate those sets of voltages. Is that even the correct approach? It seems like it will be a very similar approach to how LCD screens work with refresh rates.

HV_A (X+)
HV_B (X-)
HV_C (Y-)
HV_D (Y+)

HV_A = ((x_in / 8) + 1.25) * 56
HV_B = 140 - (((x_in / 8) + 1.25) * 56)
HV_C = ((y_in / 8) + 1.25) * 56
HV_D = 140 - (((y_in / 8) + 1.25) * 56)

• Are you planning to only have the mirror illuminate a subset of pixels in your image? Otherwise, you would generally have it sequentially step through all possible angles at a constant rate (raster scanning). Jul 27, 2020 at 4:23
• Are you asking how to generate the physical voltages from the digital data (how to build a DAC), or are you asking what the voltages should be (and for that we would need to know about your mirror)? Jul 27, 2020 at 4:28
• @user1850479 I am planning on performing a raster scan Jul 27, 2020 at 4:33
• @user4574 question is how to go from pixel -> voltages for the DAC. I provided the equations in the data sheet for the positional outputs on each axis, but that's for the 2nd step after I have the voltage values. It seems like I may have to convert positional data to voltages and not necessarily the pixel data? Jul 27, 2020 at 4:37
• @joethemow In a raster scan the pixel values are not used to generate the mirror voltages. Instead, the mirror moves at a constant velocity, and would do so even if the image was completely blank. Jul 27, 2020 at 4:38

So, the conversion from rectangular coordinates to angles is really just a bunch of trigonometric functions; that's not hard to do on paper (if your mirror is x meters from the wall, and you want to light up a point y meters right of the perpendicular, that angle is arcsin(y/x); do a drawing to clarify for yourself).

But:

Your approach isn't great. The mirror is an object with a mass and thus, hysteresis. Accelerating and breaking it is complicated, takes time and energy.

Your laser on the other hand can nearly arbitrarily fast be pulsed.

So, assuming you have one voice coil to deflect the mirror in vertical direction, and one in horizontal:

• Let the mirror do a full row scan as one continuous swipe. It's very possible that the easiest way of doing so is a simple current DAC, which you also find in cameras to control optical elements (stabilizers, autofocus), for example the AD5398A.
• Then, advance one row with the other coil, and do the swipe (hint: might be clever to do it in the opposite direction)
• all the while, you turn on your laser at the right time instants – not at inidividual "discrete" angles, but based on knowing that mirror travels continuously, at the right time.

That gives you a simple three-DAC system: One DAC for row slides, one DAC to define the vertical deflection, and one fast DAC for the laser. Your horizontal resolution is only defined by how quickly you can control the laser, your vertical by how many individual rows you can do.

• This makes sense, I have a 2D mems mirror. The principle seems like it would transfer over in this case as well. Is there a good resource on syncing the laser pulses with the position of the mirror? Jul 28, 2020 at 19:48

question is how to go from pixel -> voltages for the DAC.