Tuesday, December 1, 2015

A DIY A4 Laser Engraver made from a scanner and a printer on ATmega328

This "Get Ready For Win98" Laser Engraving Machine it's built using an old scanner, and an old printer.
A laser engraving machine is a tool that uses lasers to engrave an object.

I've an old broken scanner and an old printer lying around. Inspired by this instructables project:
I decide to build a bigger version of my small CD-ROM based laser engraver, you can find here:
That way, the engraving area are will be almost 212mm x 274mm.
Note that some part of this post is taken from the above blog post link.

Before starting up, read my blog disclaimer and the one below:

Warning! Laser diodes drive are emitting visible and invisible laser radiation and they are extremely dangerous! Their light can permanently damage the eyes. You must never look into the working diode even without the lens or point it on a reflective surface. Laser beam can cause burns or fire. This is usually a Class IIIb laser. Everything you do at your own risk.

The Y-axis it is build using the scanner assembly, the X-axis using the printer one.
As you can see by the Get Ready For Win98 sticker, the scanner is pretty old, and this sticker was so vintage that i've decided to leave it on.

The base of this machine is the scanner itself.
The scanner was completely disassebled, all except the motor and the movement mechanism is removed. The same applies for the printer.
Assembling the hardware, pay attention to build it making X normal to the Y axis. The two direction has to be perpendicular, or your engraving will have distortions.
The printer mechanism it is connected to the Y-axis scanner assembly, that way, the laser moves over the part to be engraved.

My engraver it is powered by a 12V 2A power supply, though the total current absorbed it's 700mA.

The brain of this project is an ATmega328p running at 16Mhz. loaded with grbl firmware http://github.com/grbl/grbl, which is a powerfull yet opensource g-code parser.
I've used an Arduino Mini board, even if the software does not use the Arduino framework.
A 7805 voltage regulator it is used as power supply for the ATmega.
Grbl 0.9 it is build for 3 axis router, to make it works on 2 axis systems like this, with hard limit and homing enabled, a custom version of the firmware it is needed. The only change to apply to version 0.9g are on config.h file.
#define HOMING_CYCLE_0 (1<<Z_AXIS) 
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) 
was commented out and changed to:
#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS))
//#define HOMING_CYCLE_0 (1<<Z_AXIS) 
//#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) 
Then the new grbl firmware can be compiled and used, preventing grbl 0.9 homing problem on 2 axis machines.

My custom version of grbl v0.9g compiler for ATmega328p @16Mhz, with a baudrate of 115200, can be download below.
CP2102 it is used as USB to UART board.
You just have to upload the firmware using your favorite uploader, the grbl wiki page drive you on how to do this step.
On the grbl wiki page you could also find any other information about command and software setup.

The motor driver I've use to move the X and Y motor stepper are Polulu A4988 Stepper Motor Driver Carrier, based on Allegro A4988.
My scanner has an unipolar 5-wire stepper motor. That Allegro driver works only with 4-wire bipolar stepper motor. So I've transformed the unipolar motor to a bipolar stepper motor.
To made this modification, I've just cut the common wire between the two main windings. Then I checked that the windings haven't got any connection by using a multimeter. That way i have two coil, like a bipolar motor. Look at the image below for carify:

The printer has a bipolar 4-wire stepper motor.

We can setup how many microstep and how much current Allegro A4988 sends to the motor.
Incrasing microsteps makes the motor more accurate, but it also reduce the motor torque.
You can made some tests to find your best motor power setup.
For mine motors, to allow a smooth and fine motor movement, and a good torque the Allegro A4988 it is setup to 8 microsteps for the Y-motor, and 16-microstep for the X-motor.
Below you can find the basic Polulu board connection wiring.

To make the Polulu board runs at 8 microsteps M1 and M2 has to be connected to logic power supply VDD, if you want to run it at 16 microsteps, connect also M3 to VDD.

Motors supply VMOD is connected straight to 12v.

On each axis a limit and an home microswitch it is placed to prevent axis over-running, and eventually the motor or the motor driver damage.
Because the limit switch are pretty sensible to noise, I've added an high pass 100nF capacitor and an additional pull-up 10k resistor. Also the limit and home wire are indipendent and distant from the motor and laser cable strap.

The laser used is a red laser diode, taken apart from the DVD-ROM writer optics.
In CD-ROM and DVD-ROM you could also find IR driver, DVD laser writer diode will be a little more powerfull than the CD one.
Laser diode usually has three pins, one is the common ground, laser and photodiode cathode (-), one the laser diode anode (+), the other is the monitor photodiode anode(+).
If the diode you are using has no mark, and you do not know the diode pinout, you have to find the laser cathode and anode. One simple method I use is to power up the diode with a 1.8 to 2.2v current, just for a little amount of time, let's say 1s, if it absorbs current, that wiring is the laser diode pinout.

