Parallax Rangefinder Basics

Hallo community,

I have purchased a Laser rangefinder from Parallax. Quite a new product and theres still not to much information outhere, except for a project in measuring distance in Weekly Hacks written by Dino.

I have been trying and I have problems with the library, which still I dont understand in new versions of the Arduino software. I would like to encourage someone to explain the basics of this sensor, just to understand what is what and how can one figure out then whats needed for their own purposes. Is it possible to avoid the libraries stuff? Please share knowledge about this new sensor those who had the chance to work with it. I will keep my research and write down what i discover if it so...

thanks a lot.

Please provide a link to the datasheet for the sensor, and a link to the library.

LASER link the information to it. http://www.parallax.com/product/28044#downloads

LIBRARY http://arduino.cc/es/Reference/SoftwareSerial

How can one start generating communication in between computer (arduino) and laser module by Serial? Didnt get yet anything more than the on back LED light. Would like to know, at least theres functionality...

Thanks

You could take a look at https://bitbucket.org/eagletusk/parallax-lrf/ which I believe is a sketch for interfacing the Parallex laser range finder to an Arduino Mega, and adapt it to use SoftwareSerial. Personally, I don't trust important data to SoftwareSerial.

Yes, thats what I tried. The library is not being recognized I think, nothing happens. Tried already the example of the library with a LED, nothing that makes me think is alive.

How would you communicate with this device if its not without the SoftwareSerial library? Is there any other choice?

Thanks!

Inzo:
Yes, thats what I tried. The library is not being recognized I think.

What makes you think that? Did you manage to compile the sketch after adapting it to SoftwareSerial, or not? What changes did you make to the sketch?

Inzo:
How would you communicate with this device if its not without the SoftwareSerial library? Is there any other choice?

If you are using a Mega or a Leonardo then you can use a hardware serial port. On a Uno, you’re stuck with SoftwareSerial, assuming you want to use the hardware serial port for the serial monitor.

I dont get in a UNO the orange color of the library name that tells me its working. I have checked my libraries, and everything looks ok, the library is there.

I wrote it just the same as the informatrion i founded outthere:

#include <SoftwareSerial.h>

#define rxPin 4 // connect to the LRF’s SOUT pin
#define txPin 3 // connect to the LRF’s SIN pin thru a 4.7k resister

SoftwareSerial lrfSerial = SoftwareSerial(rxPin, txPin);

I downloaded the “NewSoftSerial” library, and with this one, the library is recognized, but what I got from the developers website is that for arduino 1.0 up is not necessary to install.

http://arduiniana.org/libraries/newsoftserial/

“NewSoftSerial is in the core! Starting with Arduino 1.0 (December, 2011), NewSoftSerial has replaced the old SoftwareSerial library as the officially supported software serial library. This means that if you have 1.0 or later, you should not download this library. To port your code to 1.0, simply change all NewSoftSerial references to SoftwareSerial.”

Dont really get the point of it…

PD: thanks for the UNO tipp, thats useful.

Inzo: I dont get in a UNO the orange color of the library name that tells me its working. I have checked my libraries, and everything looks ok, the library is there.

If the modified sketch compiles OK, then it has found the library.

Finally tested in an Arduino MEGA, which provides from default up to three Serial possibilities.

The code is a simplification of a code found outhere. Tested in Arduino 1.0.4

/* 5v to VCC GND to GND 18 uart1 with SIN 19 uart1 with SOUT */

int incomingByte; int incomingByte1;

void setup() { // initialize both serial ports: Serial.begin(9600); //Serial Monitor to LRF Serial1.begin(9600); //LRF to Serial Monitor

Serial.write('U'); Serial.write('E');

}

void loop() { // read from port 1, send to port 0: if (Serial1.available()) { int inByte1 = Serial1.read(); Serial.write(inByte1); }

// read from port 0, send to port 1: if (Serial.available()) { int inByte = Serial.read(); Serial1.write(inByte); } }

//---------------------------------------------

For testing the basics, upload the code and open the serial monitor. Send R and will recieve a distance measurement as answer.

More code solutions will come.