Laser pointer discussion. Read/write reviews of laser pointers and laser pointer companies. Learn about all types of laser pointers and lasers





Welcome to Laser Pointer Forums! If you are looking for a laser pointer or want to compare different laser pointer companies, you may want to check out the LPF Laser Pointer Company Database. The link will open in a new window for your convenience.








Green Laser Pointers by Category Blue Laser Pointers by Category Red Laser Pointers by Category
Yellow Laser Pointers by Category Violet Laser Pointers by Category Orange Laser Pointers by Category
Top Laser Pointers by Power - 1 Watt+ Top Laser Pointers by Power - 500mW+ Top Laser Pointers by Power - 250mW+
Laser Pointer Database High Power Laser Pointers Laser Pointer Diodes
Laser Technology Laser Pointer Parts Lasers by Wavelength
Top 10 Laser Pointer Companies Laser Pointer Company Database Visible Beam Laser Pointers


One laser store meets all your needs

























Go Back   Laser Pointer Forums - Discuss Laser Pointers > Lasers > Laser Measurements



LPF List of Laser Pointer Companies (link opens new window)



Reply
 
LinkBack Thread Tools Display Modes
Old 08-14-2013, 08:59 PM #1
Trevor's Avatar
Class 3B Laser
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Trevor Trevor is offline
Class 3B Laser
Trevor's Avatar
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Default LPM Design: A Beginner's Guide

LPM Design: A Beginner's Guide

When I released OpenLPM in late 2011, the goal was to get more people tinkering with Arduino. But... there was one problem with OpenLPM. It had a bit of a steep learning curve. It sort of failed in its original objective to get a lot more people playing around with LPM's.

So here we are - I've decided to write a tutorial! Everything in this tutorial will be based on open source tools; primarily Arduino and Peregrine.

In this guide, I hope to prove that an LPM is just a conglomeration of very simple parts, and that it's totally possible to build one!

Part Zero - Getting Started

If this is your first time working with Arduino, I'd recommend going through the "Getting Started" guide, found here: Arduino - Getting Started

The first thing we'll do is upload the most basic program (also known as "sketches" by Arduino users) to the board so that we know it's working properly. This sketch is known as "Blink."

It simply blinks the onboard LED on and off.

Code:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup()
{                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop()
{
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}
A few things should be noted that are not covered by the comments in the code.

Rather than "naming" the pin, the statement "int led = 13;" is declaring an integer with the value being equal to the pin number; this just gives you the shorthand "led" to use instead of needing to remember what pin number the LED is hooked up to.

The statement "pinMode(led, OUTPUT);" sets that pin to an output mode. This allows it to be set at 0V or 5V (the two levels of the Arduino - logical LOW and logical HIGH), and allows you to control the LED using your code.

The statements enclosed by "/*" and "*/" are comments in the code and are ignored by the compiler. That encloses an entire block of lines as a comment. The other type of comment you'll see is preceded by "//" - it instructs the compiler to ignore anything on that line after the two slashes.

Lastly, the units for delay() are milliseconds.

With the super basics out of the way, let's move on to the basics!

Part One - Serial

At the core of any good LPM is datalogging, usually done over a serial line. This is prettymuch the easiest thing ever to do, so we'll start here.

Before we try to start sending any sort of actual data over the line, we'll start by just sending a dummy value.

You'll want to use the "Simple" protocol in Peregrine.

Code:
void setup()
{
  // First, we'll start serial running at 9600 bits per second.
  Serial.begin(9600);
}

void loop()
{
  // We print a dummy value out, terminated by
  // the end-of-transmission character, a newline (\n)
  Serial.print("1234.5\n");
  
  // Now we wait a little bit so we don't overload Peregrine.
  delay(50);
}
The graphing window will look like this:



Now, let's move to a changing value. We'll use a sine wave.

Our code now looks like this:

Code:
void setup()
{
  // Again, we'll start by setting up the serial line.
  Serial.begin(9600);
}

// We need a variable to store our angle to calculate the sine of.
// It's a floating point decimal.
float angle = 0.0;
void loop()
{
  // Calculate a value
  float outputVal = 1000.0 + 500.0 * sin(angle);
  
  // Increment the angle for the next iteration of the loop function
  angle += 0.01;
  
  // Output the value over serial, letting Arduino handle output formatting
  Serial.print(outputVal);
  
  // Output a newline to denote the end of a transmission.
  Serial.print("\n");
  
  // Wait 50ms so as to not overload Peregrine.
  delay(50);
}
Your output now looks something like this:



So there you have it - the most very basic aspects of getting an Arduino to send data to your computer.

In the next part, we'll discuss actually collecting data and transmitting it.

I'll try to get that written tonight. Until then, have fun tinkering.

Trevor


__________________
Code:
23:10 <ARG>    nothing has blown up yet :)
23:10 <Trevor> that is a distressingly low standard for success

