Welcome to Laser Pointer Forums - discuss green laser pointers, blue laser pointers, and all types of lasers

LPF Donation via Stripe | LPF Donation - Other Methods

Links below open in new window

ArcticMyst Security by Avery

Laserbee raw output now visible in OSX environment

Joined
Jul 4, 2008
Messages
2,499
Points
113
Doing some experimenting with data acquisition/ software for Arduino environment today and
got raw data capturing from my Laserbee II 3.2W pro today working.

CAUTION:
The output is in the format 0,0 -- 100mW looks like 100,100. The first digits are mW the second being current in mA.

I need to figure out how to separate these numbers and run time vs output in mW.



Instructions:

This is what I did so that OSX can see raw output from the laserbee.

Download the driver for the USB to serial adapter.

Download Arduino Environment from their website. Its about a 70Mb download.
Alternatively you can also use Zterm 2.0 or even FunTerm OSX This also works.

Alright, follow these instructions carefully.
This one is using the arduino program.

Go into usb to serial monitor mode inside the arduino environment ( under tools) and connect at 9600 baud

immediately you'll see 0,0 appearing on the monitor window.

use you laserbee like you'd do normally. You'll now see the output in mW as the laserbee

sees it. You'll start to see a string of numbers appearing representing raw data coming from

your meter. Once finished measuring. stop the meter and highlight your number string and
cut and past into numbers or Excel... done.

This is was a test to see if MacOS X10.7 can see the laserbee's output.

I think making a MacOSX laserbee app for OSX will be quite simple.

My hope is that a MacOSX based completely opensource Laser app could be made
so that everyone can record in realtime with precision the output of their LPMs, Laserbee, Kenometer, and even the DIY'ers.

An idea? This post is in no way meant to undermine developers. It is meant to allow flexibility utilizing multiple platforms.
 

Attachments

  • Screen Recording.mov
    2.6 MB · Views: 200
Last edited:





Joined
Jul 4, 2008
Messages
2,499
Points
113
Ok...

Anyone know how to filter the results so that 0,0 looks like 0.

How do I filter the incoming data stream in Zterm or FunTerm?
 
Joined
May 31, 2009
Messages
3,239
Points
63
You will need to parse the input to the serial monitor. Use the ',' character to split the data in order to ignore the first part of the input and only read the last part.

You can write the same code into Processing and turn it into a Java applet so you can use it as a standalone program.

It will also be able to export to CSV which can be imported to excel and turned into a graph or can also generate its own graph and export as a jpg image.

There are a lot of options.
 

Trevor

0
Joined
Jul 17, 2009
Messages
4,386
Points
113
You can write the same code into Processing and turn it into a Java applet so you can use it as a standalone program.

...I didn't know you could do that. I'll need to look into it.

I'll start Googling things... if you have suggestions for required reading, I'm all ears.

Viva open-source. :D

Trevor
 

Things

0
Joined
May 1, 2007
Messages
7,517
Points
0
I don't have a laserbee so I can't test it, but try this:

EDIT: Oops, I see you need a program for the computer, not on Arduino. Oh well, it's here anyway :p

Code:
boolean mAmode = false;

void setup(){
  Serial.begin(9600);
}
  
  void loop(){
  char t;
   int mW;
   int mA;
  

   if(Serial.available() > 0) // If there is data to read
   {
     mA = 0;
     mW = 0;
     mAmode = false;
	    while(Serial.available() > 0) // While there is still data
	    {
		 t = Serial.read(); // Read character

		 if(t == ','){
                    mAmode = true;
		 }
                 if(t >= '0' && t <= '9') { // If it's a number
                   if (mAmode == true){
		      mA *= 10; // Multiply previous value by 10
		      mA += t - '0'; // Add the new digit
		   } 
                    else {
                      mW *= 10; // Multiply previous value by 10
		      mW += t - '0'; // Add the new digit
                   }
                 }    
		 else
		    break;
		 delay(50);
	    }
            Serial.print("Time: ");
            Serial.println((millis() / 1000));
            Serial.print("mW: ");
            Serial.println(mW);
            Serial.print("mA: ");
            Serial.println(mA);
	 }
   }

Dan
 
Last edited:
Joined
Jul 4, 2008
Messages
2,499
Points
113
That's nice. How do I see the 0,0 as just 0 or for example 123,123 as 123?
I'm using FunTerm or ZTerm in MacOSX.
No way to parse the data?
 
Joined
May 31, 2009
Messages
3,239
Points
63
ZTerm and FunTerm are a terminal program right?

As far as I know most can not be programmed, but if it can, just parse the input. Similar to what Things did, but in the language the terminal program understands.
 

Trevor

