What is LightSensorArray

LightSensorArray
User Guide
What is LightSensorArray
LightSensorArray is an array of 8 sensors to
detect color equivalent gray scales in front of the
sensor window. It has a built in light source for
each of it’s sensors and it can detect and
differentiate dark and light shades.
Connections and Placement
LightSensorArray can be connected to any of the four sensor ports of NXT
by using standard cables from NXT set, or FlexiCable from mindsensors.com.
While attaching sensor to your robot, face the long clear sensor window
towards the mat, placing it approx 5 millimeters above the mat surface
(approx ¼ inch).
If you plan to use this sensor to track a line, place the sensor in front of the
driving wheels – (in the direction the robot will be moving).
Mounting LightSensorArray on your contraption
The holes on the LightSensorArray enclosure are designed for
tight fit of Technic pins (or axles) with ‘’ cross section. The
holes however are not designed for repeated insertions/removals
of these pins.
To mount LightSensorArray on your contraption we suggest that you use two
dark gray ‘Technic Axle 3 with Stud’ as shown.
Insert axles from the top of the LightSensorArray and secure with a
bushing on the back or mount it on your contraption directly.
Alternately, you may use blue ‘Technic Axle Pin with Friction’, as
shown.
While disassembling contraption, leave the pins on LightSensorArray.
Sensor Calibrations
NOTE
For best results, LightSensorArray should be calibrated for the surface it
will be used on. To calibrate the sensor, keep the sensor window on white
area, and calibrate white. Then keep the sensor window on black area and
calibrate black. While placing on the white or black area, ensure that all
sensors are over the same color surface.
Executable program (LSA-calib.rxe) is available for calibration, which you
can download from mindsensors.com website at following location:
Copyright © 2012 mindsensors.com
1/6
http://www.mindsensors.com/index.php?
module=documents&JAS_DocumentManager_op=viewDocument&JAS_Docum
ent_id=219
Upload this program to your NXT using the ‘NXT Window’ of your NXT-G
IDE. Following instructions explain how to upload executable program on your
NXT:
http://www.mindsensors.com/index.php?
module=pagemaster&PAGE_user_op=view_page&PAGE_id=105
Alternately, LightSensorArray NXT-G block has a calibration feature to
calibrate the sensor.
Sensor Operations
You can use the raw sensor readings of the sensor and compute yourself
whatever you need from it. The raw values are returned as byte per sensor
with 0 indicating black and 100 indicating white.
NOTE
In order to write a good line follower program, you will need to know and
understand the ‘PID Control Theory’. http://www.google.com/search?
q=PID+control+theory
http://en.wikipedia.org/wiki/PID_controller
PID without a PhD
Programming Techniques
NXT-G:
Download the NXT-G blocks available in the NXT-G Blocks
Repository at Mindsensor’s website, at following location:
http://www.mindsensors.com/index.php?
module=documents&JAS_DocumentManager_op=viewDocument&JAS_Docum
ent_id=217
Also download sample programs from following location, and modify to suit
your needs.
http://www.mindsensors.com/index.php?
module=documents&JAS_DocumentManager_op=viewDocument&JAS_Docum
ent_id=220
NOTE: Ensure to use latest firmware on your NXT Brick.
You can also obtain Mindsensors enhanced firmware here:
http://www.mindsensors.com/index.php?
module=pagemaster&PAGE_user_op=view_page&PAGE_id=137
Copyright © 2012 mindsensors.com
2/6
RobotC:
The driver implementation is available in Xander's driver suite at
following url:
http://botbench.com/blog/category/programming/robotc-drivers/
the header file for the driver is: mindsensors-lightsensorarray.h
NXC:
Download the sample programs and library file available at following location,
and include the library file it in your program by #include directive as:
#include “LSA-lib.nxc”
http://www.mindsensors.com/index.php?
module=documents&JAS_DocumentManager_op=viewDocument&JAS_Docum
ent_id=219
Alternately, you can modify the sample programs to suite your needs.
I2C Registers:
The LightSensorArray appears as a set of registers as follows:
Register
0x000x07
0x080x0f
0x100x17
Read
Firmware version – Vxxxx
Write
-
Vendor Id – mndsnsrs
-
Device ID – LSArray
-
0x41
Register
0x42 –
0x49
Read
Calibrated Sensor reading - Reading measured
for each of the sensor in the array. Higher
value indicates brighter object. (one byte for
each sensor – 8 bytes)
White Reading Limit (threshold above which
color is identified as white)
Black Reading Limit (threshold below which
color is identified as black)
White Calibration data - Calibration value for
White color for each sensor. (one byte for
each sensor – 8 bytes)
Black Calibration data - Calibration value for
Black color for each sensor (one byte for each
sensor – 8 bytes).
Command
Write
-
0x4A –
0x51
0x52 –
0x59
0x5A0x61
0x620x69
Copyright © 2012 mindsensors.com
-
-
3/6
0x6A0x79
Uncalibrated sensor voltage (Integer values,
two bytes for each sensor)
Copyright © 2012 mindsensors.com
-
4/6
Supported I2C Commands:
CMD
W
B
D
P
A
E
U
Description
Calibrate White
Calibrate Black
Put Sensor to sleep
Wake up the sensor
Configure Sensor for US region (and regions with 60
Hz electrical frequency).
Configure sensor for European region (and regions
with 50 Hz electrical frequency)
Configure sensor for universal frequency (in this mode
the sensor adjusts for any frequency, this is also the
default mode).
Reading Frequency
The array of sensors is reading at 7 milliseconds interval.
Note however, your reading speed from sensor is throttled by the I2C speed
of your NXT firmware (in firmware 1.29 it is around 17 milliseconds per
reading operation).
Physical Specs
Weight: 0.53 oz (14.8 grams)
Foot-print: 24.5mm x 72.6 mm
Height: 20.75 mm
Current Consumption
To conserve power, the sensor goes to sleep after 1 minute of inactivity. The
sensor will wake up on its own when any activity begins. You can also wake it
up (or put to sleep) via command. Average measured current profile is as
follows:
Current Consumption
Duration
5.7 mA (max)
While awake Depending on your mat
colors ratio, this will vary between
3.5 mA to 5.7 mA
3.0 mA
While sleeping
I2C Bus address
Factory Default Address: 0x14
Changing the I2C Bus Address:
Copyright © 2012 mindsensors.com
5/6
The I2C bus address of LightSensorArray can be changed. To set an
address different from default address, send sequence of following
commands on the command register:
0xA0, 0xAA, 0xA5, <new I2C address>
Note: Send these commands with no break/read operation in between. This
new address is effective immediately. Please note down your address
carefully for future reference.
You can download the address change and scan functions from our website at
www.mindsensors.com. These functions are written in RobotC.
Alternately, you can download NXT executable programs from following
location: http://www.mindsensors.com/index.php?
module=documents&JAS_DocumentManager_op=viewDocument&JAS_Docum
ent_id=91
Doing your own PID Control
If you wish to write your own PID control, following urls and references
would be useful.
An excellent reference describing PID control:
http://en.wikipedia.org/wiki/PID_controller
A Google search on PID Control theory yields several informative artifacts http://www.google.com/search?q=PID+control+theory
An article from Embedded Systems: PID without a PhD
(http://www.embedded.com/2000/0010/0010feat3.htm)
Copyright © 2012 mindsensors.com
6/6