memory problem in LSA08

Digital Fiber, Photoelectric, Laser Range, Optical, Temperature, Rotary Encoder, Ultrasonic, Gas, Gyro, Accelerometer, FlexiBend, Flexiforce, Compass......

memory problem in LSA08

Postby abhinab » Fri Jun 24, 2016 6:47 pm

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);
}
abhinab
Greenhorn
 
Posts: 2
Joined: Fri Jun 24, 2016 6:21 pm

Re: memory problem in LSA08

Postby Idris » Thu Jun 30, 2016 9:16 am

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?
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 384
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: memory problem in LSA08

Postby abhinab » Fri Jul 01, 2016 7:35 pm

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.
abhinab
Greenhorn
 
Posts: 2
Joined: Fri Jun 24, 2016 6:21 pm


Return to Sensor

Who is online

Users browsing this forum: No registered users and 7 guests