0
Joined
Jul 17, 2009
Messages
4,386
Points
113
Okay, so I spent a few hours today learning the ins and outs of making an interface in processing, and this is what I've got so far:

yBQ0z.jpg


That Arduino is running a LaserBee emulator.

It will run on PC/Mac/Linux. Autoranging graphing area, etc. I'm going to grab a cup of coffee and keep working on it. :D

Trevor
 
Last edited:
Joined
Jul 4, 2008
Messages
2,499
Points
113
ZTerm and FunTerm are a terminal program right?

As far as I know most can not be programmed, but if it can, just parse the input. Similar to what Things did, but in the language the terminal program understands.

Yes, those are terminal programs.
I was messing around earlier on today with an application called qtdmm.It's free. It can see the laserbee as a DMM and read and parse the data real time. However the saved file is useless for doing any kind of graphing.
9600Baud, 2stop bits, 14bytes ASCII polling metex voltcraft, 2000 digits. Once connected it will show laserbee as a DMM in real time. Logging doesn't seem to work. Date stamp and time stamp is added but the output is 9,9 9,9.... ??? DUnno what happend there.
 

Trevor

0
Joined
Jul 17, 2009
Messages
4,386
Points
113
...and this is what a few more hours of work yielded:

bJYvU.png


To do:
- Finish X-axis labels.
- Add a data display.
- Add graph/log saving.
- Add session management.
- ...some other things that I'm forgetting.

Trevor
 
Joined
May 31, 2009
Messages
3,239
Points
63
Looks good man! If you need a hand let me know... but looks like you know what your doing.

<3 open-source projects!
 
Joined
Oct 26, 2007
Messages
5,438
Points
83
See if this works in Processing. I didn't run/compile it, but I don't think there are any errors:

Code:
import processing.serial.*;

Serial port;        // The serial port

static final int PORT           = 0; // Which port in the list
static final int WIDTH          = 1023;
static final int HEIGHT         = 300;
static final int HEIGHT2        = 10;
static final int MAX_VALUE      = 2000; // Max value 
static final int DIGITS         = 4; // Digits for each field

int x = 0;
boolean on = false; // Variable for alternating colors as graph draws

int field0 = 0;
int field1 = 0;
int phase = 0;



void setup() 
{
    size(WIDTH, HEIGHT + HEIGHT2);
    println(Serial.list());
    port = new Serial(this, Serial.list()[PORT], 9600);
    background(0);
    println("begin");
}

void draw()
{
    while (port.available() > 0)
    {
        int value = port.readChar();

        // State machine to synchronize the data frames:
        switch (phase)
        {
        case 0:
            // First field.  Collect and parse numbers until a comma is found:
            if (value == ',') // A comma, ASCII = 0x2C
            {
                phase = 1;
            }
            else if ((value >= 48) && (value < 58)) // 0-9
            {
                field0 *= 10;
                field0 += (value - 48); // Remove ASCII offset
            } else {
                // Something else.  Restart the synchronization.
                field0 = 0;
                field1 = 0;
                phase = 0;
            }
            break;
        case 1:
            // Second field. Collect and parse numbers until a CR or LF is
            // found:
            if ((value == 0xD) || (value == 0xA)) // CR or LF
            {
                phase = 2;
            }
            else if ((value >= 48) && (value < 58)) // 0-9
            {
                field1 *= 10;
                field1 += (value - 48); // Remove ASCII offset
            } else {
                // Something else.  Restart the synchronization.
                field1 = 0;
                field1 = 0;
                phase = 0;
            }
        case 2:
            // Draw our graph:
            float fValue = field0; // Floating point version of value
            float h = map(fValue, 0, MAX_VALUE-1, 0, HEIGHT-1);
            stroke(0,0,0);
            line(x, 0, x, HEIGHT-1);
            if (on)
            {
                stroke(127,34,255);
            } else {
                stroke(255,128,0);
            }
            line(x, HEIGHT, x, HEIGHT - h);
            DrawBottom();

            phase = 0;
            field0 = 0;
            field1 = 0;
            break;
        }
    }
}

void DrawBottom()
{
    if (on)
    {
        stroke(128,128,128);
    } else {
        stroke(64,64,64);
    }
   
    line(x, HEIGHT, x, HEIGHT + HEIGHT2);

    if (++x > WIDTH)
    {
        x = 0;
        on = !on;
    }
}

It grabs characters from the serial port, parses them in "###,###" format (and assumes a linefeed at the end) into numeric values, and then graphs them.
 
Joined
May 31, 2009
Messages
3,239
Points
63
Error: Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 0

Code:
port = new Serial(this, Serial.list()[PORT], 9600);

Would it be because I don't have a device connected at that baud rate?
 




Top