Advanced Auto-Calibrating Line Sensor_SLA08

Autonomous Robot, Manual Robot, DC Motor Driver, Stepper Motor Driver, Servo, Multi PWM chip.....

Advanced Auto-Calibrating Line Sensor_SLA08

Postby Ali_Challenger » Thu Jan 29, 2015 1:41 pm

Good afternoon,
According to the user manual of SLA08 in order to get information from the line follow sensor via UART, we have to pull the UEN down and send a packet to LSA08’s UART, which it's for instance "0x01, 0x44, 0x02, 0x47" after that we expect to get the data from the TX line of SLA08.
So according to that I connect the SLA08 module to arduino UNO as shown in the circuit below, and also wrote the following code
CODE: SELECT_ALL_CODE
#include <SoftwareSerial.h>
SoftwareSerial LSA(2, 3);//2 RX,3 TX

void setup() {
  Serial.begin(9600);
  LSA.begin(9600);
  pinMode(13, OUTPUT);//UEN PIN
}
void loop() {
 LSA.print(0x01); //SET packet
 LSA.print(0x44); //SET packet
 LSA.print(0x02); //SET packet
 LSA.print(0X47); //SET packet
  digitalWrite(13, LOW);//UEN PIN
Serial.println(LSA.read());
 
  delay(2000);
 }

to send a set packet to the module and read the data out from SLA08. But, unfortunately I got nothing, Can tell me what is the wrong in the circuit or in the code?!?

Thanks.
Attachments
Diagram.png
SLA08+Arduino
Ali Challenger
Master Student @ FKEKK-MENC-UTEM
Mob.0187895080
https://www.facebook.com/pages/Challeng ... 8039157929
User avatar
Ali_Challenger
Apprentice
 
Posts: 37
Joined: Tue Oct 28, 2014 8:07 pm
Location: Melaka

Re: Advanced Auto-Calibrating Line Sensor_SLA08

Postby yonghui » Thu Jan 29, 2015 5:08 pm

Hi,

for LSA08 UART Command, u can refer to LSA08's User Manual section 6.5. commands sent to LSA08 needs to be in correct format of ADDRESS COMMAND DATA CHECKSUM. LSA08 will response with 'OK' if packet of the command is in correct format and the UART Baud rate is matching.

for retrieving line position from LSA08, its not necessary to use the command packet. just set the uart data output mode to 1 or 2 by using the push button and LCD on LSA08, then PULL DOWN the UEN line, the Data will automatically and continuosly send out from LSA08. UEN in this case is for flow control purpose, this means that if your processor /controller unable to handle too much continously data output from LSA08, u can stop LSA08 from sending out data by Setting UEN high until you finish process the previous data, then re-enable the data output by pulling UEN LOW.
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: Advanced Auto-Calibrating Line Sensor_SLA08

Postby Ali_Challenger » Thu Jan 29, 2015 11:34 pm

yonghui WROTE:Hi,

for LSA08 UART Command, u can refer to LSA08's User Manual section 6.5. commands sent to LSA08 needs to be in correct format of ADDRESS COMMAND DATA CHECKSUM. LSA08 will response with 'OK' if packet of the command is in correct format and the UART Baud rate is matching.

for retrieving line position from LSA08, its not necessary to use the command packet. just set the uart data output mode to 1 or 2 by using the push button and LCD on LSA08, then PULL DOWN the UEN line, the Data will automatically and continuosly send out from LSA08. UEN in this case is for flow control purpose, this means that if your processor /controller unable to handle too much continously data output from LSA08, u can stop LSA08 from sending out data by Setting UEN high until you finish process the previous data, then re-enable the data output by pulling UEN LOW.


Good evening,
Thank you for your quick reply, Unfortunately I haven't got any response from the LSA08 module via UART port, I set and connect the module as following:
Scenario No. 1,
Set the UART ADD to 1.
Set the BAUDRATE to 0.
Set the UARTMODE to 2.
Then,
Connect the RX of LSA08 to ARDUINO TX pin 1
Connect the TX of LSA08 to ARDUINO RX pin 0
Connect the UEN of LSA08 to ARDUINO GND
Connect the GND of LSA08 to ARDUINO GND
Then,
Uploaded ARDUINO with blank sketch.
At the serial terminal set the baudrate to 9600
Then,
Got nothing.
Nonresponse.
----------------------------------------------------------
Scenario No. 2,
Set the UART ADD to 1.
Set the BAUDRATE to 0.
Set the UARTMODE to 2.
Then,
Connect the RX of LSA08 to ARDUINO pin 3
Connect the TX of LSA08 to ARDUINO pin 2
Connect the UEN of LSA08 to ARDUINO pin 13
Connect the GND of LSA08 to ARDUINO GND
Then,
Uploaded ARDUINO with softserial with 9600 baudrate sketch as shown above.
At the serial terminal set the baudrate to 9600
Then,
Got nothing.
Nonresponse.
----------------------------------------------------------
Scenario No. 3,
Set the UART ADD to 2.
Set the BAUDRATE to 1.
Set the UARTMODE to 3.
Then,
Connect the RX of LSA08 to UC00A TX pin
Connect the TX of LSA08 to UC00A RX pin
Connect the UEN of LSA08 to UC00A GND
Connect the GND of LSA08 to UC00A GND
Then,
Used X-CTU, with 19200 Baud, NONE Flow, 8 Data Bits, Parity NONE
Then,
Got nothing.
Nonresponse.
-----------------------------------------------------
Scenario No. 4,
Set the UART ADD to 1.
Set the BAUDRATE to 0.
Set the UARTMODE to 2.
Then,
Connect the RX of LSA08 to UC00A TX pin
Connect the TX of LSA08 to UC00A RX pin
Connect the UEN of LSA08 to UC00A GND
Connect the GND of LSA08 to UC00A GND
Then,
Used X-CTU, with 9600 Baud, NONE Flow, 8 Data Bits, Parity NONE
Send a data packet "01 41 02 44" as shown in photo bellow.
Then Send a data packet "01 43 00 44"
Then,
Got nothing.
Nonresponse.

Any help please!
Thank you
Attachments
X-CTU.png
X-CTU
Ali Challenger
Master Student @ FKEKK-MENC-UTEM
Mob.0187895080
https://www.facebook.com/pages/Challeng ... 8039157929
User avatar
Ali_Challenger
Apprentice
 
Posts: 37
Joined: Tue Oct 28, 2014 8:07 pm
Location: Melaka

Re: Advanced Auto-Calibrating Line Sensor_SLA08

Postby Ali_Challenger » Fri Jan 30, 2015 10:08 pm

Hello there,
I'm sorry for inconvenience reason But, the SLA08 module have been decided to work just fine tonight.
I don't know what happend last night and what is the reason behind no response from the module but, I'm pretty sure I used the same wiring and settings, sorry again.

Thank you CYTRON crew.
Ali Challenger
Master Student @ FKEKK-MENC-UTEM
Mob.0187895080
https://www.facebook.com/pages/Challeng ... 8039157929
User avatar
Ali_Challenger
Apprentice
 
Posts: 37
Joined: Tue Oct 28, 2014 8:07 pm
Location: Melaka

Re: Advanced Auto-Calibrating Line Sensor_SLA08

Postby yonghui » Wed Feb 04, 2015 12:20 pm

good to hear that :)
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: Advanced Auto-Calibrating Line Sensor_SLA08

Postby Kalman » Tue May 10, 2016 11:39 pm

Hi, is it necessary to pull UEN low if I only want to use one LSA08 ? Bacause the data I obtain from the LSA08 through USART is very weird. For example, I obtain 83 from LSA08 but by right I should obtain 20. And all the data I receive is different from the data that showed on the LCD.
Kalman
Freshie
 
Posts: 6
Joined: Tue May 10, 2016 10:46 pm

Re: Advanced Auto-Calibrating Line Sensor_SLA08

Postby ober » Wed May 11, 2016 8:33 am

Kalman WROTE:Hi, is it necessary to pull UEN low if I only want to use one LSA08 ? Bacause the data I obtain from the LSA08 through USART is very weird. For example, I obtain 83 from LSA08 but by right I should obtain 20. And all the data I receive is different from the data that showed on the LCD.


Hi, can you give example of how is the 83 and 20 is obtain? A printscreen of software on computer and photo of actual hardware setup, and actual code would be helpful.

Also do give example of the LCD data vs data you get.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: Advanced Auto-Calibrating Line Sensor_SLA08

Postby Kalman » Wed May 11, 2016 2:37 pm

Good Afternoon, thanks for your reply.
Actually, I am using the STM32F3 Discovery Board instead of Arduino Uno to receive the data from the LSA08.
So, here is my coding.
CODE: SELECT_ALL_CODE
/* --------------------------------------Includes------------------------------------ */
#include <stddef.h>
#include "stm32f30x.h"
#include "stm32f3_discovery.h"
#include "stm32f30x_gpio.h"
#include "stm32f30x_rcc.h"
#include "stm32f30x_conf.h"
#include "uart.h"
#include "init.h"

/* ------------------------------Private variables -----------------------------------*/
unsigned char USART_Temp_Data;

/* -----------------------Private function prototypes -----------------------------*/
void InitializeLEDs(void);
void InitializeTimer(void);
void EnableTimerInterrupt(void);
void GPIO_DeInit(GPIO_TypeDef* GPIOx);
void Delay(int value);
void TIM3_IRQHandler(void);
void USART1_IRQHandler(void);
void EnableUartInterrupt();


/*------------------------------- Global variables---------------------------------- */
char result[10];
GPIO_InitTypeDef    GPIO_InitStructure;
RCC_ClocksTypeDef   RCC_Clocks;

