Advanced Source code for data logger!!!

by barkkathulla 2012-09-20 14:18:49

<font color=#550000><font size=6>DESIGN OF USB DATA LOGGER</font></font>
#include <reg51.h>
#include <math.h>

#include "header.h"
#include "pcf8591.c"
#include "i2c.c"
#include "lcd.C"
unsigned int data1;

/* adc local variable declaration*/


unsigned int adc1= 0,adc2 = 0,adc3 = 0,adc4 = 0,add;

void display_data()
{


gotoxy(12,1);

split_numbers(lvdt);
lcddat(hundreds+0x30);
lcddat(tens+0x30);
lcddat(ones+0x30);



}

void main(void)
{

// char *str1=",*str2;
delay(10000); /* startup delay.*/
lcdinit(); /* initialize on board LCD.*/
clrscr(10); /* it cleares both the screen */
printstr(" 4 Channel ",0,0); /* Print string into LCD Screen.*/
printstr(" Data Logger ",0,1); /* Print string into LCD Screen.*/
delay(10000);
delay(10000);
delay(10000);
clrscr(10);
init();

while(1)
{
/* Get ADC Value */
adc1 = PCF8591_get(CH1);
adc2 = PCF8591_get(CH2);
adc3 = PCF8591_get(CH3);
adc4 = PCF8591_get(CH4);

add = 1;
/* if(adc1 > 85)
{
adc1 = adc1 - 85; // 90

adc1 = (unsigned int)adc1 * 10;
// adc1 = adc1 / 1.8;

lvdt = (unsigned int)(adc1/1.Cool
;
}
else
{
lvdt = 1;
} */

data1 = adc1;
// lvdt = ((data1 * 100)/255);
lvdt = data1 * 2;
split_numbers(lvdt);
tx_byte(add + 0x30);
tx_byte(hundreds+0x30);
tx_byte(tens+0x30);
tx_byte(ones+0x30);

printstr(" CHANNEL 1 ",0,0);
printstr("TEMP ",0,1);
display_data();
lcddat('C');
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);

add = 2;
data1 = adc2;
lvdt = ((data1 * 100)/255);
lvdt = 100 - lvdt;
split_numbers(lvdt);
tx_byte(add + 0x30);
tx_byte(hundreds+0x30);
tx_byte(tens+0x30);
tx_byte(ones+0x30);
printstr(" CHANNEL 2 ",0,0);
printstr("LDR ",0,1);
display_data();
lcddat('%');
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);

add = 3;
data1 = adc3;
lvdt = ((data1 * 100)/255);
split_numbers(lvdt);
tx_byte(add + 0x30);
tx_byte(hundreds+0x30);
tx_byte(tens+0x30);
tx_byte(ones+0x30);
printstr(" CHANNEL 3 ",0,0);
printstr("CH3 ",0,1);
display_data();
lcddat('%');
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);

add = 4;
data1 = adc4;
lvdt = ((data1 * 100)/255);
split_numbers(lvdt);
tx_byte(add + 0x30);
tx_byte(hundreds+0x30);
tx_byte(tens+0x30);
tx_byte(ones+0x30);


printstr(" CHANNEL 4 ",0,0);
printstr("CH4 ",0,1);
display_data();
lcddat('%');
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);

}
} /* End main */

/* This Function is used to split the variable into hundreds,tens,ones*/
void split_numbers(unsigned int number)
{
hundreds = (number / 100);
number %= 100;
tens = (number / 10);
number %= 10;
ones = number ;
}

void init()
{
IE = 0x81;
TCON =0x41;
SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */
TMOD = TMOD | 0x20 ; /* Timer 1 in mode 2 */
TH1 = 0xF5; /* 9600 Bds at 11.059MHz */
TL1 = 0xF5; /* 9600 Bds at 11.059MHz */
ES = 1; /* Enable serial interrupt */
EA = 1; /* Enable global interrupt */
TR1 = 1;
}
575
like
0
dislike
0
mail
flag

You must LOGIN to add comments