Last edited by Trevor; 08-14-2013 at 09:04 PM.
Trevor is offline   Reply With Quote







LPF List of Laser Pointer Companies (link opens new window)







Old 08-15-2013, 12:01 AM #2
Meatball's Avatar
Class 3B Laser
 
Join Date: Feb 2008
Location: Lincoln, NE
Posts: 2,989
Rep Power: 242
Meatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond repute
Meatball Meatball is offline
Class 3B Laser
Meatball's Avatar
 
Join Date: Feb 2008
Location: Lincoln, NE
Posts: 2,989
Rep Power: 242
Meatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

Nice post! It's time we had more programmers around here. Any way we could get some C instructions going as well? Its good to have that extra flexibility where sometimes extra speed is needed. I've got some great UART C functions for the 328 I could post..
__________________
FIAT LUX

(\__/)
(='.'=)
(")_(")
Meatball is offline   Reply With Quote
Old 08-15-2013, 12:02 AM #3
Wolfman29's Avatar
Class 3B Laser
 
Join Date: Jan 2011
Location: Davis, CA
Posts: 3,828
Rep Power: 227
Wolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond repute
Wolfman29 Wolfman29 is offline
Class 3B Laser
Wolfman29's Avatar
 
Join Date: Jan 2011
Location: Davis, CA
Posts: 3,828
Rep Power: 227
Wolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond reputeWolfman29 has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

Very concise guide! I like it. I didn't know that Arduino basically ran on Java D: At least it looks like Java to me. But I often get C++ and java confused - haven't used them in a while.
Wolfman29 is offline   Reply With Quote
Old 08-15-2013, 12:11 AM #4
Class 4 Laser
 
Join Date: May 2007
Location: Queensland, AU
Posts: 7,549
Rep Power: 1100
Things has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond repute
Things Things is offline
Class 4 Laser
 
Join Date: May 2007
Location: Queensland, AU
Posts: 7,549
Rep Power: 1100
Things has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

Just to add to this, the pinMode function is a bit of an interesting one. It's purpose is to set the Arduino to a high impedance input, meaning if you try and use it as an output, it'll still work, but you'll have very limited current output, or an output to enable the full 20mA per pin. In the latest Arduino they also added INPUT_PULLUP to the pinMode function so that you can enable the internal pullups on the pins - a feature I've been waiting to see since the start!
Things is offline   Reply With Quote
Old 08-15-2013, 12:31 AM #5
Trevor's Avatar
Class 3B Laser
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Trevor Trevor is offline
Class 3B Laser
Trevor's Avatar
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

Quote:
Originally Posted by Meatball View Post
Nice post! It's time we had more programmers around here. Any way we could get some C instructions going as well? Its good to have that extra flexibility where sometimes extra speed is needed. I've got some great UART C functions for the 328 I could post..
Go for it! I was thinking I'd shy away from advanced C stuff, at least for the first sections of the guide, but you're welcome to post what you've got!

The more information is available, the better! Please, share!

