Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Ads

Discussion Groups

Discussion Groups | BasicX | GetADC - lm34

Discussion forum for the BasicX family of microcontroller chips.

GetADC - lm34 - William Keith - May 20 11:33:00 2001

I now have the lm34 working (Thank you to Dave & Tom).
I am however unable to figure out how to display the temp with 2 digits after the decimal point (72.45)

I have tried

Dim Temp as Integer
GetADC(13)*5/10

I get actual temp values pretty close to my digital thermometer, but they integers (72)

I've tried

Dim Temp as Single
GetADC(13, temp)

I get something like 0.145678
If I use my calculator and multiply 0.14567 by 500 I get 72.835
I try this in the program and I end up with type mismatch and all kinds of things

I would be most grateful if someone could point me in the right direction or provide a tidbit of code showing how to use GetADC with the lm34 and have a display showing the temp with 2 digits to the right of the decimal point.

William [Non-text portions of this message have been removed]





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: GetADC - lm34 - Tony Brenke - May 20 13:51:00 2001

Dim Temp as Single
GetADC(13, temp)

I get something like 0.145678
If I use my calculator and multiply 0.14567 by 500 I get 72.835
I try this in the program and I end up with type mismatch and all
kinds of things

'----------
GetADC(13, temp)
tmp = tmp * 500.0

try this.
the type missmatch was because there was no ".0" after your 500
=====
Tony Brenke
North Tacoma, WA

__________________________________________________





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: GetADC - lm34 - Author Unknown - May 20 15:19:00 2001

> ... how to use GetADC with the lm34[, displaying] the temp with 2 digits to
the right of the decimal point.

There are two issues. First, the BX-24 ADC resolves to about 5mV, which is 0.5
degree from the LM34; that's the best resolution you'll get from a direct
connection; once you have the significant data, then you need a method to
display 1.2345Volt as 123.45. Both are easy.

To see 0.01 degree resolution, you'll need either external gain and offset -
still limited by the 10-bit ADC, so the maximum range would be only 10.23
degrees, probably unacceptable - or software that synthesizes the additional
resolution via averaging or successive approximation (discussed here recently),
in exchange for response time.

If you need full-range or negative temps, this won't work; you'll need more
smarts, but here's my direct-connect LM34DZ code:

sT=csng(GetADC(bTempPin))/1024.0 '0-0.9999... (*5V=temp,
1.0V=100degreesF)
sTav=sTav+(sT-sTav)/100.0 'approximation of average temp, + two decimal
places

sTav will be the value you'll use. 1.0 represents 100.0 degreesF.

To display "123.45" from 1.2345, I did this:

strZ=cstr(clng(fix(sTav*10000.0+0.5)+100000.0))
strX=strX & mid(strZ,2,3) & "." & mid(strZ,5,2)
call putstr_n(strX) Tom Becker
--... ...--

The RighTime Clock Company, Inc., Cape Coral, Florida USA
www.RighTime.com




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: GetADC - lm34 - Author Unknown - May 20 16:07:00 2001

It's in the comment but not in the code: multiply sT by the 5.0v ADC reference:

sT=5.0*csng(GetADC(bTempPin))/1024.0 '0-0.9999... (*5V=temp,
1.0V=100degreesF)
sTav=sTav+(sT-sTav)/100.0 'approximation of average temp, + two decimal
places

sTav will be the value you'll use. 1.0 represents 100.0 degreesF. Tom Becker
--... ...--

The RighTime Clock Company, Inc., Cape Coral, Florida USA
www.RighTime.com





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )