Arduino Laser Show With Real Galvos

73,575

187

140

Introduction: Arduino Laser Show With Real Galvos

About: I'm a software guy, starting to learn electronics.

In this project we use an Arduino UNO/Nano to run a laser show with a laser pointer. We are using real galvos (galvanometers) like in commercial laser projectors, since these have become quite affordable recently (around 100 Euros/Dollars) and provide a much higher quality than speakers or stepper motors.

Hardware

On the hardware side, we build the Arduino driven projector by using a external 12Bit DAC (digital to analog converter) and an (optional) amplifier circuit to create the signal for the galvonometers.

You can build this project if you have some basic experience with an Arduino board and a breadboard.You can get away without any soldering, although it is probably a better solution to solder a PCB finally.

Software

On the software side, a complete Arduino sketch is provided which features:

  • Text rendering (including zoom/translate/rotate)
  • Logo rendering
  • Drawing effect (draw object or text incrementally)
  • Line clipping
  • Optimized for small program size (PROGMEM font/objects) and speed (fixed-point arithmetic)
  • And a 3D cube that is rendered live...

All source code is provided and can be easily adapted to create your own show!

Inspiration / further reading

I was originally inspired by the following project, which explains quite well how laser projectors work and which uses speakers to simulate the galvos:

https://www.instructables.com/id/Arduino-Laser-Show-with-Full-XY-Control/

Using speakers is very limited regarding quality and complexity of the objects you can draw, which is why we use real galvos in our project.

Step 1: Parts You Need

  • an Arduino UNO / Nano (or a compatible clone) + USB power
  • 20Kpps galvos with driver cards and power supply (these typically come in a set, see below)
  • a 220V or 110V power cord (if galvo power supply does not come with a cord)
  • MCP4822 DAC (a cheap dual channel 12 bit DAC)
  • a red laser pointer
  • some crocodile/alligator clips (to easier connect the laser pointer)
  • a breadboard or prototyping PCB
  • jumper wires
  • some Lego bricks (optional, for the laser mounting)
  • a box/casing to mount the project (optional but recommended)

If you want to build the (optional) ILDA amplifier, see the parts list in the amplifier step.

The most expensive parts of this project are the 20Kpps galvos. I bought my set on ebay:

http://www.ebay.de/itm/20Kpps-laser-scanning-galvo-scanners-ILDA-/201645259187

Just search the internet / ebay for "20Kpps galvo" and you should find an adequate set. These sets typically come with a bipolar power source (mine uses +15V/-15V, if yours is in the range of 12-15V it should not make a difference).

Step 2: Laser Pointer

Hacking the laser pointer

For our project, we need to switch a laser pointer on/off from the Arduino. For this, you need to buy a cheap red laser pointer. It will typically have an on/off push button, which you need to fixate to a permanent pushed state. On my pointer, I just used duct tape to permanently press the button. Next you need to remove the battery case (back part of the pointer) and add power supply wires instead of the batteries. The easiest will be to use two alligator clips, typically one on the spring (-) and one on the case (+).

Have a look at the images for an example laser pointer.

Testing

To test the pointer, you can connect it like this: Arduino 5V -> Laser+, Arduino GND -> Laser -

If your laser pointer draws too much current to be safely connected to the digital output of the Arduino, you have to use a transistor or MOSFET to switch it. My pointer worked without problems, so it probably draws less than 50mA.

Mounting

The pointer needs to be at the correct height to point into the galvos, for this you need to build some holder. I used some Lego bricks to build the holder, see above picture. Of course you can use any other material to build it.

Step 3: Setting Up the 20 Kpps Galvos

The galvo set should consist of:

  • The two X/Y galvos with mirrors (attached to a metal block)
  • Two identical driver boards, on for X and one for Y
  • A power supply
  • Connector cables to wire everything
  • Extra input connector cables

Power supply

In my set, the power supply did not have a power cord, so I added a standard 3 wire power cord (I used an old PC power cord and removed the PC connector). Be careful when you work with the power supply, since it works on AC 220V/110V and this is (as you should know) DANGEROUS! I recommend that you get some kind of box to mount everything in and reserve an extra isolated spot for the power supply. I glued a plastic box on top, covering the power supply so that nobody can touch the high voltage input.

Connecting everything

Now connect the cables from the power supply to each driver card and each driver card to one of the galvos. You should have two remaining connector cables, which you can plug into the ILDA input of each card. You can either use these connector cables or instead you may use individual female jumper cables instead. In the next step, we will connect these to the Arduino / DAC outputs.

Step 4: Wiring the DAC and Laser Pointer

For this project we choose the MCP4822 DAC (as PDIP-8, to be breadboard friendly). It is available for 3-4 euros. It offers dual channel 12bit and there is an Arduino library available for it. It is connected to the Arduino via SPI and supports an additional LATCH pin which offers synchronous update of both channels. It will generate two output signals ranging 0V to 4.096V.

The following links to the datasheet for the DAC:

http://ww1.microchip.com/downloads/en/DeviceDoc/21953a.pdf

The wiring is done like shown in the images above.

The laser pointer is connected to GND and to Arduino pin D5. As said before, if you want to be on the safe side regarding drawing current from the Arduino, you can also use a transistor/MOSFET instead of a direct connection from pin D5.

The connection to the DAC is as follows:

Arduino CLK (pin D13) -> DAC SCK (pin 3)

Arduino MOSI (pin D11) -> DAC SDI (pin 4)

Arduino CS (pin D10) -> DAC CS (pin2)

Arduino pin D7 -> DAC LATCH (pin 5)

Arduino 5V -> DAC VDD (pin 1)

Arduino GND -> DAC VSS (pin 7)

This leaves us with DAC pin 6 and pin 8 which provide us with the two analog output signals.

One output of the DAC is connected to the ILDA driver card for the X galvo and the other one to the Y galvo. Since the ILDA driver cards expect a bipolar signal, in pricipal we would have to generate a signal from -5V to +5V and an inverted signal for the negative driver input. But these driver cards do not care so much about the bipolar signal, so you can wire each DAC output (with is positive 0 to +4.096V) to the ILDA IN+ connector and connect both the ILDA GND and ILDA IN- to the Arduino's GND. This will not drive the galvos to their full angle range, but it should already generate an image in about 1/4 of the galvos range. In a later step, we will learn how to create a correct bipolar signal.

In principle, this DAC is replaceable by any other dual channel DAC
that operates on 5V and supports latching, but you will need to adjust the Arduino sketch to make it work with a different DAC. The DAC code is inside of the Laser.cpp file.

Step 5: Housing / Putting Everything Together

If you don't have a box/case yet, now is a good time to get one. Don't forget to add an opening so that the laser ray can be emitted. I just used a wooden box and sawed a (too big) round hole and added a flap to open/close it. As you can see in the picture, I have plenty of room left, so I should have choosen a smaller box.

After everything is mounted, place the laser pointer near the galvos and adjust it so that it points into the center of the first galvo. I recommend to not fixate it at this point, so that you can re-adjust it later on.

The Arduino should be powered via USB, so you need to connect it to your PC (or later on to a USB charger) to run the laser show. You could also get the power from the galvo power supply, but this would require a DC-DC step down module, which is easy to add but out of scope of this project.

Your setup should look similiar to the one given in the image above, except for the extra (optional) amplifier PCB on the image, which will be explained later on.

Step 6: Software: Uploading the Laser Show to the Arduino

If you haven't already installed the Arduino IDE, now is a good time to do so.

You can download the complete laser show sketch from:

https://github.com/DeltaFlo/LaserProjector

  • Download the project (Just click on the "Clone or Download" button and choose "Download ZIP").
  • Open the LaserShow/LaserShow.ino sketch in the Arduino IDE.
  • Connect the Arduino via USB.
  • Press the compile and upload button.

If you wired everything as explained, the Arduino should now run the laser show right away.

Since the laser pointer does not have a lot of power, you will need a dark place to fully enjoy the show. Of course you can upgrade the project to a more powerful laser diode, but this is not covered in this tutorial and requires additional safety measures.

Trouble shooting:

  • is the laser pointer not switching on/off? Check if it is wired correctly.
  • is the laser pointer hitting the galvos in the right position? Try readjusting the height/angle of the pointer.
  • are't the galvos moving? Check if the power supply is working. Check if the galvos move when you connect +5V and afterwards GND to the positive input of the driver card instead of the output from the DAC.
  • is the image flipped horizontally or vertically? (adapt the Laser.h header file to flip the projection)
  • is the image rotated 90 degrees (adapt the Laser.h file to swap X/Y)

Fine Tuning:
Have a look at the Laser.h file to fine tune various timings to your hardware. Your laser pointer might have a smaller/bigger on/off delay than mine and the galvos might react differently.

The galvo driver cards typically also have potentiometers to fine tune over/under shooting, so you might play with those as well. In my setup I still had problems reaching the closing point of a contour exactly, probably because of the overshooting.

Step 7: Bipolar Signal With Opamps

NOTE: you only need to do this step if you want to get a bigger projection angle or if you are eager to learn how to generate bipolar signals and their inverse.

In the previous steps, we have already built a working laser projector, but we did not generate the correct bipolar ILDA signal that the driver cards expect. So how does a bipolar signal work? Bipolar means that the signal swings from -5V to +5V (so it has a range of 10V and GND is the center). In additional, the ILDA standard wants the same signal again as an inverted signal. For example a negative ILDA input of e.g. -5V requires a positive ILDA input of +5V.