Quote:
Originally Posted by Wolfman29 View Post
Very concise guide! I like it. I didn't know that Arduino basically ran on Java D: At least it looks like Java to me. But I often get C++ and java confused - haven't used them in a while.
Ohhh, believe me, it's going to get way less concise as I write more.

Arduino definitely runs on C, but the Arduino core includes a lot of abstraction layers that can make it look a lot like Java.

Trevor
__________________
Code:
23:10 <ARG>    nothing has blown up yet :)
23:10 <Trevor> that is a distressingly low standard for success
Trevor is offline   Reply With Quote
Old 08-15-2013, 12:52 AM #6
Class 4 Laser
 
Join Date: May 2007
Location: Queensland, AU
Posts: 7,549
Rep Power: 1100
Things has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond repute
Things Things is offline
Class 4 Laser
 
Join Date: May 2007
Location: Queensland, AU
Posts: 7,549
Rep Power: 1100
Things has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond reputeThings has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

The Arduino IDE is Java, but the language is not
Things is offline   Reply With Quote
Old 08-15-2013, 12:26 PM #7
Meatball's Avatar
Class 3B Laser
 
Join Date: Feb 2008
Location: Lincoln, NE
Posts: 2,989
Rep Power: 242
Meatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond repute
Meatball Meatball is offline
Class 3B Laser
Meatball's Avatar
 
Join Date: Feb 2008
Location: Lincoln, NE
Posts: 2,989
Rep Power: 242
Meatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond reputeMeatball has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

^^A lot of macros that are allowed in the IDE seem to also support C++ like functions. One can very easily save their arduino project files as .c/.cpp/.pde. or .ino.

I'll get some basic C/assembly stuff up here good for the arduino. Its really nice to be able to mix Wiring/C/assembly all into the same program.
__________________
FIAT LUX

(\__/)
(='.'=)
(")_(")
Meatball is offline   Reply With Quote
Old 08-20-2013, 06:04 PM #8
Trevor's Avatar
Class 3B Laser
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Trevor Trevor is offline
Class 3B Laser
Trevor's Avatar
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

In the hubbub of moving, I never finished part two. Here it is. Time to work on part 3.

Part Two - The ADC

The most basic function of an LPM is to translate a voltage value returned by the sensor into a digital value usable by the microcontroller.

For this example, we're going to use the internal analog-to-digital converter (ADC) in the Arduino. For an actual production LPM, it will be better to use an external ADC for higher resolution and accuracy, but for the purpose of this part of the tutorial, it is sufficient.

The ATMega328P has an internal 10-bit ADC. The number of bits determines how many steps it divides a voltage input into. The Arduino's ADC, having ten bits, can represent a voltage in 2^10 steps - so, a range of 0-1023. If its reference voltage (what the ADC compares a signal against) is 5V, that means that each step represents 4.89mV. For a signal from a sensor outputting 1V/W, that equals a resolution of 4.89mW.

For comparison, an external 16-bit ADC would return a range of 0-65,535, giving a resolution of 0.076mV.

Here's an image of the circuit I'm using. It's just a normal 10k potentiometer; +5V is connected to one leg, ground is connected to the other leg, and the wiper is hooked up to analog pin 0 on the Arduino.



Let's start with this little bit of code.

Code:
void setup()
{
  // Initialize serial
  Serial.begin(9600);
}

void loop()
{
  // Read from analog pin 0 and store the result
  // in an integer variable.
  int ADCVal = analogRead(0);

  // Let Arduino format and transmit the value
  Serial.print(ADCVal);
  
  // Send a newline to denote the end of the data packet.
  Serial.print("\n");
  
  // Wait so we don't overload the graphing software.
  delay(50);
}
The only real new steps we added were the call to analogRead() to get a value from the ADC and serial output in two steps instead of one. To keep the datastream simper and transmit fewer bytes, we're using Serial.print() instead of Serial.println().

When you get the Arduino connected to Peregrine, you can turn the potentiometer and change the value. By twiddling the dial, you can make some pretty crazy graphs.