Laser diode has to be drive with a proper driver, to run mine, i've build a LM317 based laser driver.
This laser driver can drive diode from 12mW to 700mW.
A 9v voltage regulator prevent overvoltage on the laser diode.
Also a NPN it is placed to allow the TTL input that comes from the microcontroller to enable or disable the laser.
We are using LM317 IC as a current regulator.
Input voltage get in the Vin pin of the LM317, from the output Vout to the ADJ pin there is a resistor R connected.
The output current Iout is given by the formula Iout = Vref/R.
Over there resistor there always be Vref voltage. When current decrease, the voltage over R should be lower, but that way the regulator increase his output voltage to adjust his Vref voltage.
Vref is 1.25 for the LM317. R is made using a fixed resistor R1 and a trimmer R2. That resistor and the trimmer sets the current that the laser use.
So laser driver current is given by the formula: I=1.25/(R1+R3).
The power rating of the resistors R1 and R2 is calculated by the forumla P=1.25*I.
Before connecting the laser and testing the driver, check that the resistence is the higher value possible, then connect the laser and measure the absorbed current using an amperometer. Note that if you set too much current to the laser, that will blow.
Below the laser driver circuit.

A standard 60mm x 60mm pc brushless fan is installed to clear the smoke, this prevents the laser optics lens to be clouded.

Commands to the engraving machine are sent through UART at 115200 baud rate.

One you have built the machine, checked and connect all, upload the grbl firmware to your microcontroller, you could use terminal software, or a grbl controller to setup your board. I'm using Universal G-Code Sender to setup and send command to grbl, but you can also use a simple terminal.

The first thing to do is test the motor movement:

To test it, just send the
X10 Y10
command, or use the Universal G-Code Sender movement button.

You should see a motor movement on each axis.

Also check the laser is turned on and off using

Now to setup the correct motor distance to run, you have to set each motor step/mm.
The axis motor step/mm calibration method is pretty simple.
Let's try the X axis calibration as example.
We know how many step/mm or steps_per_revolution grbl is actually setup, grbl $100=250.000 (x, step/mm) parameter.
Now, we move your motor for some steps, let's say 100 microsteps, the axis should have move 100mm.
Now we measure the real distance the motor has moved, let's suppose is 181mm.
The new step/mm value for this motor axis should be
steps_per_mm = (steps_per_revolution*microsteps)/mm_per_rev
138.121 = (250*100)/181
Now, if you move the motor 100mm, it should move 100mm.

Because i've installed the limit and home switch, I have alse enabled hard limits
I've setup the homing pull-off to 5mm, cause my microswitch have a long lever, and i want the motor to move fare away after the home cycle.
Also the homing cycle it was enabled:
And the homing direction mask it is changed. One may even need to invert axis direction, "dir port invert mask" is the paramenter you have to touch.

Those are the most common grbl setup, for the complete list, look at the grbl wiki page.

Below you can find the grbl configuration parameters i changed:
$21=1 (hard limits, bool)
$22=1 (homing cycle, bool)
$27=5.000 (homing pull-off, mm)
$23=3 (homing dir invert mask:00000011)
$100=37.879 (x, step/mm)
$101=94.246 (y, step/mm)
$110=100.000 (x max rate, mm/min)
$111=100.000 (y max rate, mm/min)
$130=212.500 (x max travel, mm)
$131=274.400 (y max travel, mm)

Now you could be able to send g-code drawing to your engraver.

There are a lot of software you could use to build g-code draw, the one I use the InkScape.
The working are for this plotter is 212mm x 274mm, so setup your project area to this dimension.
Once you have you path, then you could select the path you want to engrave, and transform it using the InkScape laser engraver extension.
Just copy the extension on your extension inkscape folder, restart inkscape, and use that to build your g-code file.
Once you have your g-code file, you could send it to grbl using Universal-G-Code-Sender, or other grbl software like Grbl Controller.


  • read risk disclaimer
  • excuse my bad english

Saturday, November 14, 2015

The Happy Frog - A touch sensor switch

The Happy Frog is a simple single touch sensor switch.

It's high impedance switch, powered by a 9V battery.
The body can act as a switch, that close the circuit, now some current flow through the base of the NPN transistor, and the transistor makes current flow through the led.

One can use a two transistor in Darlington Pair to get more gain, and makes the led bright a little more.
Thank to my friend Matteo for the vinyl cut sticker

  • read risk disclaimer
  • excuse my bad english

Tuesday, October 13, 2015

