LSA08 is an Advance Line Following Sensor bar with build up with 8 pair of super bright green LED as the sensor’s transmitter. LSA08 is able to operate at various color surfaces with distinct brightness. The LSA08 has several output mode and convenience of use for any system. Namely, digital output port, serial communication port, and analog output port.
In this tutorial, we will be using the MC40SE to control the robot. The LSA08 will be a guide to detect the line and MC40SE is use to interpret information from LSA08 further give order to the robot which direction to go and follow.
So, let’s start the project.
• LSA08 x1
• MC40SE x1
• MOTOR x2
• WHEEL x2
• BATTERY x2
• Mobile robot x1
• PICKIT 2
• How to set up MPLAB IDE
• How to use PicKit2
Line Following using LSA08 with MC40SE
Before we start setting up the robot, we have to decide which motor to use. In this tutorial, I will be using the LINIX brushless motor. Below are some pictures of the wire connected to the mobile robot.
Brushless motor driver connection
Connection of the brushless motor driver to the MC40se board
It is up to you which type of motor to use, we have plenty of tutorial showing various types of motor being used together with MC40SE, check out our tutorials 🙂
1. Output Port
LSA08 has 2 output ports. One of it is digital output port which provides digital status of each sensor. This port is labeled as port B. For the 1st example I am going to demonstrate the method to use this digital port, interface with MC40SE.
A brief about LSA08 digital output, each output pin is TTL 5V, which should be directly connected to sensor port of MC40SE. It represent the status of sensor on LSA08, whether bright color (white) or dark color (black) is detected. We should be using LSA08 digital output like 8 normal sensor, connect it to 8 digital input port on MC40SE. I am using female to female jumpers wire to make connection, for experiment purpose it is fine. But for competition and robustness, I do not recommend using this wires as it is easily disconnect, please use proper IDE socket for LSA08 (it should come with LSA08) and 2510 3 ways socket for MC40SE (should come with MC40SE too).
To calibrate the LSA08, please do refer to the User’s Manual of LSA08.
Connection to PORT B at LSA08.
Connection to MC40SE’s digital input port. If you look carefully, we are connecting power supply of 12V to LSA08 from SEN1 port of MC40SE. The rest of SEN ports are connected with Signal pin only 🙂
Circuit diagram for you all to look at it^^
These are some important coding which use in line following…
This is the main body of doing line following
The code is too long to paste in this blog, so please do download it from the attachment under this article.
If you have problem on the code, please do discuss in our technical forum.
2. ADC Port
According to the User’s Manual of LSA08, there is another output from LSA08. The ADC output will generate analog voltage to indicate where is the line. The ADC output is located in PORT A of LSA08 together with UART port.
The advantage of using ADC output is minimum of wires interface 🙂 Because with 3 to 4 wires, you can obtain the line information from LSA08 for line following. For the details on ADC output, please check out the User’s Manual, page 37.
PORT A of LSA08, check the manual for detailed pin assignment. Besides the ADC from LSA08, I am using the junction pulse output too.
Connection to MC40SE board, ADC output of LSA08 connect to ADC input of MC40SE. The power is connected to ADC port too, do select 12V for the ADC + to power up LSA08. The Junction pulse from LSA08 connect to Signal pin of SEN1 port.
Sample Code for using ADC
For complete source code, please download from the attachment at the bottom of this article.
3. UART Port
The 3rd interface option from LSA08 is UART port and is located at Port A too (together with ADC). It comes with TX, RX and UEN. TX and RX are are normal UART transmitter and receiver pin. While UEN is to enable UART interface. UART interface can be used to configure various setting of LSA08 beside getting sensing information.
And for this tutorial, we are going to get the sensor information only for line following purpose 🙂
The connection is as illustrated below. For detailed pin assignment, please again refer to User’s Manual, page 34.
Connection on LSA08.
Connection on MS40SE, please connect the TX and RX to UART port (left of 2×8 LCD), for 12V supply you can either take from SENx PORT (digital port), ADC port or the port under UART port.
Here is the sample source code for the UART mode 1. There are mode 2 and 3., it is up to you which to use. I am using mode 1 in this tutorial.
Sample code are as below
Main body of the code
For further information on UART protocol and command, please refer to LSA08 User’s Manual.
Read first before you start doing the project. The project maybe harmful!!!
1. Check all the connections, especially the positive and negative terminals to avoid short circuit.
2. Check the battery connection
3. Please lift your robot so the tires can run freely before powering up
4. Please note that there were no kids beside.
TUTORIAL END HERE, any inquiry you could as at below command or our forum.
Here are some video and sample code…. enjoy!
In Github repository contains:
- MC40SE with PIC16F887 + LSA08 using ADC
- MC40SE with PIC16F887 + LSA08 using Digital
MC40SE with PIC16F887 + LSA08 using UART updated Jan 2013