Outputting a raw ADC value is cool, but let's map that value to a voltage.

So, let's changed up the code a bit.

Code:
void setup()
{
  // Initialize serial
  Serial.begin(9600);
}

void loop()
{
  // Read from analog pin 0 and store the result
  // in an integer variable.
  int ADCVal = analogRead(0);
  
  // Convert to a voltage
  float PowerVal = (ADCVal / 1023.0) * 5000.0;

  // Let Arduino format and transmit the value
  Serial.print(PowerVal);
  
  // Send a newline to denote the end of the data packet.
  Serial.print("\n");
  
  // Wait so we don't overload the graphing software.
  delay(50);
}
We've added another variable, named "PowerVal." It's a floating point decimal intended to hold the calculated power value (or voltage, if your signal isn't 1V/W). To convert the ADC value to a voltage, you divide it by the maximum possible value, then multiply it by the reference voltage, in this case, 5V - though I'm working in millivolts here, so I've put in 5000.

Now, you can turn the potentiometer and watch the signal swing from zero all the way up to the reference voltage, 5V.



At this point, if your signal isn't 1V/W, you would apply whatever scaler is necessary. You would also apply nonlinearity correction here.

So, if the signal is 0.1V/W, you would multiply PowerVal by 0.1 to have the correct power value.

That concludes part two. In part three, we'll add an LCD into the mix!

Trevor
__________________
Code:
23:10 <ARG>    nothing has blown up yet :)
23:10 <Trevor> that is a distressingly low standard for success

Last edited by Trevor; 09-09-2013 at 08:19 PM.
Trevor is offline   Reply With Quote
Old 08-21-2013, 11:30 AM #9
ped's Avatar
ped ped is offline
Class 3B Laser
 
Join Date: Nov 2008
Location: Liverpool , UK
Posts: 4,915
Rep Power: 7046
ped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond repute
ped ped is offline
Class 3B Laser
ped's Avatar
 
Join Date: Nov 2008
Location: Liverpool , UK
Posts: 4,915
Rep Power: 7046
ped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond reputeped has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

Quote:
Originally Posted by Trevor View Post
At the core of any good LPM is datalogging
* Coughs*

Or accuracy maybe?

Regards
__________________
@Ped0771

5000mW Coherent/Kenometer

Lazoors:
550mW C6 9mm lens
445nm Blord "Big Boy" 3.36w 9mm lens
445nm Jarob C6 kit (on 3rd diode) 1.9w 9mm lens
Various 532n nm 15mw pens ~ 600mW monster
515nm 34mW Direct Green Diode - LaserBtB
Various 650's - 1mW pens upto 300mW C6's
ped is offline   Reply With Quote
Old 08-21-2013, 05:24 PM #10
Trevor's Avatar
Class 3B Laser
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Trevor Trevor is offline
Class 3B Laser
Trevor's Avatar
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

Quote:
Originally Posted by ped View Post
* Coughs*

Or accuracy maybe?

Regards
Er. I just mean it's a core feature. There's (hopefully) more than one.



Trevor
__________________
Code:
23:10 <ARG>    nothing has blown up yet :)
23:10 <Trevor> that is a distressingly low standard for success
Trevor is offline   Reply With Quote
Old 08-22-2013, 12:21 AM #11
cheech226's Avatar
Class 3R Laser
 
Join Date: Jun 2011
Location: across the river from the big easy
Posts: 1,485
Rep Power: 1051
cheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond repute
cheech226 cheech226 is offline
Class 3R Laser
cheech226's Avatar
 
Join Date: Jun 2011
Location: across the river from the big easy
Posts: 1,485
Rep Power: 1051
cheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond reputecheech226 has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

