4096 Step Laser Analog Driver

Spindles & Lasers.
Forum rules
Be Kind to other's.
No Cussing or Swearing.
Don't post anything Illegal or Obscene.
Image attachment size limit is 500 KiB.
rwensley
Posts: 29
Joined: Fri Oct 30, 2015 2:55 pm

4096 Step Laser Analog Driver

Postby rwensley » Mon Nov 16, 2015 1:48 pm

Greetings, NOTE ************** THIS IS VERSION 2.0 UPDATE YOUR FILES *****************************

I have been experimenting with this concept for a couple of weeks and I feel I am getting good results.

Attached is the schematic for this circuit and below is the code for it.

If you have any questions please let me know.

Ron Wensley

/* This program is deigned to act as an interface between the grbl UNO board
* and your laser driver analog input.
* 0 = laser off
* -4095 = laser maximum
*
* stated another way
* when Z-Axiz = 0 there is 0 volts sent to the laser driver
* when Z-Axis = -1 there is 5 volts sent to the laser driver
*
* Z step/mm set to 4095
* Z Feedrate should be set to 439.5604 mm/min
* Z Max Depth set to -1 mm
*
*/

#include <Wire.h>
#include <Adafruit_MCP4725.h>

Adafruit_MCP4725 dac;

#define STEP 2 // digital pin 2 = interrupt 0
#define DIR 3 // digital pin 3 not used as an interrupt in this project

int pulseCounter = 0;

void setup()
{
Serial.begin(115200);
Serial.println("grbl Interface");

attachInterrupt(STEP - 2, IRQhandler, RISING);
pinMode(dir,INPUT_PULLUP);

dac.begin(0x62);
}

void loop()
{
if (pulseCounter > 0)
{
pulseCounter = 0;
}
if (pulseCounter < -4095)
{
pulseCounter = -4095;
}

dac.setVoltage(map(pulseCounter, 0, -4095, 0, 4095), false);
}

void IRQhandler()
{
if (! digitalRead(DIR))
{
pulseCounter++;
}
if (digitalRead(DIR))
{
pulseCounter--;
}
}

Stepper to Analog.png
Stepper to Analog.png (22.45 KiB) Viewed 10941 times
Last edited by rwensley on Sat Nov 21, 2015 8:36 am, edited 6 times in total.

User avatar
Picengravertoo
Full Access Moderator
Posts: 1092
Joined: Thu Dec 18, 2014 4:02 pm
Contact:

Re: 4096 Step Laser Analog Driver

Postby Picengravertoo » Tue Nov 17, 2015 9:58 am

Hi Ron,

That's ingenious! :respect)

Can you post your laser engraving results using your DAC?

Thanks.
Jeff

rwensley
Posts: 29
Joined: Fri Oct 30, 2015 2:55 pm

Re: 4096 Step Laser Analog Driver

Postby rwensley » Tue Nov 17, 2015 1:35 pm

Jeff,

I already did it is labeled First Success in the gallery.

Ron

rwensley
Posts: 29
Joined: Fri Oct 30, 2015 2:55 pm

Re: 4096 Step Laser Analog Driver

Postby rwensley » Tue Nov 17, 2015 1:40 pm

I should have stated that I built the prototype circuit on a arduino screw terminal proto-board. This allowed for the greatest flexibility until an integrated board is developed. Most of the parts are available from adafruit.com except the LM358. Sometime Radio Shack has them, if not JameCo.com will.

Have fun !

rwensley
Posts: 29
Joined: Fri Oct 30, 2015 2:55 pm

Re: 4096 Step Laser Analog Driver

Postby rwensley » Fri Nov 20, 2015 10:37 am

Jeff,

In the schematic I provided delete the LM358 op-amp. It is not needed. The output of the DAC can drive the laser driver directly.

The original post has been edited and updated to reflect the changes.

Ron

User avatar
Picengravertoo
Full Access Moderator
Posts: 1092
Joined: Thu Dec 18, 2014 4:02 pm
Contact:

Re: 4096 Step Laser Analog Driver

Postby Picengravertoo » Fri Nov 20, 2015 1:32 pm

Thanks Ron.

User avatar
Picengraver
Full Access Moderator
Posts: 381
Joined: Tue Dec 23, 2014 5:40 pm
Contact:

Re: 4096 Step Laser Analog Driver

Postby Picengraver » Sat Nov 21, 2015 5:27 pm

Ron,
Very nicely done. Thanks so much for sharing.
I plan to soon dust off my breadboard to test your setup with an Arduino Nano and one of the 8 bit DAC chips (MCP4602 ?).

I will post my findings here when I have them.

rwensley
Posts: 29
Joined: Fri Oct 30, 2015 2:55 pm

Re: 4096 Step Laser Analog Driver

Postby rwensley » Mon Nov 23, 2015 11:15 am

There is an 8 bit DAC by MicroChip MCP4901. It is SPI instead of I2C.

Leparti83
Posts: 4
Joined: Sat Jan 02, 2016 1:25 pm

Re: 4096 Step Laser Analog Driver

Postby Leparti83 » Mon Jan 11, 2016 5:47 pm

Hi
This was interesting. Actually you don't need any extra chip to do 10bit. Arduino has it's own timer, which can do 8,10,12 and even 16 bits :) i made actually code (using partially your code) on arduino which also reads Z step and dir pulses and outputs 10 bit pwm, which can be adjusted to 12 or 16 bits.

Tero

User avatar
Picengraver
Full Access Moderator
Posts: 381
Joined: Tue Dec 23, 2014 5:40 pm
Contact:

Re: 4096 Step Laser Analog Driver

Postby Picengraver » Mon Jan 11, 2016 9:07 pm

Thanks Tero,
Please share your results when you have some to share.
John


Return to “Hardware Discussions”

Who is online

Users browsing this forum: No registered users and 5 guests

cron