Want we want to build now is an amplifier circuit which amplifies the unipolar DAC signal (from 0V to +4.095V) to the bipolar range -5V to +5V. For this we need a bipolar power supply. Luckily we can just use the power supply of the galvos, which is bipolar.

We are going to build the amplifier for X and Y separately, since it is the exact same circuit. To amplify an analog signal and to invert it, an opamp (operational amplifier) is used. Since we want to make the amplifier adjustable, we will add potentiometers for the gain and the offset, instead of fixed resistors. This makes the whole setup adjustable to different input ranges from the DAC and different power supply voltages.

Parts needed:

  • 2x TL082 opamp (PDIP-8)
  • 2x 1 KOhm resistor
  • 2x 47 KOhm resistor
  • 4x 10 KOhm resistor
  • 4x 10 KOhm potentiometers

The above images show the circuit for one signal line, you need to build it two times. I generated a circuit view and a breadboard view. I decided to put it on prototyping PCB together with the DAC, but that is totally up to you, breadboards will work fine as well. My PCB is shown on the last image.

Finally you need to connect the two DAC outputs to the two amplifiers and their +/- output to the ILDA driver inputs. Make sure that you also connect the GND of the Arduino with the GND of the galvo power supply, to get a common ground. Connect the power supply to the two amplifiers as well. Now everthing should be setup and you can run the laser show and adjust the image using the potentiometers.

How the amplifier works

One potentiometer is used for the GAIN (it scales the image) and the other for the OFFSET (it moves the image). The TL082 IC contains two separate opamps. One opamp is used to move and scale the signal (and also invert it), the output is the negative ILDA INPUT-. The second opamp is used to invert the signal again to get the positive ILDA INPUT+.

Step 8: Further Project Extensions