Thanks for the understandable explanation trevor!
__________________
i have fond memories of owning
10 hene tubes 2 argon ion units and lots of diode and dpss lasers in these wavelengths:
405,445,450,458,473,488,532,543,594,612,632,635,650,685,780
I'm rebuilding my collection:
Skyray 405 12x
kryton groove gitd 445
B&W Tek 473 lab laser
JDSU 2214-40 multiline argon ion
Osram pl520 in an sh-032 host
Skylaser HL532-300
543 HeNe
632 HeNe x3
Opnext 638 single mode in c6 host
Rayfoss 650 150mW
Laserbee II Deluxe lpm w/ Peregrine
Laissez les bons temps rouler!
cheech226 is offline   Reply With Quote
Old 08-24-2013, 08:59 PM #12
ARG's Avatar
ARG ARG is offline
Super Moderator
 
Join Date: Feb 2011
Location: Canada
Posts: 6,987
Rep Power: 1994
ARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond repute
ARG ARG is offline
Super Moderator
ARG's Avatar
 
Join Date: Feb 2011
Location: Canada
Posts: 6,987
Rep Power: 1994
ARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

Good job with this guide Trevor! Putting it in simple terms for the new guys

+Rep when I can
ARG is offline   Reply With Quote
Old 09-08-2013, 07:31 PM #13
Trevor's Avatar
Class 3B Laser
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Trevor Trevor is offline
Class 3B Laser
Trevor's Avatar
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

As usual, pesky school keeping me from my laser work.

Part Three - Adding an LCD

Right now the basic LPM we've put together is functional - but can only output values over a USB connection. Pretty lame, in my opinion. Let's add a screen!

We'll use a standard 16x2 character LCD, supported by Arduino's LiquidCrystal library. More info on Arduino's support for the LCD can be found here: Arduino - LiquidCrystal

I'm using a shield from DFRobot that has the LCD plus a few buttons.

I have a voltage divider set up with the wiper hooked up to analog pin 3.

Today, our code will get a bit more complex. I'll go through the changes step-by-step.

First, we obviously need to include the library. We'll also need to include stdio, so we have access to sprintf() for LCD output.

Code:
#include <LiquidCrystal.h>
#include <stdio.h>
Second, we need to add a line to initialize the LCD and tell the LiquidCrystal library what Arduino pins are attached to the LCD pins.

Code:
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Next, we go into the setup() function and add three lines of code.

Code:
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("LPM Example Code");
This starts up the LCD with a size of 16x2, sets the cursor at position 0 on line 0, and shows the text "LPM Example Code".

Now, we need to add some code to the loop() function.

Code:
char buf[17];
sprintf(buf, "ADC Value:  %4d", ADCVal);
This declares a region of memory as an array of 17 characters (enough to have 16 characters and a null terminator), then uses sprintf() to put the ADC value into a string and place it in our array of characters.

The string we passed to sprintf() is known as the format. We want our LCD to look something like "ADC Value: 54" - and always have the number right-aligned. So, we have "ADC Value:" (10 characters) plus two spaces, leaving four characters for the reading, which will range from 0 to 1023.

Finally, we add a flag for sprintf(). The "%" sign tells sprintf() that it needs to place a value. The "4" immediately following it tells sprintf() that if the number converted to a string has fewer than 4 characters, pad with spaces. Lastly, the "d" tells sprintf() that the value it is printing is decimal - base 10.

Now, we add this code to place this text on the LCD on the second line:

Code:
lcd.setCursor(0, 1);
lcd.print(buf);
So, our final code looks like this:

Code:
#include <LiquidCrystal.h>
#include <stdio.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
  Serial.begin(115200);
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("LPM Example Code");
}

void loop()
{
  int ADCVal = analogRead(3);

  char buf[17];
  sprintf(buf, "ADC Value:  %4d", ADCVal);
  
  lcd.setCursor(0, 1);
  lcd.print(buf);
  
  Serial.print(ADCVal);
  Serial.print("\n");
  
  delay(50);
}
You get this:



Well, that's all fine and good, but let's read the voltage!

Alter your loop() function to this:

Code:
void loop()
{
  int ADCVal = analogRead(3);

  float Voltage = ( (float)ADCVal / 1023.0 ) * 5000.0;

  char buf[17];
  sprintf(buf, "Voltage:  %4dmV", (int)Voltage);
  
  lcd.setCursor(0, 1);
  lcd.print(buf);
  
  Serial.print(Voltage);
  Serial.print("\n");
  
  delay(50);
}
All we did was remap the ADC value ( 0 - 1023 ) to the range of the reference voltage of the Arduino ( 0 - 5000mV ).

You'll end up with this result:



That's great - but let's move this all to the context of lasers, shall we?

In addition to switching to "mW" as our unit, let's add a peak reading! All you have to do is check to see if your current reading is greater than your peak reading. If it is, update the line for the peak.

I've also added a splash screen that displays for one second, and initial strings to display on the LCD once readings start.

Code:
#include <LiquidCrystal.h>
#include <stdio.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
  Serial.begin(115200);
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  
  lcd.begin(16, 2);
  
  lcd.setCursor(0, 0);
  lcd.print("LPM Example Code");
  lcd.setCursor(0, 1);
  lcd.print("       by Trevor");
  
  delay(1000);
  
  lcd.setCursor(0, 0);
  lcd.print("Power:       0mW");
  lcd.setCursor(0, 1);
  lcd.print("Peak:        0mW");
}

float PeakPower = 0.0;
float VoltsPerWatt = 1.0;

void loop()
{
  int ADCVal = analogRead(3);

  float Power = ( (float)ADCVal / 1023.0 ) * 5000.0 * VoltsPerWatt;

  char buf[17];
  sprintf(buf, "Power:    %4dmW", (int)Power);
  lcd.setCursor(0, 0);
  lcd.print(buf);
  
  if(Power > PeakPower)
  {
    sprintf(buf, "Peak:     %4dmW", (int)Power);
    lcd.setCursor(0, 1);
    lcd.print(buf);
    
    PeakPower = Power;
  }
  
  Serial.print(Power);
  Serial.print("\n");
  
  delay(50);
}
So, now we have this!



To my eye, that's a pretty capable power meter. Paired with an Ophir 20C-A and an external ADC, this would exceed the capabilities of the classic Kenometers, the Radiant Alpha, and every LaserBee product (including the $600 model!). Not too shabby for a few minutes' work with a soldering iron and a little bit of code!

Parts four and five will be by ARG, and will cover how to further advance an LPM design.

Trevor
Attached Thumbnails
LPM Design: A Beginner's Guide-tsw_7933.jpg   LPM Design: A Beginner's Guide-tsw_7935.jpg   LPM Design: A Beginner's Guide-tsw_7938.jpg  
__________________
Code:
23:10 <ARG>    nothing has blown up yet :)
23:10 <Trevor> that is a distressingly low standard for success
Trevor is offline   Reply With Quote
Old 09-08-2013, 08:01 PM #14
Blaster's Avatar
Class 3R Laser
 
Join Date: Jul 2013
Location: Adelaide , South Australia
Posts: 1,172
Rep Power: 107
Blaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond repute
Blaster Blaster is offline
Class 3R Laser
Blaster's Avatar
 
Join Date: Jul 2013
Location: Adelaide , South Australia
Posts: 1,172
Rep Power: 107
Blaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond reputeBlaster has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

hi not sure where to put in this reply so here goes i noticed that the output from a laserbee 3.7usb seems by many other LpMs to be about 10% lower in actual power, than shown buy most other LPMs, any reason, a few posts actually have LPM from another LPM and then Then usb 3.7 and in every case it shows at least 10% down on output compared to others, which is great if my lasers are 10% more power than shown, but are they ?
__________________
Blasters Lasers and Gear
95 mW 405nm custom 501b
102 mW 405 nm custom C6
125 mW 405 nm focus-able 501b
270 mW 405 nm 20MM Cannon shell focus-able
705 mW 405 nm focus-able 501b G2 lens

