Free source code for LVDT design!!!

by barkkathulla 2012-09-20 14:37:21

Design of LVDT

#include <reg51.h>
#include <math.h>
#include "header.h"
#include "pcf8591.c"
#include "i2c.c"
#include "lcd.C"
unsigned char adc1,adc2,adc3,adc4; /* adc local variable declaration*/
/************************ Main function ***************************/
void main(void)
{
delay(10000); /* startup delay.*/
lcdinit(); /* initialize on board LCD.*/
clrscr(10); /* it cleares both the screen */
printstr("LVDT Trainer Kit",0,0); /* Print string into LCD Screen.*/
delay(10000);
delay(10000);
delay(10000);
delay(10000);
printstr("LVDT : ",0,1); /* Print string into LCD Screen.*/
init();
while(1)
{
/* Get ADC Value */
adc1 = PCF8591_get(CH1);
adc2 = PCF8591_get(CH2);
adc3 = PCF8591_get(CH3);
adc4 = PCF8591_get(CH4);
adc2 = adc2 - 19;
lvdt = 10.0 /12.0;
lvdt = (float)lvdt * adc2; // Temperature
split_numbers(lvdt);
gotoxy(7,1);
lcddat(hundreds+0x30);
lcddat(tens+0x30);
lcddat(ones+0x30);
lcddat(' ');
lcddat('c');
lcddat('m');
lcddat(' ');
lcddat(' ');
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 /* Enable global interrupt */
TR1 = 1;
}
867
like
0
dislike
0
mail
flag

You must LOGIN to add comments