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.
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.
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:
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:
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.
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.
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
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.
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:
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:
- 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.
- 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)
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.
- 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
(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
Participated in the
Lamps and Lighting Contest 2016