Parallax 28044 User Manual

Web Site: www.parallax.com Forums: forums.parallax.com Sales: sales@paral la x.c om Technical: support@parallax.com
Office: (916) 624-8333 Fax: (916) 624-8003 Sales: (888) 512-1024 Tech Support: (888) 997-8267
Parallax Laser Range Fi nd er (#28044)
Designed in co njunction with Grand Idea St udio (www.grandideastudio.com), the Parallax Laser Range Finder (LRF) Module is a distance-measuring instrument that uses laser technology to calculate the distance to a targeted object. The design uses a multicore Propeller microcontroller, CMOS camera, and laser diode to create a low-cost laser range finder. Distance to a targeted object is calculated by optical triangulation using simple trigonometry between the centroid of laser light, camera, and object.
Features
Optimal measurement range of 6–48
inches (15–122 c m) with an accuracy error <5%, average 3%
Maximum object detection distance of
~8 feet (2.54 meters)
Range finding sample rate of 5 Hz
Key Specifications
Power requirements: 5 VDC @ 150 mA
  Communication: Asynchronous serial
300–115,200 baud with automatic baud rate detection
Operating temperature: 32 to 122 °F
(0 to 50 °C)
Compact module with integrated CMOS
camera and laser diode
Single row, 4-pin, 0.1” header for easy
connection to a host system
All engineering materials released as
open source under a Creative Commons license; see page 23
Table of Contents
Connections .................................................... 2
Usage ............................................................ 2
Command Set ................................................. 3
Range and Accuracy ...................................... 10
Error Modes .................................................. 10
Electrical Characteristics ................................ 11
LRF Image Viewer ......................................... 12
Dimensions: 3.95" W x 1.55" H x 0.67" D
(10.05 W x 3.95 H x 1.7 D cm)
Application Ideas
Distance or liquid level measurements
  Object detection and/or avoidance Item counting
Hardware Design .......................................... 15
Theory of Operation ...................................... 16
Camera Interface .......................................... 19
Care and Handling ........................................ 22
Safety .......................................................... 22
Open Source Files and Example Code ............. 23
Revision History ............................................ 23
Copyright © Parallax Inc. Parallax Laser Range Finder (#28044) v2.0 10/31/2015 Page 1 of 23
Pin
Name
Type
Function
1
GND
G
System ground. Connect to power supply’s ground (GND) terminal.
2
VCC
P
System power. 5 VDC input.
3
SOUT
O
Serial output to host. 5 V TTL-level interface, non-inverted, 8 data bits, no parity, 1 stop bit, baud rate matched to host.
Connections
The LRF Module i nterfaces to any hos t microcontroller or computer system usi ng only four connect ions (GND, VCC, SOUT, SIN).
4 SIN I Serial input from host. 3.3 V to 5 V TTL-level interface, non-inverted, 8 data
bits, no parity, 1 stop bit, baud rate matched to host.
Type: I = Inpu t, O = Output, P = Power, G = Ground Use the following example circuit for connecting the Parallax Laser Range Finder Module:
Usage
The LRF Module is controlled by the host via a serial communications interface. To use, simpl y align the LRF Module towards the target object and send the desired command.
The serial interface is configured for 8 data bits, no parity, 1 stop bit (8N1). Automatic baud rate detection occurs on initial power-up of the LRF Mod ule. The Module wait s for a “U” character to be sent by the host and will se t its baud rate t o match that of the host . Supported ba ud rates include 3 00, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, and 115200.
When the LRF is ready to receive commands, it will send a “:” to the host. The LRF wait s in an idle state until it receives a valid command, at which time it performs the command and returns command-specific data (if any). The LRF will return a “?” u pon receiving an invalid command.
Copyright © Parallax Inc. Parallax Laser Range Finder (#28044) v2.0 10/31/2015 Page 2 of 23
The camera system used in the LRF Module has automatic white balance, automatic exposure, and automatic gain control enabled by default, and will automatically adjust its image to account for sud den changes in lighting con diti ons. How ever , the LR F work s best i n a controlle d en vironm ent, s uch as i ndoors with minimal changes in brightness across the frame. The LRF is also less reliable when the laser is shining onto a bright object (for example, a white piece of paper), since the background subtraction performed during image processing could potentially “subtract” the bright laser from the already bright frame.
Status Indicator
A visual indication of the LRF Module’s operating state is given with the on-board LED (Light-Emitting Diode). The LED is l ocated on the ba ck side of the LRF nea r the center of the board. The LED denotes four states of the LRF:
1. Green: Idle state. Waiting for a command to be sent by the host.
2. Red: Active s tate . For ex ample, p erformi ng a rang e calcula tion or capturi ng an i mage wit h the camera.
3. Orange (Solid): Baud rate detection state. The LRF is waiting for a “U” character to be sent by the host in order to a utomatically set the communi cations baud rate . Occurs on LRF power-up only.
4. Orange (Blinking): Error sta te. The LRF has malfunctioned. A message ident ifying the failed operation will be transmitted on the SOUT (Serial Out) pin. See Error Modes, page 10, for details.
If the LED is OFF, the LRF may not be receiving power.
Command Set
All commands are single-byte, ASCII p rintable values and are not case-sensitive (upper case and lower case will both work). No carriage return (CR) or linefeed (LF) is required after the command byte is sent. Depending on the command, data may be returned by the LRF.
The command descriptions in this section are for LRF firmwa re version 2.0. For command descriptions of earlier firmware versions, refer to product manual version 1.1. Examples are shown for direct connection to a microcontroller (BASIC Stamp 2) and/or to a host PC via a terminal program.
Basic Commands R B L E S T V H
Single range measurement (returns a 4-digit ASCII value in millimeters) Single range measurement (returns a 2-byte binary value in millimeters) Repeated range measurement (any subsequent byte will stop the loop) Adjust camera for current lighting conditions Reset camera to initial settings Toggle laser on/off Display ver si on inf or mation Display available commands
Copyright © Parallax Inc. Parallax Laser Range Finder (#28044) v2.0 10/31/2015 Page 3 of 23
Capture & send processed frame (320x16, 8 bits/pixel grayscale) w/ background subtraction
Advanced Commands O X A G C
Display coordinate, mass, and centroid information for all detected blobs Calibrate camera system for range finding Adjust blob detection parameters Capture & send single frame (160x128, 8 bits/pixel grayscale) Capture & send single frame (320x16, 8 bits/pixel grayscale) w/ laser enabled
P
Command Details
R: Single range measurement (ASCII)
Takes a single range finding measurement and returns the distance to the target object as a printable ASCII string (“D = ”) with a
4-digit decimal
milliseconds to complete. The LRF Module is most accurate within its optimal measurement range of 6–48 inches (15–122 cm ). In
ideal conditions, a distance measurement of up to ~8 feet (2.54 meters) may be possible. While the accuracy will be hindered at distances outside o f the optimal range, the LRF co uld still be used for gross distance measurements or simple object detection. See Range and Accuracy, page 10, for details.
Terminal Example:
:R D = 0288 mm :
BS2 Example:
SEROUT LRF_TX, LrfBaud, ["R"] ' Send command
' Wait for distance measurement and store it as a decimal value SERIN LRF_RX, LrfBaud, 3000, No_Response, [WAIT("D = "), DEC4 range]
B: Single range measurement (binary)
Takes a single range finding measurement and returns the distance to the target object as a
value in millimeters. Data is sent MSB first. A range measurement takes ~200 milliseconds to
binary
complete. The LRF Module is most accurate within its optimal measurement range of 6–48 inches (15–122 cm ). In
ideal conditions, a distance measurement of up to ~8 feet (2.54 meters) may be possible. While the accuracy will be hindered at distances outside o f the optimal range, the LRF co uld still be used for gross distance measurements or simple object detection. See Range and Accuracy, page 10, for details.
Terminal Example:
:B <binary data> :
BS2 Example:
SEROUT LRF_TX, LrfBaud, ["B"] ' Send command SERIN LRF_RX, LrfBaud, 3000, No_Response, [range.HIGHBYTE, range.LOWBYTE]
value in millimeters. A range measurement takes ~200
2-byte
Copyright © Parallax Inc. Parallax Laser Range Finder (#28044) v2.0 10/31/2015 Page 4 of 23
L: Repeated range measurement
Continuously calls t he Sing l e rang e m ea sure me nt ( ASCII) command (“R”). O nce the loop has starte d, a ny subsequent byte sent to the LRF Module will stop the command. Each range measurement takes ~200 milliseconds to complete.
Terminal Example:
:L D = 0288 mm D = 0289 mm D = 0289 mm D = 0289 mm <any key pressed> :
E: Adjust camera for current lighting conditions
Calibrates the LRF Module’s camera for the current lighting conditions. This may aid the camera in successfully detecting the laser spot within the frame, which increases accuracy of the range finding functionality.
The command first e nsures that a utomatic white balance (AWB), automatic exposure control (AEC), and automatic gain control (AGC) are enabled. Then, after a 10 second delay for the camera image to settle, AWB, AEC, and AGC are disabled. The EV/exposure level is also reduced to a minimum value. This will cause the entire camera frame, including any previously bright areas, to appea r dark. A bright laser spot may now be more easily identifiable within the frame.
The camera’s settings can be reset to their default with the “S” command. Terminal Example:
:E <short delay> :
BS2 Example:
SEROUT LRF_TX, LrfBaud, ["E"] SERIN LRF_RX, LrfBaud, [WAIT(":")]
S: Reset camera to initial settings
Resets and initializes the LRF Module’s camera to its default, power-up configur ation, including e nabling automatic white balance (AWB), automatic exposure control (AEC), and automatic gain control (AGC). It may take up to 10 seconds for the camera image to settle after the command is sent.
This command is particularly helpful when the “E” command has been used to adjust the camera for current lighting cond itions and the user wishes to reset the camera settings w ithout power cycling the LRF Module.
Terminal Example:
:S :
BS2 Example:
SEROUT LRF_TX, LrfBaud, ["S"] SERIN LRF_RX, LrfBaud, [WAIT(":")]
Copyright © Parallax Inc. Parallax Laser Range Finder (#28044) v2.0 10/31/2015 Page 5 of 23
T: Toggle laser on/off
Allows for manual control of the laser diode. The command will toggle the laser diode on and off. Commands that make use of the laser diode (“R”, “B”, “L”, “O”, “X”, “C”, and “P”) will supersede the state set using this command.
Terminal Example:
:T <laser diode on> :T <laser diode off> :
BS2 Example:
SEROUT LRF_TX, LrfBaud, ["T"] ' Turn laser diode on SERIN LRF_RX, LrfBaud, [WAIT(":")] SEROUT LRF_TX, LrfBaud, ["T"] ' Turn laser diode off SERIN LRF_RX, LrfBaud, [WAIT(":")]
V: Display version information
Lists version and calibration information for the LRF Module. This data is useful for troubleshooting and debugging.
FW: Firmware revision (major.minor) MFG and PID: Manufacturer ID and Product ID of the LRF’s on-board camera SLOPE, INTERCEPT, PFC_MIN: Device-specific values calculated during the calibration process
(“X”) and used for range finding (if the LRF Module is uncalibrated, the values will all be 0xFFFFFFFF)
LOWER_BOUND , UPPER_BOUND, BLOB_MASS_THRESHOLD: Parameters used for blob detection
during the range finding process. The values default to those shown in the example output below, but can be changed using the “A” command.
Terminal Example:
:V Parallax Laser Range Finder Designed by Grand Idea Studio [www.grandideastudio.com] Manufactured and distributed by Parallax [support@parallax.com]
FW = 2.0 MFG = 7FA2 PID = 7691 SLOPE = +0.001418615 (3AB9F0CE) INT = -0.009308979 (BC1884B0) PFC_MIN = 28 LOWER_BOUND = 50 UPPER_BOUND = 255 BLOB_MASS_THRESHOLD = 16 :
Copyright © Parallax Inc. Parallax Laser Range Finder (#28044) v2.0 10/31/2015 Page 6 of 23
H: Display available commands
Lists all available commands that the LRF Module supports. Terminal Example:
:H Basic Commands: R Single range measurement B Single range measurement (binary response, 2 bytes) L Repeated range measurement (any subsequent byte will stop the loop) <more commands listed, but not shown in this manual> :
O: Display coordinate, mass, and centroid information for all detected blobs
Displays coordinate, mass, and centroid (center of m ass) information for up to 6 detected blobs within the camera’s field-of-view. This information can be used for custom im age proce ssing or ob ject dete ction outside of the sta ndard LRF Module functio nality. The blob detection begins on the left side of the frame and “scans” to the right. See Image Pr ocessing a nd Blob Detection, page 20, for details.
L: X coordinate of the beginning (left side) of the detected blob R: X coordinate of the end (right side) of the detected blob M: Mass of blob (sum of all valid pixels within the blob) C: Centroid (center of mass) of blob <: Marker to indicate if the blob is less than the BLOB_MASS_THRESHOLD *: Marker to indicate the blob with the largest m ass (primary blob)
In many cases, if a single blob is detected within the frame, it is likely t he laser spot. In other cases, there may be reflections of the laser light or other spots that are not related to the laser. Generally, the blob with the largest mass within the frame can be c onsidered the actual laser spot.
Terminal Example:
:O 0: L = 81 R = 88 M = 14 C = 84 < 1: L = 137 R = 232 M = 917 C = 181 * 2: L = 235 R = 254 M = 170 C = 244 :
X: Calibrate camera system for range finding
To account for manufacturing and assembly variances, particularly related to the camera and laser diode alignments, each LR F Module must be ca librated. This occ urs during producti on, but the LRF ca n be re­calibrated by the user at a later date if desired. If a new major version of firmware is loaded (for example, upgrading from firmware version 1.0 to 2.0), the LRF will need to be re-calibrated.
The calibration routine requires the user to place the LRF Module at 6 fixed distances (from 20 cm to 70 cm at 10 cm intervals), measured from the front face of the LRF circuit board. The LRF takes measurements at each distance a nd calculates the SLOPE, INTERC EPT, and PFC_MI N values. The va lues are then stored in an unused portion of the non-volatile boot Serial EEPROM. They will remain intact during a power cycle .
Copyright © Parallax Inc. Parallax Laser Range Finder (#28044) v2.0 10/31/2015 Page 7 of 23
Loading...
+ 16 hidden pages