865 mW 445 nm Kryton Groove
1130 mW 450 nm focus-able custom
1175 mW 450 nm focus-able S4

1375 mW 445 nm WL ARCTIC S3
2.3 watt 445 nm G2 -Cree Q5
3.1 watt +Adj 445 nm Blitzbuck V3.1 9mm SS Survival host

95 mW 532nm custom focus-able
110 mW 532 nm S4 host
125 mW 532 nm SD 305A x 2
135 mW 532 nm SD 301 focus-able x2

135 mW 532 nm focusable laser SD 303 x2
175 mW 532 nm custom focus-able

494 mW 532 nm O like Crown*
100 mW 589 nm
PGL III C
115 mW 635 nm custom C6 host
800 mW 635 nm Hotlights host G1 lens

155 mW 645 nm custom 501b host
160 mW 650 nm focus-able C6 host
255 mW 650 nm SD301
280 mW 650 nm SD302
260 mW 660 nm custom C6 host
505 mW 660 nm custom C6 host
45 mW 650 red and 114 mW 532nm multi laser
350mW 830 nm IR custom C6 focus-able
Another
4 dozen plus 5 mW to 160 mW in all colors Way overspec ebay pens
LaserBee 3.7W USB Laser Power Meter
Blaster is offline   Reply With Quote
Old 09-08-2013, 08:06 PM #15
Trevor's Avatar
Class 3B Laser
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Trevor Trevor is offline
Class 3B Laser
Trevor's Avatar
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 4,506
Rep Power: 2565
Trevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond reputeTrevor has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

The only way you'll know for sure is if you have your LPM side-by-side with a known accurate one and compare.

Trevor
__________________
Code:
23:10 <ARG>    nothing has blown up yet :)
23:10 <Trevor> that is a distressingly low standard for success
Trevor is offline   Reply With Quote
Old 09-08-2013, 08:08 PM #16
ARG's Avatar
ARG ARG is offline
Super Moderator
 
Join Date: Feb 2011
Location: Canada
Posts: 6,987
Rep Power: 1994
ARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond repute
ARG ARG is offline
Super Moderator
ARG's Avatar
 
Join Date: Feb 2011
Location: Canada
Posts: 6,987
Rep Power: 1994
ARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond reputeARG has a reputation beyond repute
Default Re: LPM Design: A Beginner's Guide

Quote:
Originally Posted by Blaster View Post
hi not sure where to put in this reply so here goes i noticed that the output from a laserbee 3.7usb seems by many other LpMs to be about 10% lower in actual power, than shown buy most other LPMs, any reason, a few posts actually have LPM from another LPM and then Then usb 3.7 and in every case it shows at least 10% down on output compared to others, which is great if my lasers are 10% more power than shown, but are they ?
Could be your LPM that is out, could be the other persons, could be the laser.

I think the most likely reason is that it could be the response time. If everyone else is using an Ophir head, it will show the true output power before it drops due to the heat in the pointer. Compare the laser output at 30s on their chart, to the number you get.

The only way to know with 100% certainty is to test your LPM with a stable laser against a NIST traceable LPM. If you want I can test it for you and let you know.

Last edited by ARG; 09-08-2013 at 08:09 PM.
ARG is offline   Reply With Quote
Reply





Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On











Loading








Green Laser Pointers by Category Blue Laser Pointers by Category Red Laser Pointers by Category
Yellow Laser Pointers by Category Violet Laser Pointers by Category Orange Laser Pointers by Category
Top Laser Pointers by Power - 1 Watt+ Top Laser Pointers by Power - 500mW+ Top Laser Pointers by Power - 250mW+
Laser Pointer Database High Power Laser Pointers Laser Pointer Diodes






Privacy Policy | Advertising Disclaimer | Terms of Use


 


All times are GMT. The time now is 02:05 PM.


Powered by: vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO
Privacy Policy | Advertising Disclaimer | Terms of Use
Copyright (C) 2017 Laser Pointer Forums, LLC