Welcome to Laser Pointer Forums - discuss green laser pointers, blue laser pointers, and all types of lasers

# Converting XY points to DAC values

#### laserlightguy

##### New member
I have an XY galvo and want to make a control card.

If I have values (0,0) (0,10) (10,10), (0,0) eg a square, how do I convert these XY values to voltages?

My understanding is that the angle the mirror rotate is supposed to be linear between -5v and +5v eg if I get it 0 volts then the mirror should rotate to 0 degrees, if I give it +5v it should go to say +20degrees so +2.5v=10degrees.

Playing with my galvo I see if I adjust the X galvo from -5v to +5v it will scan a straight line but if I scan the Y galvo the line is not vertical if the X galvo is not at 0v.

Anyone have the equations for the function (volts_A,volts_B)=function(x,y) ?

#### camvo

##### New member
It depends on what kind of DAC you are using.

I find that the Arduino DUE board is most easy one.

Code:
``````analogWrite(DAC1, valx );
analogWrite(DAC0, valy);``````

That's it!
And its biggest advantage is that both DACs are updated at the same time.

Or with MCP4725:

Code:
`````` Wire.beginTransmission(DACX);
Wire.send(64);                // cmd to update the DAC
Wire.send(valx >> 4);         // the 8 most significant bits...
Wire.send((valx & 15) << 4);  // the 4 least significant bits...
Wire.endTransmission();

Wire.beginTransmission(DACY);
Wire.send(64);                // cmd to update the DAC
Wire.send(valy >> 4);         // the 8 most significant bits...
Wire.send((valy & 15) << 4);  // the 4 least significant bits...
Wire.endTransmission();``````

You need 2 separate DACs. You can not update them at the same time.
So no diagonally lines, only stair cases.

MCP4922 which is a dual DAC has latching capability but is is way to slow.

Have a look at this thread at LPF

Last edited:

#### Sultanen

##### New member
Im working with an SPI DAC, its ALOT faster than I2C once like MCP4725. Its easy to interface it if your reading the datasheet =)

#### Multimode

##### New member
Im working with an SPI DAC, its ALOT faster than I2C once like MCP4725. Its easy to interface it if your reading the datasheet =)

I set up a SPI DAC running at 8mhz clock and it tops out at about 700 points.
Any more points and the graphics starts to flicker.

The DAC / processor Camvo is using loads the DAC by writing to the DAC registers directly, so only takes a few clock cycles, therfore the limiting factor is the scanners not the SPI bandwidth.

ATB
MM