Group,
I'm nearing completion of my 80 watt laser setup and wanted to share some information on how to use an Arduino Uno board and a relay board to control certain features of the laser machine.
For example:
Using a SPDT switch, you can turn on/off the air pump that pumps air into the laser beam.
Using a SPDT switch, you can turn on/off the 5vDC red dot laser.
Using the 5vDC output to LASER1 when it is turned on/off, start/stop an LED timer display.**
** Marco, am I correct to assume that when the DSP controller turns on the laser, the 5vDC output on LASER1 turns on and when the DSP controller turns the laser off, that 5vDC output is turned off?
I purchased the following items for this control:
Arduino Uno Board - https://www.sparkfun.com/products/11021
SPDT Pushbuttons (2) - https://www.sparkfun.com/products/11972
5vDC Power Supply to power Arduino Uno - http://www.ebay.com/itm/141082066753?ss ... 1439.l2649
Programmable Digital Timer - http://www.lightobject.com/Programmable ... -P464.aspx
4 Channel 5 Volt Relay Board - http://www.ebay.com/itm/321302843841?ss ... 1439.l2649
Arduino Uno is a programmable mini-computer which can read input signals both digital and analog and turn on/off output to 5vDC devices. It uses a simple programming language that makes it possible to customize its operation to suit your needs. See the Arduino website to learn more about its capabilities and to download the software needed to program it. http://www.arduino.cc/
So, I downloaded the Arudio software and wrote the following program that will control the functionality I needed. Being a programmer with tons of experience in C, embedded systems, web development and an Apple iOS developer, the code was quite easy for me. :
const int airpushbutton = 2; // air push button connected to pin 2
const int reddotpushbutton = 3; // red dot push button connected to pin 3
const int airoutpin = 12; // pin 12 connected to IN1 on relay board which takes 5vDC
const int dotoutpin = 13; // pin 13 connected to red dot laser which takes 5vDC
const int laserout = 11; // pin 11 connected to IN2 on relay board which takes 5vDC
void setup() {
pinmode(airpushbutton, INPUT); // set pin 2 as an input pin for air button
pinmode(reddotpushbutton, INPUT); // set pin 3 as an input for red dot laser button
pinmode(airoutpin, OUTPUT); // set pin 12 as an output of 5vDC to relay 1 input
pinmode(dotoutpin, OUTPUT); // set pin 13 as an output of 5vDC directly to the red dot laser
pinmode(laserout, OUTPUT); // set pin 11 as an output of 5vDC to relay 2 input
}
void loop() {
int airbuttonstate = digitalRead(airpushbutton);
int dotbuttonstate = digitalRead(reddotpushbutton);
int sensorValue = analogRead(A0);
if (airbuttonstate == HIGH) { // if the air pushbutton was pressed
digitalWrite(airoutpin, HIGH); // turn on pin 12 sending 5vDC to the relay board
}
else {
digitalWrite(airoutpin, LOW); // otherwise, turn pin 12 off thus turning off the air pump
}
if (dotbuttonstate == HIGH) { // if the red dot button was pressed
digitalWrite(dotoutpin, HIGH); // turn on pin 13 sending 5vDC to the red dot laser
}
else {
digitalWrite(dotoutpin, LOW); // otherwise turn the red dot laser off
}
if (sensorValue == 1023) { // if this value is 1023 then it means that 5vDC is present on pin A0
digitalWrite(laserout, HIGH); // so turn on pin 11 sending 5vDC to relay 2 on the relay board thus turning on power to the digital timer
}
else {
digitalWrite(laserout, LOW); // otherwise turn off power to the digital timer
}
}
So let me explain what this code does. First, some constants are defined. Constants are memory storage areas in the Arduino board that are storing information that will not change.
Pin 2 on the Arduino board will be connected to one pin on the push button that will be used to turn on/off the air pump. (the other pin on the push button will be connected to ground on the Arduino board).
Pin 3 will on the Arduino board will be connected to one pin on the push button that will be used to turn on/off the red dot laser.
Pin 12 on the Arduino board will be connected to input 1 on the relay board.
Pin 13 on the Arduino board will be connected directly to the 5vDC pin on the red dot laser. The other pin on the red dot laser will be connected to ground on the Arduino board.
Pin 11 on the Arduino board will be connected to input 2 on the relay board.
Here's what happens in the Loop portion of the code:
First the inputs are read into variables. Variables are memory storage areas on the Arduino board that store information that can and will change based on the state of various devices connected to the board.
Then tests are performed on these read values. If the air pushbutton is pressed it will be registered by the Arduino when it reads the input on pin 2 (high means it's been pushed and engaged or turned on, low means it's been pushed and disengaged or turned off).
If the button has been engaged, a HIGH value will be registered and as such, pin 12 will be turned on sending 5vDC to the relay board. When this happens, the relay board will engage relay 1 completing a connection that turns on the air pump.
If the button has been disengaged, a LOW value will be registered and as such, pin 12 will be turned off which will cause relay 1 to turn off thus turning off the air pump.
The same holds true when reading pin 3 on the Arduino board. If it's HIGH, then pin 13 is turned on sending 5vDC to the red dot laser. If it's LOW, the red dot laser is turned off.
The last read value is an analog one. Here is where pin A0 on the Arduino board is read to see if it has 5vDC applied to it. This dc input comes from the DSP, 5vDC pin on the LASER1 output. When the Arduino sees that it has 5vDC on pin A0, it then turns on pin 11 sending 5vDC to relay 2 on the relay board. This in turn energizes the relay thus turning on power to the digital timer which turns on and continues to accumulate the number of hours that the laser has been running (accumulative hours).
It's important to note that the timer is powered by 120 volts AC and the air pumps is as well. The relay board takes 5vDC as its input. It doesn't output 120v though. Instead, it acts as a light switch. So in wiring, the black wire of your 120 v AC goes to one pin of the relay and another wire comes out of the relay on another pin (I believe there's a drawing of how a relay is wired somewhere in the forum) going to the device. This wire isn't electrically connected until the relay energizes which completes the AC circuit thus turning on the device.
The Arduino is programmed by connecting a USB cable from your computer to the board (it has a USB type B socket on it). Once you write the code in the supplied Arduino editor that you downloaded, you can upload the code to the board. Once uploaded. You can disconnect the USB from the board and it will retain the code you uploaded until you upload new code.
I hope this will be helpful to others who would like to implement these features into their laser cutter/engraver build.
Bob Hunt
Using Arduino Uno with DSP Controller
-
- Posts: 66
- Joined: Wed Apr 16, 2014 3:40 am
- Contact:
-
- Posts: 4654
- Joined: Mon Jun 15, 2009 3:00 pm
- Contact:
Re: Using Arduino Uno with DSP Controller
Bob:
To turn on air pump or air compressor or doing counting, you don't need to add Arduino controller board. What you need is a relay logic board, an electric vale (only if you use air compressor), and a digital counter. The DSP has output signal OUT1 and OUT2 can take care it. The +5V is always ON when DSP is powered up. For counting sure a non-contact trigger mechanisum is better than relay though. The only advantage to use the relay board is its simplity
Relay I/O board: http://www.lightobject.com/24V-relay-br ... -P840.aspx
Air value (12V or 24V): http://www.lightobject.com/Search.aspx?k=air%20valve
Digital counter: http://www.lightobject.com/Programmable ... -P464.aspx
Marco
To turn on air pump or air compressor or doing counting, you don't need to add Arduino controller board. What you need is a relay logic board, an electric vale (only if you use air compressor), and a digital counter. The DSP has output signal OUT1 and OUT2 can take care it. The +5V is always ON when DSP is powered up. For counting sure a non-contact trigger mechanisum is better than relay though. The only advantage to use the relay board is its simplity
Relay I/O board: http://www.lightobject.com/24V-relay-br ... -P840.aspx
Air value (12V or 24V): http://www.lightobject.com/Search.aspx?k=air%20valve
Digital counter: http://www.lightobject.com/Programmable ... -P464.aspx
Marco
-
- Posts: 66
- Joined: Wed Apr 16, 2014 3:40 am
- Contact:
Re: Using Arduino Uno with DSP Controller
Hi Marco,
Yes, I have the digital counter but was planning on using it to keep track of the number of hours of usage on the laser. So is there a way electronically to detect when the laser is on and when it is off?
So you are saying that the 5v on LASER1 is always on?
Bob
Yes, I have the digital counter but was planning on using it to keep track of the number of hours of usage on the laser. So is there a way electronically to detect when the laser is on and when it is off?
So you are saying that the 5v on LASER1 is always on?
Bob
-
- Posts: 4654
- Joined: Mon Jun 15, 2009 3:00 pm
- Contact:
Re: Using Arduino Uno with DSP Controller
Yes, the +5V is contant output and won't change at all in referrence to the GND (ground)
For the Out1 and Out2, it is "Level Low" logic. When no action is taken, the output from the OUT1 and OUT2 is always "HIGH" or 5V in reference to the ground. When XY is moving or laser is firing, the output is "Level Low" means that it output "0V" but consider is "Active". With the I/O board, you don't worry the Level High or Level Low issue (confuse to many folks). You just power it with the board 24V and has the input pin connect to the OUT1 or OUT2, it will show nice trigger seamless
Here is output from OUT1 and OUT2:
OUT1: Output "High" when XY start to move. OK to use this output to control air-pump On or Off as "Air-pump" take time to pump air out and slow
OUT2: Output "High" when laser is firing:
A) Note that there is no output when XY is moving. It is ideal to use it to control an air-valve when use "Air compressor" as air-assist. Faster action
B) Use the same output to trigger a timer/counter for counting laser usage.
(Note the difference between an Air-pump and an Air-compressor. )
The counter memorieze usage even with power lost. You can reset the time by hitting "RESET". Otherwise, it will keep counting up. Better to install it inside of the machine to avoid other personel reset the timer. I will use it to charge my customer to use the laser machine.
Marco
For the Out1 and Out2, it is "Level Low" logic. When no action is taken, the output from the OUT1 and OUT2 is always "HIGH" or 5V in reference to the ground. When XY is moving or laser is firing, the output is "Level Low" means that it output "0V" but consider is "Active". With the I/O board, you don't worry the Level High or Level Low issue (confuse to many folks). You just power it with the board 24V and has the input pin connect to the OUT1 or OUT2, it will show nice trigger seamless
Here is output from OUT1 and OUT2:
OUT1: Output "High" when XY start to move. OK to use this output to control air-pump On or Off as "Air-pump" take time to pump air out and slow
OUT2: Output "High" when laser is firing:
A) Note that there is no output when XY is moving. It is ideal to use it to control an air-valve when use "Air compressor" as air-assist. Faster action
B) Use the same output to trigger a timer/counter for counting laser usage.
(Note the difference between an Air-pump and an Air-compressor. )
The counter memorieze usage even with power lost. You can reset the time by hitting "RESET". Otherwise, it will keep counting up. Better to install it inside of the machine to avoid other personel reset the timer. I will use it to charge my customer to use the laser machine.
Marco
-
- Posts: 66
- Joined: Wed Apr 16, 2014 3:40 am
- Contact:
Re: Using Arduino Uno with DSP Controller
That's great, thanks Marco, I understand now so will use OUT1 and OUT2 to control counter and air pump.
In another tread you talked about a safety switch on the door and using an input to shut everything off if the door is open. Can you explain how that works, which input to use. Can I use a simple limit switch for this safety measure?
Thanks,
Bob
In another tread you talked about a safety switch on the door and using an input to shut everything off if the door is open. Can you explain how that works, which input to use. Can I use a simple limit switch for this safety measure?
Thanks,
Bob
Who is online
Users browsing this forum: No registered users and 5 guests