![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Hi guys this is my first attempt in A/D. My target is to build a 0-99 Celsius temperature display. (Two digits & no need decimal point) My temperature sensor is giving 10mV per Celsius. My supply is 5V. My analog input is AN0. For 99 C it has to measure = 99 X 10 = 990 mV. So an eight bit resolution is more than enough. I just checked my input (AN0) by connecting a V/R. My BCD coding gives me 0 to 255 values when I turning the preset (V/R). My problem is how to convert this 8 bit value to temperature? I did a small math as in the graph please tell is that correct or not? If you like you can share a method how to convert this 8 bit value to temperature. Many Thanks Last edited by Suraj143; 14th January 2008 at 05:14 AM. | |
| |
| | (permalink) |
| hi Suraj, Have you considered setting the +Vref to +2.5V, this will double the ADRESL value. If you just want 8 bit resolution you could also Left Justify the ADC into ADRESH. EDIT: If you are going to display the ADRESX value as ASCII Temperature, on a LCD, you will need a binary to ascii conversion routine in your program.
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 14th January 2008 at 10:04 AM. | |
| |
| | (permalink) |
| Hi Eric thanks for your response.Actually I didn't set +Vref because i have never used Vref stuff before. Is my data table ok? I think i can use RLF command to make it double. please help me. | |
| |
| | (permalink) | |
| Quote:
If its a 10bit ADC, this will give a value of 1023 decimal for a an ADC input voltage of +5V, when using the internal Vref of +5V. So, for a Vin of 1V the ADC value will be: Value = (Vin/5)* 1023 equals 204 decimal 0xCC hex. Calculate the rest of your graph/table using the same formula, Does this help.?
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | ||
| |
| | (permalink) |
| Hi Eric I have BCD versions.I don't need ascii i just need decimals. Now its displaying 0 to 255 in the segments because i'm using 8 bits.I gave inputs through a V/R(preset).when I turn the preset value varies 0 to 255.I can see from the seven segments. I need to replace the V/R to my temperature sensor.My sensor 10mV per Celsius. For 8 bits 5/255 = 0.0196 is this correct? | |
| |
| | (permalink) | |
| Quote:
I think you are using a LM35 temp sensor.? If your maximum Temp is going to be 100Cdeg thats 100 * 0.01 = 1volt So Max Value= (1/5) *1023 = 204.6.. IF you have right justified the ADC output or Value = (1/5) *255 = 51 ... IF you have Left Justified the ADC output.. For the Temp range you are working over I would right justify and just use ADRESL output. You will have to convert the binary value to BCD for your display.
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | ||
| |
| | (permalink) | |||
| Quote:
Quote:
Quote:
| ||||
| |
| | (permalink) |
| My Maximum value is 51 now what do I have to do?this must divide into 100 pcs. | |
| |
| | (permalink) | |
| Quote:
Check my PIC tutorials for the hardware I use for A2D in the tutorials. | ||
| |
| | (permalink) | |
| Quote:
You will get 100/205... approx, 0.49Cdeg/increment in ADRESL The resolution of the Tempr using 51 to represent 100Cdeg is a poor way to go, consider the Tempr resolution. 100/51= 2Cdeg resolution per increment!!!
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | ||
| |
| | (permalink) |
| Hi Eric I'll re read your above post & I'll give a try.Please give me some time to work out. | |
| |
| | (permalink) |
|
__________________ Simran.. 8051 Specialist.. | |
| |
| | (permalink) |
| Hi Eric great news! I just right justify & read the ADRESL value. I wrote my own coding & it worked. But I have only one problem. When the value changes in the segments its flickering. For example if the temperature is 29 Celsius when it goes to 30 the both digits flickering so in the flickering time I can see both 88 (all the segments displaying).After the value changes its ok it will display nicely. Is it a hardware error or coding error? How do I get a smooth value change? Here I have attached my hardware as well as my code. Code: list P=16F877A #include <P16F877A.inc> errorlevel -302 __config _CP_OFF & _PWRTE_ON & _XT_OSC & _WDT_OFF & _BODEN_OFF & _LVP_OFF cblock 20h Digit1,Digit2,Digit3,ADL,lsd,msd,bigmsd,Del endc org 0000h clrf STATUS Init bsf STATUS,RP0 clrf TRISB clrf TRISD movlw b'00000001' ;make RA0 input (sensor) movwf TRISA movlw b'10001110' ;result right justified,Vref+=Vdd,Vref-=Vss movwf ADCON1 bcf STATUS,RP0 movlw b'01000001' ;ADON,RA0 Channel,FOSC/8 movwf ADCON0 clrf ADL clrf Digit1 clrf Digit2 clrf Digit3 clrf PORTB clrf PORTD clrf PORTA goto Main ;************ ;Main program ;************ Main call Multiplex ;show the display call Check_AD ;get the AD value bcf STATUS,0 rrf ADL,F ;devide the AD value by by 2 call BCD ;call BCD & make into decimals call BCD_Split ;move BCD results to segment digits goto Main ;********************************** ;move BCD results to segment digits ;********************************** BCD_Split movf lsd,W movwf Digit1 movf msd,W movwf Digit2 movf bigmsd,W movwf Digit3 return ;********************** ;Read AD value routine ;********************** Check_AD clrf ADL bsf ADCON0,GO btfsc ADCON0,GO goto $-1 bsf STATUS,RP0 movf ADRESL,W bcf STATUS,RP0 movwf ADL return ;**************************** ;8 bit to 3 digit BCD version ;**************************** BCD movf ADL,W clrf msd ;result register1 clrf lsd ;result register2 clrf bigmsd ;result register3 call convert_bcd movf msd,W call convert_big return convert_bcd clrf msd ; clear the msd movwf lsd ; move the number to convert into lsd ten movlw .10 ; load the constant 10 subwf lsd,w ; subtract 10 from lsd btfss STATUS,0 ; check if answer negative goto done ; conversion complete, jump to done movwf lsd ; save the answer back in lsd and incf msd,F ; increment the msd goto ten ; do the routine again done return ; return to caller convert_big clrf bigmsd ; clear hundreds movwf msd ; move the hundred number to msd hundred movlw .10 ; load the constant 10 subwf msd,w ; subtract 10 from msd btfss STATUS,0 ; check if answer negative goto hundreddone ; conversion complete, jump to hundreddone movwf msd ; save the answer back in msd and incf bigmsd,F ; increment the bigmsd goto hundred ; do the routine again hundreddone return ; return to caller ;******************************************************* ;Multiplex routine 3 digits (last digit ignoring-Digit3) ;******************************************************* Multiplex movlw 10h movwf PORTD movf Digit3,W call Delay movf Digit2,W call Delay movf Digit1,W goto Delay Delay call Table movwf PORTB decfsz Del,F goto $-1 clrf PORTB bcf STATUS,C rlf PORTD,F return ;*************************************** ;Data look up table for segment patterns ;*************************************** Table addwf PCL,F retlw b'01111110' ;0 retlw b'01100000' ;1 ;dp cbdeafg retlw b'00111101' ;2 retlw b'01110101' ;3 retlw b'01100011' ;4 retlw b'01010111' ;5 retlw b'01011111' ;6 retlw b'01100100' ;7 retlw b'01111111' ;8 retlw b'01110111' ;9 end | |
| |
| | (permalink) | |
| Quote:
__________________ --- The days of the digital watch are numbered. --- Last edited by kchriste; 16th January 2008 at 06:11 AM. | ||
| |
| | (permalink) | |
| You mean that my Multiplexing routine I must call every one second? Quote:
In my diagram is it a low pass filter? | ||
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Guide to using an MCP2515? | Sam Jelfs | General Electronics Chat | 0 | 4th April 2007 09:14 PM |
| Hotair Soldering Desoldering Guide or Tutorial is Needed | xpacer | General Electronics Chat | 1 | 20th October 2006 06:56 PM |
| Orcad PCB Layout Manual Guide, Help ! | sinkopa | General Electronics Chat | 1 | 31st March 2004 10:20 AM |
| ASM guide | McGuinn | Micro Controllers | 4 | 2nd February 2004 01:38 AM |
| anyone willing to help and guide me?? | philipsi | Micro Controllers | 2 | 23rd December 2003 08:02 AM |