Page 1 of 1

memory problem in LSA08

PostPosted: Fri Jun 24, 2016 6:47 pm
by abhinab
I'am using LSA08 in UART mode 2 with arduino mega 2560. It works fine for one time I calibrate it. After one or more time of switching the power supply(12V to Vin), the calibrated data is lost, and works if I re-calibrate it. I get zero every time, in every position when I get that problem.
Also, first two-three data obtained from UART line is incorrect. and next data obtained will be correct. This happens every time when I switch the supply. But, above first problem occurs at random time.


/*
* lineSensor.cpp
*
* Created: 5/9/2016 6:18:36 PM
* Author: Abhinab
*/

#include "lineSensor.h"
#include "uart.h"
#include "ADC.h"

void setContrast(char value)
{
char address = 0x01;
char command = 'S';
char data = value;
char checksum = address + command + data;

UART2Transmit(address);
UART2Transmit(command);
UART2Transmit(data);
UART2Transmit(checksum);
}

void clearJunction()
{
char address = 0x01;
char command = 'X';
char data = 0x00;
char checksum = address + command + data;

UART2Transmit(address);
UART2Transmit(command);
UART2Transmit(data);
UART2Transmit(checksum);
}

uint8_t getJunction()
{

if(bit_is_set(PINF,1))
{
return 1;
}

else
return 0;

}



uint8_t getLineState(void)
{

REQ_DATA;
//wait for data to be received
while(!((UCSR2A)&(1<<RXC2)));
STOP_DATA;
//return received data
return UDR2;


//uint16_t presentData=readADC(1);
//if(presentData>990)
//{
//return 255;
//}
//return ((float)presentData/960)*70;

}

uint8_t getJunctionSensor()
{
uint16_t presentData1=readADC(14);
uint16_t presentData2=readADC(15);

if((presentData1<400)||(presentData2<500))
{
return 1;
}
else
{
return 0;
}

}


void calibrateSensor()
{
STOP_DATA;
char address = 0x01;
char command = 'C';
char data = 0x00;
char checksum = address + command + data;

UART2Transmit(address);
UART2Transmit(command);
UART2Transmit(data);
UART2Transmit(checksum);

}

void lcdBackLight(char intensity)
{
STOP_DATA;
char address = 0x01;
char command = 'B';
char data = intensity;
char checksum = address + command + data;

UART2Transmit(address);
UART2Transmit(command);
UART2Transmit(data);
UART2Transmit(checksum);
}

void setJunctionWidth(char jWidth)
{
char address = 0x01;
char command = 'J';
char data = jWidth;
char checksum = address + command + data;

UART2Transmit(address);
UART2Transmit(command);
UART2Transmit(data);
UART2Transmit(checksum);
}

void setOutputMode(char mode)
{
char address = 0x01;
char command = 'D';
char data = mode;
char checksum = address + command + data;

UART2Transmit(address);
UART2Transmit(command);
UART2Transmit(data);
UART2Transmit(checksum);


}

void setBaudRate(char baud)
{
char address = 0x01;
char command = 'R';
char data = baud;
char checksum = address + command + data;

UART2Transmit(address);
UART2Transmit(command);
UART2Transmit(data);
UART2Transmit(checksum);
}

Re: memory problem in LSA08

PostPosted: Thu Jun 30, 2016 9:16 am
by Idris
Hi abhinab,

Sorry for your inconvenience.

What do you mean by switching the power supply from 12V to Vin? What is the purpose doing that?

Re: memory problem in LSA08

PostPosted: Fri Jul 01, 2016 7:35 pm
by abhinab
Idris WROTE:Hi abhinab,

Sorry for your inconvenience.

What do you mean by switching the power supply from 12V to Vin? What is the purpose doing that?


By that, I mean to switch(ON and OFF) the 12V signal connected to Vin pin of LSA08, to power the device.