We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am currently doing a mini-project on temperature sensor using 8051 micro-controller. The 8051 micro-controller will receive 8bit temperature data from Analogue-to-Digital Converter which is connected to a temperature sensor(eg. LM35) I have a problem in translating the 8bit data from ADC to a temperature reading (eg. 38 celcius)in keil. I hope to understand the structure or the procedure in carrying out this step. Thank you!
thanks! by the way, which port would i acquire the 8bit data because the AT89C52 have 4 port? Futhermore, i have set aside P0 to LCD display and P1 to keypad.
"which port would i acquire the 8bit data because the AT89C52 have 4 port?" You choose!
Below is the C prog. I notice that the problem is lies with "OPORT = instr;" because it suppose to move what is in instr into OPORT which is in Xdata at location 0000h but it did not. #include <reg51.h> void delay5ms(void); void delay1ms(void); void lcdWriteInstrReg(char instr); void lcdInit(void); void lcdClrScr(void); char xdata OPORT _at_ 0x0000; sbit pinRW = P3^3; sbit pinRS = P3^4; sbit pinE = P3^5; void main(void) { lcdInit(); while(1); }//end main void lcdWriteInstrReg(char instr) { OPORT = instr; //o/p to D0-D7 pinRW = 0; //write pinRS = 0; //RS=0 for instr Reg pinE = 0; pinE = 1; pinE = 0; } void lcdInit(void) { delay5ms(); delay5ms(); delay5ms(); delay5ms(); lcdWriteInstrReg(0x38); delayms(); lcdWriteInstrReg(0x38); delay1ms(); lcdWriteInstrReg(0x38); delay1ms(); lcdWriteInstrReg(0x06); delay1ms(); lcdWriteInstrReg(0x0f); delay1ms(); lcdClrScr(); } void lcdClrScr(void) { lcdWriteInstrReg(0x01); delay1ms(); delay1ms(); }
Make OPORT volatile. Stefan
void main(void) { char ebit,ans; ebit = 0x01; ans = ebit*(100/256); } how can i display the value in ans on LCD ? void lcdPutStr (char *string) { char i; i=0; while(string[i]) { lcdPutCh (string[i++]); } } this is the program segment for putting the characters into LCD.