/* ---------------------------------Private functions------------------------------ */
void InitializeLEDs()
{
    GPIO_DeInit(GPIOE);
    GPIO_InitTypeDef  GPIOStructure;
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE, ENABLE);
    GPIO_StructInit(&GPIOStructure);
    GPIOStructure.GPIO_Pin =GPIO_Pin_15 | GPIO_Pin_14 | GPIO_Pin_13 | GPIO_Pin_12 | GPIO_Pin_11 | GPIO_Pin_10 | GPIO_Pin_9 | GPIO_Pin_8;
    GPIOStructure.GPIO_Mode = GPIO_Mode_OUT;
    GPIOStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIOStructure.GPIO_OType = GPIO_OType_PP;
    GPIOStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_Init(GPIOE, & GPIOStructure);
}

void EnableUartInterrupt()
{
    NVIC_InitTypeDef nvicStructure;
    nvicStructure.NVIC_IRQChannel = USART1_IRQn;
    nvicStructure.NVIC_IRQChannelPreemptionPriority = 4;
    nvicStructure.NVIC_IRQChannelSubPriority = 4;
    nvicStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&nvicStructure);

}

void USART1_IRQHandler(void)
{
      if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)  //receive data
     {
       USART_ClearITPendingBit(USART1, USART_IT_RXNE);
            USART_Temp_Data = (unsigned char) USART_ReceiveData(USART1);
      }
}

void InitializeTimer()
{
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
    TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct
    TIM_TimeBaseInitStruct.TIM_Period =20000;  //Period = 20ms
    TIM_TimeBaseInitStruct.TIM_Prescaler =72;
    TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1;
    TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
    TIM_TimeBaseInitStruct.TIM_RepetitionCounter = 0x0000;
    TIM_TimeBaseInit(TIM3, &TIM_TimeBaseInitStruct);
    TIM_Cmd(TIM3, ENABLE);
   TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);
}


void EnableTimerInterrupt()
{
    NVIC_InitTypeDef nvicStructure;
    nvicStructure.NVIC_IRQChannel = TIM3_IRQn;
    nvicStructure.NVIC_IRQChannelPreemptionPriority = 3;
    nvicStructure.NVIC_IRQChannelSubPriority = 3;
    nvicStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&nvicStructure);
}

void LSA_Command(char address, char command, char data)
{
   char checksum = address + command + data;
   putcUART1(address);
   putcUART1(command);
   putcUART1(data);
   putcUART1(checksum);
}


void TIM3_IRQHandler()
{

   if(TIM3->SR & TIM_SR_UIF) { // if UIF flag is set
         TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag

          STM_EVAL_LEDToggle(LED9);
          LSA_Command(0x01,0x4F,0x02); //command set to LSA08 every 20ms through USART1

          sprintf(result,"LINE POSITION : %u\r\n",USART_Temp_Data); //print data to the terminal through UART4
          putsUART4(result);         
      }
}

/**
**===========================================================================
**
**  Abstract: main program
**
**===========================================================================
*/
int main(void)
{
   SYSInit();
   InitializeLEDs();
   InitializeTimer();
   UARTInit(USART1,115200);
   UARTInit(UART4, 115200);
   EnableTimerInterrupt();
   EnableUartInterrupt();
   STM_EVAL_LEDToggle(LED3);

  while (1)
  {
     STM_EVAL_LEDToggle(LED5);
  }

  return 0;
}


Below are my hardware setup:
Connect the RX of LSA08 to STM32 TX pin
Connect the TX of LSA08 to STM32 RX pin
Connect the GND of LSA08 to STM32 GND

The problem I am facing now is I cannot get the correct reading from the LSA08 by using the USART. For example, when the LCD on the LSA08 shows 20 but terminal show a different reading which is 83.

Reading on LSA08 LCD => Reading received through UART

20 => 83

25 => 243

30 => 255

35 => 1
Kalman
Freshie
 
Posts: 6
Joined: Tue May 10, 2016 10:46 pm

Re: Advanced Auto-Calibrating Line Sensor_SLA08

Postby ober » Wed May 11, 2016 10:48 pm

hardware seem to be correct although there is no actual picture, but I am not familiar with STM code and library.

If the LCD is displaying the correct value correspond to line detected, the LSA08 is working. My advise is to cross check (both LSA and STM) with computer. Connect a USB to UART converter, such as UC00A or any compatible UART devices, tap the TX pin of LSA, look at the value. Tap the TX pin of STM, look at the value. This will verify the baudrate too.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: Advanced Auto-Calibrating Line Sensor_SLA08

Postby Kalman » Wed May 11, 2016 11:33 pm

Thanks for your reply. The baudrate I set for both STM32 and LSA08 is 115200. And I do not pull low the UEN pin of LSA08, does it matter? About your idea, I had try before, the data from the tx of STM32 seem correct which is in the sequence of 0x01 0x4F 0X02 0X52. I send this packet of command to LSA08 every 20ms to request the line position from it. I expect the LSA08 will return the line position to STM32 in char but I only receive the garbage value like 83,1 and 255. Do you have any idea on the causes of this problem? Thank you.
Kalman
Freshie
 
Posts: 6
Joined: Tue May 10, 2016 10:46 pm

Next

Return to Robot Controller

Who is online

Users browsing this forum: No registered users and 18 guests

cron