XinSound Fuzz FD-20 mod - Big Muff V2 Ram's Head clone

The XinSound Fuzz FD-20 is a Big Muff V2 Ram's Head guitar pedal clone.

It's schematic is next to the Electro Harmonix Big-Muff Pi 1975-15-10 original circuit.
As usually, I would like to experment on this pedal, doing some mods.

On the first and second gain stage of the original circuit, XinSound puts two soldered bridge to select which feedback loop diode and capacitors to use, a simple mod can be just split those bridge so try different sounds, it's the JP6 and JP7 bridge, you can see on the original board below.

The original electrolytics capacitors installed by XinSound where changed with Nichicon brand.
XinSound uses electrolytics capacitors on the clipping stage, but i prefer ceramic ones.
Also, all the four XinSound C1815 transistors where changed with classics 2N5088.
Below my modded board.

A Boost section it is added. The boost section produce an extremly clipped sound on bass.
One again many thanks to my friend Matteo for cutting me vinyl sticks for this pedal.
Found below the XinSound original schematic, as i've traced out, hope it does not contains errors.

And the modded one:

  • read risk disclaimer
  • excuse my bad english

Friday, September 4, 2015

SXAM: A Spark.io Indoor Ambient Quality Monitor

SXAM is a Spark.io indoor ambient quality monitor.

SXAM (Spark to Xively AMbient quality monitor), is an ambient quality monitor that logs 4 environmental parameters to the xively.com and display the ambient status by using for RGB leds.

SXAM logs:
  • Humidity
  • Temperature
  • Ambient noise
  • Brightness
Note: Spark.io is now Particle.io.

This project it is built upon the spark xivelylib you can found here: https://github.com/davidegironi/spark-xivelylib

A web page can be used to set the xively feed and API token.

The WiFi network connection can be configured through the Spark.io app.

For humidity and temperature a DHT22 sensor it is used.
To measure ambient noise an analogic noise sensor built with a electret microphone and a opamp it is used.
Brightness it is measured by a BH1750 sensor board.

I would like to thank my friend Matteo for cutting me the beautifull vinyl sticks for this project.

RGB leds are WS2812B, that types of leds are easy to drive.

For each of those sensor appropriate library are used.

Ambient noise and brightness are sampled 10 times per second, in order to give the led feedback almost instantly. Humidity and temperature have slower samplerate.
Ambient levels average it is computed and then posted to xively.com every minute.

Each parameter can be changed at compile time.

To run this project you have to create a new app in the Spark Build environment. Then you should add that libraries:
  • NeoPixel
  • AdaFruit_DHT
  • XivelyLIB
  • BH1750LIB
  • AudioGetAverageLIB
Add a config.h file to your project.
Copy and past the source of this project (see below for the project code), to your newly created file.
Edit the config.h according to your needs.
Now you should be able to compile this code and run it on your device.

It will be be easy to add new sensors.


  • read risk disclaimer
  • excuse my bad english

Saturday, August 1, 2015

AMQUMO: A Xively AMbient QUality MOnitor built on ATmega328

AMQUMO is an Indoor AMbient QUality MOnitor.

AMQUMO logs 4 environmental parameters:
  • Humidity
  • Temperature
  • Ambient Noise
  • Brightness

The data it is logged to the xively.com platform, and displayed to the user through 4 bi-color leds.

It can be used to monitor you Office Ambient Quality over the parameters logged.

This project it is built upon the xively logger ATmega328 library: http://davidegironi.blogspot.it/2014/12/a-web-configurable-xively-logger-build.html

So, a web page can be used to setup network parameters, and xively tokens.
Network can be set using a Static IP, Gateway, NET Mask, or DHCP.
Obviously xively feed number and API token can be setup by that web page.
Also the temperature sensor library expose a Celsius/Fahrenheit settings here.

EC28J60 board perform all the communications.

For humidity and temperature a DHT22 sensor it is used.
To measure ambient noise an analogic noise sensor built with a electret microphone and a opamp it is used.
Brightness it is measured by a BH1750 sensor board.

Ambient noise and brightness are sampled 2 times per seconds, in order to give the led feedback almost instantly. Humidity and temperature have slower samplerate.
Ambient levels average it is computed and then posted to xively.com every minute.

All that parameters can be changed at compile time by user.
Also it is quite simple to add your own sensor.

The PCB is quite simple, it's just a bridge board for a low cost Arduino Mini board and all the sensors board.
The main board and all sensor can be of course designed as a single board.
Note that the temperature and humidity sensor needs to be exposed outside the main electronics board, because both the EC28J60 chip and the voltage regulator heat up to almost 40 deg. and 
To solve this issue, a step down switching regulator should be used. And eventually another networking solution.