You can extend this project in various way. If anyone is interested, I plan to write additional instructables that extend this project:

  • Upgrade to a Teensy 3.2 microcontroller and create a live spectrum analyzer

    (https://www.youtube.com/watch?v=QLwdwvleztA)

    (Source code here: https://github.com/DeltaFlo/LaserProjector/tree/master/LaserSpectrumAnalyzer)

  • Add an ESP8266 to show content from the Web

  • Create an Etch-A-Sketch Webpage which sends the drawn sketch to the laser projector
Lamps and Lighting Contest 2016

Participated in the
Lamps and Lighting Contest 2016

17 People Made This Project!

Recommendations

  • Mason Jar Speed Challenge

    Mason Jar Speed Challenge
  • Bikes Challenge

    Bikes Challenge
  • Remix Contest

    Remix Contest

140 Discussions

0
Tinkering Idiot
Tinkering Idiot

18 days ago

I'd like to add my praise for this project, it was enough to set it up myself, even through I am a total hack in electronics. Great work! May I add that you can find affordable options of the galvo's on Ali Express, I bought them for less than half the price on the European stores. Had to wait 5 months for them to arrive though. :(

0
1john.murphy
1john.murphy

Question 2 months ago on Step 8

What is the purpose and impact of removing the line:
#define MCP4X_PORT_WRITE 1
to make this work with an Arduino Mega?
0
DeltaFlo
DeltaFlo

Answer 2 months ago

The line turns on some optimizations (writing bits directly to ports), which only works on Arduino Nano / Uno. Disabling it switches to normal digital writes, which are slower on the Uno but it does not matter for other faster microcontrollers.

0
Tinkering Idiot
Tinkering Idiot

Reply 18 days ago

Very good find, @1john.murphy. I had problems myself figuring out why I couldn't get it to work on the Mega, but could on the Uno. I almost bought a new Mega, because I thought my cheap Mega clone was to blame. :)

I wish to add though that the Mega is not faster than the Uno, it's just bigger in terms of memory and pins. In the MCP4X library unfortunately the optimization is hard tied to the Uno as well as that specific pin. Even on the Uno, if you don't use pin 10, you have to switch off the port write to make it work.

Optimization on the Mega is still possible, but the ports are different so it will never 'just work' (in fact I believe the hard-coded port corresponds to the MOSI pin, which is used in the communication, so you can't even use the pin that corresponds with the code). You'll have to choose a specific pin first, and then you'll have to change DAC_MCP4X.cpp to change it directly.

0
bradley.jansen.2005
bradley.jansen.2005

4 weeks ago

Hi, great project! Did you ever make the etch-a-sketch program?

1
DeltaFlo
DeltaFlo

Reply 4 weeks ago

Yes, I built it with a Teensy and ESP8266. You can connect to it via WIFI and can draw on a HTML canvas, which then gets simplified and sent to the laser. But I never found the time to polish it/write an instructable about it.

0
bradley.jansen.2005
bradley.jansen.2005

Reply 4 weeks ago

Cool! Any chance I could have the code?

1
1john.murphy
1john.murphy

Question 2 months ago

I was experimenting with changing the angle offset in the SIN code from 90 to another value to create an ellipse and got unexpected results in one of the outputs, so I changed the call in the circle() function to:

laser.sendto(COS(r)/scale, COS(r)/scale);

and sent it to an oscilloscope (all other code is unchanged from your work). There is a "hitch" in the bottom curve. Do you have any idea what might be causing that? Everything else seems to work fine. A different "hitch" is also apparent in the same channel when he circle code is unchanged, but it's much more subtle and doesnt affect the circle.

The bottom graph on the scope is the 'x' and the top the 'y'.

20200710_140303.jpg
0
DeltaFlo
DeltaFlo

Answer 2 months ago

Probably your output circuit does that? Did you look at the DAC output or the final ILDA signal? I would look at the DAC output directly. I don't think that the contains contains/generates the bump, except if the scale causes an integer overflow in that direction. You could check how it behaves with a smaller scale and what the min/max values are that you send.

0
1john.murphy
1john.murphy

Reply 2 months ago

I thought that as well, so I added some code to use the built IDE plotter to see the values being output to the DAC and I saw the same behavior. In order to address the issue I created a new SIN function which takes phase a parameter (to get COS i just call SIN with a phase shift of 90). My new SIN routine looks like this:

long SIN2(unsigned int angle,int phase) {
angle+=phase;
while (angle > 360) {
angle-=360; }
if (angle > 270 && angle < 361) return -LUT2(360-angle);
if (angle > 180 && angle < 271) return -LUT2(angle-180);
if (angle > 90 && angle < 181) return LUT2(180-angle);
return LUT2(angle);
}

LUT2 is just like what you did for LUT with the order of the values reversed. This seems to work fine for manipulating the sin waves for X and Y.

Now on to a few more parameters and POTS to control amplitude, frequency, and phase, and I should be able to draw the old style Lissajous patterns with the laser as well:) ... at least that is my hope!

0
CHOIX
CHOIX

Question 4 months ago

Nice Project.
How can I calculate how big the drawing area can be if the laser is 3 meter away from the wall? And are those lasers dangerous for the eyes? are they visible by daylight? Thank you for any provided information.

0
trevor.boultwood14
trevor.boultwood14

Answer 3 months ago

I reckon a bit of trig would come in handy here!

0
CHOIX
CHOIX

Reply 3 months ago

I did not get what you mean.

0
trevor.boultwood14
trevor.boultwood14

Reply 3 months ago

Cos-1( angle) = a/h a= how far away. H = 1/2 of picture so multiply the answer by 2 and you should get a rough estimate?

0
CHOIX
CHOIX

Reply 3 months ago

aha "trigonometrie" ok ok :D thanks. and what about the danger for the eyes? do you know anything? hmm I mean in clubs/discos there are also lasers, but I think those are only visible by darkness.

0
trevor.boultwood14
trevor.boultwood14

3 months ago

I have generated a few PCBs which can hold an arduino nano and correction amplifier and DAC. If anyone is interested drop me a message. It also has the ability to play ilda files from a modified sound card. I hope to create an instructable at some point in the near future! Thank you for your instructable.

0
trevor.boultwood14
trevor.boultwood14

Reply 3 months ago

Here is a picture, i am still awaitng delivery but will have a few spare.

DAC.png
0
PercyMcfly
PercyMcfly

8 months ago

I used SuperNit‘s diagram. Worked fine and i‘m happy about the result.
I‘m wondering if there is also a solution without the potentiometers?
I‘ve just started with arduino about 2 weeks ago, so i have no clue about electronics and how it all really works. I figured i could just figure out what a potentiometer does, and do it all with wires and resistors, but maybe there is a more elegant solution?🤔

0
trevor.boultwood14
trevor.boultwood14

Reply 3 months ago

once you have found the best result, you could take out the variable resistors and measure their resistance with a volt meter and then replace with some resistors. Though I would recommend leaving them in and putting a bit of lock tight or hot glue as all resistors have a tollerence of around 5%

0
DeltaFlo
DeltaFlo

Reply 8 months ago

The whole opamp/potentiometer circuit is optional, it is just needed to allow analog scaling of the output image. You can also connect the output voltage of the dac to the laser x/y, as described in the text. Then your projection will not be as large as it could be, because the voltage will only go from 0-5 V and not from -5 to 5 (or even -10 to 10). Without potentiometers, you can only scale the signal digitally, which is less precise.