Laser + Galvanometer Control

Hi everyone!

I've just finished building a laser harp and it works great except for when I try and program "animations" for the laser.

How it works is by a single laser pointing into a mirror attached to a galvanometer. The galvo moves extremely quickly between each position I want a laser beam to be in, so to the human eye it looks like a fan of laser beams.

The galvo is controlled via a 12- bit DAC (0-4095). Say I want to move the laser beam slowly from the right to the left, I'm using this code:

#define MCP4725_DEVICE 96

void animationRightToLeft() {
    for(int i = 0; i < 2048; i++) {	
        setBeamPosition(4095 - i * 2);
        delay(1);
    }
}

void setBeamPosition(int pos) {
    Wire.beginTransmission(MCP4725_DEVICE);
    Wire.write(64);
    Wire.write(pos >> 4);
    Wire.write((pos & 15) << 4);
    Wire.endTransmission();
}

Hardware:
Boarduino (I have also been running it from an Uno, however results are the same)
Galvanometer: Don't have model but it is 20kpps from laserwinkel (dutch company)
DAC: MCP4725

It functions basically as intended and the laser moves from the right to the left, however, it isn't smooth, it appears to slightly slowdown and slightly speed up at different points throughout the animation.

I'm not sure if this is hardware or software, I'm still really new to this but I thought maybe the arduino had some hidden interrupts or something, I have no idea xD

Cheers,
Kaine

Hi,

I think your equation should be setBeamPosition(4095 - (i * 2)) instead setBeamPosition(4095 - i * 2);

tauro0221:
Hi,

I think your equation should be setBeamPosition(4095 - (i * 2)) instead setBeamPosition(4095 - i * 2);

I very much doubt that. Multiplication has precedence over subtraction in C.

and woohoo, 7000 posts. :slight_smile:

Hi!

Yes, multiplication does have precedence so writing 4095 - i * 2 is the same as 4095 - (i * 2)

The output values from the equation are correct, however, the movement of the galvanometer isn't "linear". I say linear in quotes because I believe it has a linear response and I am thinking that the time between each loop is different as if something is occurring in between somewhere.

And congrats on 7000! I'm almost there :wink:

In your setBeamPosition function, don't you need a Wire.endTransmission() to actually send the 12C data?

That was my bad, I actually do have Wire.endTransmission() in my code. Sorry for the mistake.

Old post I know but would you mind sharing some info on your laser harp... I have Just given up on a stepper motor version of a laser harp and about to embark on a galvo version

What galvanometer are you using? You need to slowdown to turn around at edges so depending your model it could be explanation. They also dont like to jump positions without tripping. When we do laser scanning with analog GG setups, our waveforms are sinusoids as opposed to ramps or and we blank the lasers in the turn around to avoid burning.

Since this seems digitally controlled they are probably smoothing the movements for you, hence the slow downs.