Line-Following Robot Using LSA08 in Serial Mode with Digital Output

Introduction

Good day,

The Advanced Auto-Calibrating Line Sensor (LSA08) is capable to operate in three different modes: digital, analog, and serial. In this tutorial, I am going to show you how to make a line following robot using LSA08 in serial mode with Arduino Uno board. However serial mode of LSA08 support 3 different output modes: 8-bit digital data representing each sensor state (1 or 0), 1 byte data that representing the line position (0 – 70), 8 continuous data bytes that representing analog reading of each sensor. For this tutorial I will introduce the basic of LSA08 in serial mode, with 8-bit digital data output.

Preparation

Before we could start, let’s take a look at what we needed.

Hardware:

and some materials for robot base.

Software:

Arduino IDE – an open source Integrated Development Environment used to program Arduino board. You can download it here.

Procedures

Alright, now we have all we need, let’s start by making a robot base. 1…2…3……

Here we go, a robot base~

In case you wondering the steps of robot making, you can view it here. A small precaution here is to make sure that the base is larger than 20cm x 20cm, so you can mount everything we need on it.

So the next thing is to mount everything on it, like this…

Here is the connection that you will need, we will discuss about the connection of LSA08 after this.

Notice that I did not connect 5V pin on MDD10A because there is no such pin on my real board, you have to connect it to 5V pin on your Arduino board if such pin exist.

A switch is highly recommended to avoid your robot running away once you connect the battery =P.

In the end, your connection should looks like the one at left.

(Click the image for larger view)

Working with LSA08

Still with me? I assume that you are here. So the next thing is to talk about LSA08 as I promised.

Figures at the left shows the Advanced Auto-Calibrating Line Sensor (LSA08) line sensor that I always mentioned about. What makes it different with the normal Auto-Calibrating Line Sensor (LSS05) is that it has the word “advanced” in its name (of course).

LSA08 has 8 sensor array rather than 5 in LSS05, besides it also allows the user to manually select the line sensing option through its setting menu.

Here is the list of available setting for LSA08. More explanation about the setting menu will be discussed later.

(Click the image for larger view)

We have the pin layout for PORTA which is used for serial and analog mode.

The connection is as shown in the table below:

 LSA08 pinArduino Uno board
1RX (pin 0)
2TX (pin 1)
3digital pin 2
4not used
5digital pin 4
6not used
7not used
8not used
9Vin
10GND

*NOTE: make sure this is PORTA, and input voltage ranging from 7.5V – 20V

All done? Good, after that we can really talk about the setting menu. First, power up your board, and you will see something like this.

The 8 bars at the top display the sensor value for each sensor. The number at the bottom left of LCD display the current line position, while the ‘J’ at the bottom right will show up whenever it crossed a junction.

Now, pressing the MODE button on board will bring you to the setting menu. In the setting menu, press MODE button to loop over the menu, and pressing SEL button will enter to option setting.

Pressing SEL button in option setting allow you to choose the desired option for that setting, and press MODE when the LCD display the desired option will save the setting and return to setting menu.

Let’s see what we can do with the setting menu.

LCD Contrast (LCD CON)

Use this setting to adjust the contrast of LCD display.

Calibration (CALB)

Pressing SEL will put your LSA08 into calibration mode, and you have to start moving sensors across the black line like there is no tomorrow =P.

Line Mode (LINEMODE)

Allows user to choose either Light-On mode or Dark-On mode. Sensor will output 1 when detect white surface, 0 when detect dark surface during Light-On mode, and vice versa.

Threshold (THRES)

Allows user to set the number of bar chart on LCD required for LSA08 to assumes it as a valid line detected.

Junction Width (J WIDTH)

Allows user to set the number of sensors detect line in order for LSA08 to assumes as a junction cross.

UART Address (UART ADD)

Allows user to identify which LSA08 the user refers to when working with multiple LSA08. Address for each LSA08 in  the same system must be unique to avoid ambiguous cases.

UART Baudrate (BAUDRATE)

Allows user to select the baudrate used in UART serial communication.

The baudrate can be set as list below:

No.Baudrate
09600
119200
238400
357600
4115200
5230400

UART Mode (UARTMODE)

Allows user to choose the output send to host (stated above) when UART output enable pulled LOW.

No.Mode
0no data output
18-bits digital output
21 byte analog output
38 continuous bytes of analog output package

LCD Backlight (LCD B/L)

Allows user to choose a suitable backlight for LCD. Value 0 means the backlight is OFF.

Exit (EXIT)

Press SEL button to exit the menu, or press and hold MODE in setting menu will also bring you back to line display screen.

For complete information on LSA08 setting, please refer to its user manual from Cytron’s product page.

LSA08 also allows user to set the configuration through UART serial communication with following specification:

And here is the command reference table:

(Click the image for larger view)

The command send to LSA08 must be in 4 continuous bytes within 20ms in the arrangement of:

|Address | Command | Data | Checksum|

where Checksum is the sum of Address, Command, and Data, if the result is more than 1 byte, only lower byte is taken. So we can simply say that:

Checksum = LowByte(Address + Command + Data)

LSA08 will respond with “OK” for every successful command received. However, for command such as retrieving line position, and junction count will be replied with the data requested instead.

You can download the source code at attachment below.

Upload the sketch commandTest.ino into your Arduino board, and it will help you to configure the LSA08 into a setting that is suitable for our line following task to work.

Video below shows how this program works.

After that, upload LSA08Serial.ino sketch to Arduino board, and run the program. If your robot moving in a wrong way, try changing the polarities of your motor, or changing the state values where I mentioned in the source code.

Finally, if you have any question, feel free to ask in our technical forum as we seldom check the tutorial’s comment section.

Video

Buy

, , ,

Related Post

How to Make your Line Following Robot Faster?

Control Mobile Robot through WiFi with ESP-WiFi Shield (Arduino + Andriod)

Smartphone Controlled Wheel Robot

Arduino + 2A motor + Encoder

Arduino + 2A Motor Shield + Encoder Motor

2 thoughts on “Line-Following Robot Using LSA08 in Serial Mode with Digital Output

  1. hi… i am also design above type of line following robot for robotics competition… in my case first i want to follow bright line in dark background(first area). after that robot complete the first area it entering to the second area. in this second area robot should follow the dark line in bright background. so i want to know whether LSA08 sensor can be used to my application. because i am confuse when it calibrate to detect bright line in dark background how should i change the calibrating setting to detect dark line in bright background.

Leave a Reply

Your email address will not be published. Required fields are marked *