Arduino Laser Show With Real Galvos

29,245

137

82

Posted in TechnologyArduino

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

12 People Made This Project!

Recommendations

  • Science of Cooking

    Science of Cooking
  • Pocket-Sized Contest

    Pocket-Sized Contest
  • Microcontroller Contest

    Microcontroller Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

82 Comments

I can't figure out how to mirror the image.
After I built a correction amp it flipped the x and y, but now I need to flip the y in the code.
Plz help

Hi, great instructable, i'm really looking forward to giving it a go. I do have one question, I've had a look at the two circuit diagrams of op-amps and I noticed that in the images the ilda + and - appear to come from different pins the images. In one the + signal comes from pin 7 in the other it comes from pin 1 and visa-versa. Which way is correct?

2 replies

You are right, they are flipped, I think the schematic view is correct. But since the ILDA signal is bipolar (swings from -10 to 10v), this does not matter much (nothing will break), it will just flip the axis (which you can undo in the software)

Hiya,

Thanks for your reply. I was looking over the spec for the MCP4822 and it does suggest have the IC isolated with both ceramic and tantalum caps, can you see any reason not to do this?

DeltaFlo,

Do you have a code example and sketch of connection SD card spi in parallel with mcp4822?)

1 reply

No, I don‘t. But it works like this: Connect the Sd to miso/mosi/clk as usual and connect the SD CS (chipselect) to a free digital pin on the Nano.

Now take the SD reading example code and enable the SD CS while reading from the SD card but disable the MCP CS while doing so. Then, disable the SD CS and enable the MCP CS to draw what you have read.

Alternatively, you could use a Teensy with two SPI ports or a Spark Photon which has a dual DAC built in (no mcp dac needed) so the SPI is free for the sd card.

Hi! I want to make this project, but there are a couple things I don't quite understand about the galvo driver boards.
1) Why are there 3 pins on the ILDA input connectors if there are only 2 outputs on the schematic (ILDA + and ILDA -). Is the third pin not used, or is it GND? If so, do the colors match the wires? For example on the left board: Red +, White -, Black GND.
2) On both driver boards there are two 3 pin headers for power, and on the left board, only one of the two are hooked up, while on the right board, both seem to be connected. Why are there two headers on the boards?

1 reply

Yes, the third ILDA pin is the GND.

I think there are two power connectors on each board so that you can connect the power serially, which is why you only have one connection on the last board.

Would it be possible to use an esp32? (faster processor - 32bit)

2 replies

This is what I'm currently doing. The PORTB and PORTD direct GPIO pin settings need changing. I'm using a fake Wemos R32 arduino style board and can't find enough information to know what I'm doing. I can't get all the pins to set and clear.

Yes, that is possible. You only have to get the code running on it. You might need to increase the delays because the chip is so much faster.

I have finished the project but the image is flipped.I tried to remove the line from laser.h # define LASER_SWAP_XY but it gives me this error :






In file included from sketch\Cube.h:4:0,

from sketch\Cube.cpp:2:

Laser.h:27: error: 'define' does not name a type

define LASER_SWAP_XY

^

In file included from sketch\Cube.cpp:2:0:

Cube.h:6: error: 'Laser' does not name a type

extern Laser laser;

^

sketch\Cube.cpp: In function 'void draw_wireframe_quads(const long int (*)[2])':

Cube.cpp:99: error: 'laser' was not declared in this scope

laser.drawline(n[EDGE(i,0)][0], n[EDGE(i,0)][1], n[EDGE(i,1)][0], n[EDGE(i,1)][1]);

^

Cube.cpp:104: error: 'laser' was not declared in this scope

laser.drawline(n[EDGE(i,1)][0], n[EDGE(i,1)][1], n[EDGE(i,2)][0], n[EDGE(i,2)][1]);

^

Cube.cpp:109: error: 'laser' was not declared in this scope

laser.drawline(n[EDGE(i,2)][0], n[EDGE(i,2)][1], n[EDGE(i,3)][0], n[EDGE(i,3)][1]);

^

Cube.cpp:114: error: 'laser' was not declared in this scope

laser.drawline(n[EDGE(i,3)][0], n[EDGE(i,3)][1], n[EDGE(i,0)][0], n[EDGE(i,0)][1]);

^

sketch\Cube.cpp: In function 'void rotateCube(int)':

Cube.cpp:121: error: 'laser' was not declared in this scope

laser.setScale(1);

^

exit status 1
'define' does not name a type

1 reply

You removed the # before define, it should be #define. You've probably discovered this by now!

Hi Deltaflo,

Do you have any idea for connection SD card module in parallel with MCP4822?

1 reply

You can use the CS (chip select) of the MCP 4822 to enable/disable if it listens to the serial data. A SD card also has a CS, so you can use that as well, the SD card library allows you to specify the CS.
So connect a spare digital pin to the mcp CS and set it to low when you want the mcp to listen and to high when you want to read from the sd.

Thanks for putting this together - it's awesome. I just got this working and am trying to figure out how to do a simple raster pattern where it draws a horizontal line, then shifts down 1mm and draws another line, and repeats. How do i change the code to do this? I will also probably move this to a pcb, has anyone uploaded eagle or altium files yet?

1 reply

If you use glow in the dark paint (contains Zinc Sulphide) on the surface you want to project onto then you will get enough persistance to form an image. I have been thinking of using a rotating mirror on an old VCR head to produce the vertical component of a raster (it would be easy to sync to a video), a much faster motor will be required for the line frequency though. Good luck with generating some raster images. The code to draw a raster will be fairly simple, increment x until it reaches max, then make x = 0 and increment y, when y = max reset all to zero, increment your counter, repeat. Modulating your image from a file while where [ x,y]counter = laser on or off. I hope this was helpfull.

What power laser pointer did you use and how visible do you think it would be in a well lit room?

1 reply

I don't actually know the power of my laser pointer, since it was a merchandising gift. With a standard laser pointer, the room needs to be dark. If you use a more powerful laser pointer, it gets dangerous because you may not look into the laser anymore and you need protective glasses/gear.