As references for optimal ambient threshold, some international standards and papers are taken in consideration.
  • Helsinki University of Technology: Effect Of Temperature On Task Performance In Office Environment [Olli Seppänen, William J Fisk, QH Lei]
  • ASHRAE Standard 62.1-2010
  • VAISALA - Increased human comfort from optimal indoor air humidity
  • University of Nebraska - Relating Productivity & Annoyance 
  • to Indoor Noise Criteria Systems: A Low Frequency Analysis [Erica E. Bowden & Lily M. Wang, Ph.D.]
  • Noise in The Office Workplace [Lorraine E. Maxwell]
  • Labour Department of HK - Lighting In Offices


  • read risk disclaimer
  • excuse my bad english

Friday, July 3, 2015

D02: a simple 80W Bass guitar amplifier built around the TDA7294 IC

As stated by the ST datasheet, the TDA7294 is a monolithic integrated circuit in. Multiwatt15 package, intended for use as audio class AB amplifier in Hi-Fi field applications.

D02, is a simple 80W Bass guitar amplifier.

I've some parts laying around that i decided to assemble in order to build a portable Bass guitar amplifier. I've a nasty 10" speaker, a power transformer, a car amplifier heatsink, and some other parts found in the on a "dumpster dive".
My friend Matteo gives me a speaker case he does not use more, he also cut's the stickers with his cutter plotter machine.

The circuit is really simple. The preamplifier it is build around a TL072 opamp. The first stage amplify the signal, the second does 3-tone balances.

The amplifier stage is pretty much the same of the ST TDA7294 datasheet, with just some value changed.

The circuit can be definitely improved. But just as it is now, it sounds pretty good.
The first improvement for this amplifier will be a better speaker.

  • read risk disclaimer
  • excuse my bad english

Tuesday, June 2, 2015

InLinea01: A PID controlled line following robot build on an ATmega 8

InLinea01 is a simple PID controlled line following robot.
This is not speed oriented line follower, this is just a prototype I built to experiment with this type or machines, though it can be the first step to build a faster one.

The goal of a line following robot is follow a line that is draw on the floor, usually this line is a black on white floor line, or a white on black one.
A sensor is needed to detect the line, and mantain the robot over the line.

This follower has two 200rpm @ 6v DC motors, driven by a L9110S H-bridge based controller board.

Detector is build using 8 cheap TCRT5000 reflective sensors. It can detect black on white, or white on black lines. The dection inversion must be decided at compile time.

It uses PID controller to make the robot follow the line smoother.
The PID parameters can be setup via UART using a GUI, the UART connection can be estabilished through a bluetooth adapter like the HC-05, if you use this type of connection, you can setup PID variables leaving cables out of the robot. That's pretty usefull for a line following robot.

The core of the robot is a ATmega8 microcontroller running at 8Mhz with his internal crystal.

A 7.4v LiPo battery powers the robot. Then an LM2596S based DC/DC converter regulated to 6v feed the 2 motors, and a LM7805 voltage regulator all other components.

In a few words, sensor detect the line. In order for the robot to follow the line, it has to be centered over it. To keep the robot in the middle of the line the speed of eveny wheel must be changed. The difference in speed of rotation determines the robot direction. That speed is evaluated by the PID controller depending on the position error.

As example, if the line is detected by the right detectors, then left motor has to spin less than the right one, that way the robot will turn a little on the left, and the line will be again in the center position.
The PID controller prevents robot oscillations and smooth his path.

  • 01c: fixed a typo error on schematics, thanks to Visweswara Rao Kalla for this feedback.
  • 01b: fixed a typo error on schematics, thanks to Abdullbasit AlHaita for this feedback.
  • 01: first release


  • read risk disclaimer
  • excuse my bad english

Wednesday, May 20, 2015

Radio France Fuzz - Silicon Fuzz pedal

"I've Got A Fuzzbox And I'm Gonna Use It"

This one is a silicon Fuzz pedal for guitar.
It's a standard silicon Fuzz Pedal circuit, made up using two common NPN transistors, the BC547, and the 2N5088.

I've try to "take it to the limit", to produce an extreme distorsion clipping sound.
There are three control points on this pedal:
  • the volume
  • the crunch switch, that's sets the gain to a low value
  • the stoner switch, that makes the pedal sounds thinner or fatter

It's called "Radio France" Fuzz, cause while playing with different components values on my breadboard, i can even even hear a radio transmission from France (likely AM), which is pretty distant from where i live. Luckly this doesn't happens on the preforated board, but it was enough for me to call it Radio France Fuzz.

The box is an aluminion chocolates from Lindt.

  • read risk disclaimer
  • excuse my bad english