Discussion forum for the BasicX family of microcontroller chips.
|
Hi, Another simple question, I'm sorry. I know I should be able to figure this out myself, but I am stumped. I have an LM35DX temperature sensor which I have connected to an ADC pin on the BX24. The sensor specs are 0 - 100C in 10mv per degree C. I have used the GetADC in Integer form and am getting readings of around 68 when the temperature is more like 28. I am not sure how to get the correct degree C from this? I have read that the GetADC splits the 0 - 5V into 1023 pieces. This gives a resolution of approx, 4.98mv. As the LM35D has a resolution of 10mv per degree I have divided the returned value by 2. But to get the reading to be close to correct I have to subtract 6 from the value. Would this be the right way to do it or should I divide by 2.*? Any hints would be appreciated. Regards Chris Parker |
|
|
|
The equation is: a = numeric value returned by ADC centigradetemp = csng(a) * (5.0 / 1024) * 100. If you have a volt meter, how many millivolts are you reading on the input pint to the ADC? Hopefully the ADC and the voltmeter agree. If they do, then check your circuit for the LM35. The single supply suggestion (from National) has two diodes and a 18K load resistor to make it work. Do you have this circuit? http://www.national.com/ds/LM/LM35.pdf Jack -----Original Message----- From: Chris Parker <> To: <> Date: Friday, November 26, 1999 6:33 PM Subject: [BasicX] ADC from an LM35? >Hi, > >Another simple question, I'm sorry. I know I should be able to figure this out myself, but I am stumped. I have an LM35DX temperature sensor which I have connected to an ADC pin on the BX24. The sensor specs are 0 - 100C in 10mv per degree C. I have used the GetADC in Integer form and am getting readings of around 68 when the temperature is more like 28. > >I am not sure how to get the correct degree C from this? I have read that the GetADC splits the 0 - 5V into 1023 pieces. This gives a resolution of approx, 4.98mv. As the LM35D has a resolution of 10mv per degree I have divided the returned value by 2. But to get the reading to be close to correct I have to subtract 6 from the value. Would this be the right way to do it or should I divide by 2.*? > >Any hints would be appreciated. > >Regards >Chris Parker >[Attachments have been removed from this message] |
|
Hi Jack, Thanks for the help. As the sensor is only accurate to +/- 2C I am only displaying it as 2 digits, without the decimal point. This equation gives me a similar readout to the equation I had, it is still a few degrees out. I am using the sensor as it is used with a Basic Stamp2 and an ADC0831 in an example in Scott Edwards book. There are no diodes or load resistors. I have 5.0V on one pin, ground on the other, and the BX24 ADC pin on the other. Nothing like the circuits shown on the pdf file. Thanks for the link. Using a voltmeter I find that I am getting 0.25V @ around 22C. I am reasonably happy with the result I am getting now, except for one thing. I have a light sensor that turns the backlight on the LCD on or off automatically. When the backlight turns on, my temp reading drops 2 degrees. When the light goes out, the reading gets the 2 degrees back. The voltage at the sensor pins doesn't change either way? Thanks again for your help. I am lost, but learning rapidly. Regards Chris Parker -----Original Message----- From: Jack Schoof <> To: <> Date: Sunday, 28 November 1999 3:33 Subject: Re: [BasicX] ADC from an LM35? >From: "Jack Schoof" <> > >The equation is: > >a = numeric value returned by ADC > >centigradetemp = csng(a) * (5.0 / 1024) * 100. > >If you have a volt meter, how many millivolts are you reading on the input >pint to the ADC? Hopefully the ADC and the voltmeter agree. If they do, >then check your circuit for the LM35. The single supply suggestion (from >National) has two diodes and a 18K load resistor to make it work. Do you >have this circuit? > >http://www.national.com/ds/LM/LM35.pdf > >Jack > >-----Original Message----- >From: Chris Parker <> >To: <> >Date: Friday, November 26, 1999 6:33 PM >Subject: [BasicX] ADC from an LM35? >>Hi, >> >>Another simple question, I'm sorry. I know I should be able to figure this >out myself, but I am stumped. I have an LM35DX temperature sensor which I >have connected to an ADC pin on the BX24. The sensor specs are 0 - 100C in >10mv per degree C. I have used the GetADC in Integer form and am getting >readings of around 68 when the temperature is more like 28. >> >>I am not sure how to get the correct degree C from this? I have read that >the GetADC splits the 0 - 5V into 1023 pieces. This gives a resolution of >approx, 4.98mv. As the LM35D has a resolution of 10mv per degree I have >divided the returned value by 2. But to get the reading to be close to >correct I have to subtract 6 from the value. Would this be the right way to >do it or should I divide by 2.*? >> >>Any hints would be appreciated. >> >>Regards >>Chris Parker >> >> >>[Attachments have been removed from this message] >> >> > > |
|
Are you using the 5 volts out of the regulator in the BX24 to power the LEDs in the backlight? Or are you using some other regulator to power the BX24? Backlights in the LCD devices eat alot of current and can cause your main power to sag. The reference voltage used to measure ADC values is based on the "5 Volts" that is provided to the main BasicX chip on the BX24. This 5 Volts can be from our regulator, or it can come from you. If this voltage sags, the BasicX chip still cuts that new reference voltage into 1024 pieces. to be more accurate the equation should have been: a = numeric value returned by ADC (integer) v = voltage provided to the BasicX chip (single) normally 5.0 centigradetemp = csng(a) * (v / 1024.0) * 100.0 Look at the pin 21 of the BX24 and watch it when you turn the LED backlight on and off. This should give you some idea of the magnitude of changes in the power. If your calculation of off by + or - 2 degrees that means that the BX24 is "seeing" a change of +-20 millivolts. This is easy to get with the large power requirements of a backlight. I would suggest running the LCD display on its own power, and the BX24 on its own power, both from a higher source like 9 volts. Jack -----Original Message----- From: Chris Parker <> To: <> Date: Sunday, November 28, 1999 3:25 PM Subject: Re: [BasicX] ADC from an LM35? >From: "Chris Parker" <> > >Hi Jack, > >Thanks for the help. As the sensor is only accurate to +/- 2C I am only >displaying it as 2 digits, without the decimal point. This equation gives me >a similar readout to the equation I had, it is still a few degrees out. I am >using the sensor as it is used with a Basic Stamp2 and an ADC0831 in an >example in Scott Edwards book. There are no diodes or load resistors. I have >5.0V on one pin, ground on the other, and the BX24 ADC pin on the other. >Nothing like the circuits shown on the pdf file. Thanks for the link. > >Using a voltmeter I find that I am getting 0.25V @ around 22C. I am >reasonably happy with the result I am getting now, except for one thing. I >have a light sensor that turns the backlight on the LCD on or off >automatically. When the backlight turns on, my temp reading drops 2 degrees. >When the light goes out, the reading gets the 2 degrees back. The voltage at >the sensor pins doesn't change either way? > >Thanks again for your help. I am lost, but learning rapidly. > >Regards >Chris Parker > >-----Original Message----- >From: Jack Schoof <> >To: <> >Date: Sunday, 28 November 1999 3:33 >Subject: Re: [BasicX] ADC from an LM35? >>From: "Jack Schoof" <> >> >>The equation is: >> >>a = numeric value returned by ADC >> >>centigradetemp = csng(a) * (5.0 / 1024) * 100. >> >>If you have a volt meter, how many millivolts are you reading on the input >>pint to the ADC? Hopefully the ADC and the voltmeter agree. If they do, >>then check your circuit for the LM35. The single supply suggestion (from >>National) has two diodes and a 18K load resistor to make it work. Do you >>have this circuit? >> >>http://www.national.com/ds/LM/LM35.pdf >> >>Jack >> >>-----Original Message----- >>From: Chris Parker <> >>To: <> >>Date: Friday, November 26, 1999 6:33 PM >>Subject: [BasicX] ADC from an LM35? >> >> >>>Hi, >>> >>>Another simple question, I'm sorry. I know I should be able to figure this >>out myself, but I am stumped. I have an LM35DX temperature sensor which I >>have connected to an ADC pin on the BX24. The sensor specs are 0 - 100C in >>10mv per degree C. I have used the GetADC in Integer form and am getting >>readings of around 68 when the temperature is more like 28. >>> >>>I am not sure how to get the correct degree C from this? I have read that >>the GetADC splits the 0 - 5V into 1023 pieces. This gives a resolution of >>approx, 4.98mv. As the LM35D has a resolution of 10mv per degree I have >>divided the returned value by 2. But to get the reading to be close to >>correct I have to subtract 6 from the value. Would this be the right way to >>do it or should I divide by 2.*? >>> >>>Any hints would be appreciated. >>> >>>Regards >>>Chris Parker >>> >>> >>>[Attachments have been removed from this message] >>> >>> >> >> |
|
If you are using the ADC and put an output on one of the other pins of this port the reading can shift significantly since the load current can drop the voltage to this part of the chip (including the ADC reference). A 100uH inductor from +5 to the hole behind pin20 (AVCC) can stiffen up this supply. A separate regulator (78L05) running from the same supply that feeds the BX24 would be an even better way to get AVCC. I have seen a shift of about 2% with in-spec loads on only one pin. Also, the regulator on the BX24 has poor regulation if heavily loaded, so use an external +5 where possible to power off-chip resources, even if they shouldn't exceed the allowed current. mwf -----Original Message----- From: Jack Schoof [SMTP:] Sent: Sunday, November 28, 1999 6:56 PM To: Subject: Re: [BasicX] ADC from an LM35? From: "Jack Schoof" <> Are you using the 5 volts out of the regulator in the BX24 to power the LEDs in the backlight? Or are you using some other regulator to power the BX24? Backlights in the LCD devices eat alot of current and can cause your main power to sag. The reference voltage used to measure ADC values is based on the "5 Volts" that is provided to the main BasicX chip on the BX24. This 5 Volts can be from our regulator, or it can come from you. If this voltage sags, the BasicX chip still cuts that new reference voltage into 1024 pieces. to be more accurate the equation should have been: a = numeric value returned by ADC (integer) v = voltage provided to the BasicX chip (single) normally 5.0 centigradetemp = csng(a) * (v / 1024.0) * 100.0 Look at the pin 21 of the BX24 and watch it when you turn the LED backlight on and off. This should give you some idea of the magnitude of changes in the power. If your calculation of off by + or - 2 degrees that means that the BX24 is "seeing" a change of +-20 millivolts. This is easy to get with the large power requirements of a backlight. I would suggest running the LCD display on its own power, and the BX24 on its own power, both from a higher source like 9 volts. Jack -----Original Message----- From: Chris Parker <> To: <> Date: Sunday, November 28, 1999 3:25 PM Subject: Re: [BasicX] ADC from an LM35? >From: "Chris Parker" <> > >Hi Jack, > >Thanks for the help. As the sensor is only accurate to +/- 2C I am only >displaying it as 2 digits, without the decimal point. This equation gives me >a similar readout to the equation I had, it is still a few degrees out. I am >using the sensor as it is used with a Basic Stamp2 and an ADC0831 in an >example in Scott Edwards book. There are no diodes or load resistors. I have >5.0V on one pin, ground on the other, and the BX24 ADC pin on the other. >Nothing like the circuits shown on the pdf file. Thanks for the link. > >Using a voltmeter I find that I am getting 0.25V @ around 22C. I am >reasonably happy with the result I am getting now, except for one thing. I >have a light sensor that turns the backlight on the LCD on or off >automatically. When the backlight turns on, my temp reading drops 2 degrees. >When the light goes out, the reading gets the 2 degrees back. The voltage at >the sensor pins doesn't change either way? > >Thanks again for your help. I am lost, but learning rapidly. > >Regards >Chris Parker > >-----Original Message----- >From: Jack Schoof <> >To: <> >Date: Sunday, 28 November 1999 3:33 >Subject: Re: [BasicX] ADC from an LM35? >>From: "Jack Schoof" <> >> >>The equation is: >> >>a = numeric value returned by ADC >> >>centigradetemp = csng(a) * (5.0 / 1024) * 100. >> >>If you have a volt meter, how many millivolts are you reading on the input >>pint to the ADC? Hopefully the ADC and the voltmeter agree. If they do, >>then check your circuit for the LM35. The single supply suggestion (from >>National) has two diodes and a 18K load resistor to make it work. Do you >>have this circuit? >> >>http://www.national.com/ds/LM/LM35.pdf >> >>Jack >> >>-----Original Message----- >>From: Chris Parker <> >>To: <> >>Date: Friday, November 26, 1999 6:33 PM >>Subject: [BasicX] ADC from an LM35? >> >> >>>Hi, >>> >>>Another simple question, I'm sorry. I know I should be able to figure this >>out myself, but I am stumped. I have an LM35DX temperature sensor which I >>have connected to an ADC pin on the BX24. The sensor specs are 0 - 100C in >>10mv per degree C. I have used the GetADC in Integer form and am getting >>readings of around 68 when the temperature is more like 28. >>> >>>I am not sure how to get the correct degree C from this? I have read that >>the GetADC splits the 0 - 5V into 1023 pieces. This gives a resolution of >>approx, 4.98mv. As the LM35D has a resolution of 10mv per degree I have >>divided the returned value by 2. But to get the reading to be close to >>correct I have to subtract 6 from the value. Would this be the right way to >>do it or should I divide by 2.*? >>> >>>Any hints would be appreciated. >>> >>>Regards >>>Chris Parker >>> >>> >>>[Attachments have been removed from this message] >>> >>> >> >> --------------------------- ONElist Sponsor ---------------------------- Thinking about putting your business on the Web? MindSpring Biz has helped over 100,000 businesses get their .com. Join MindSpring Biz and save $50! <a href=" http://clickme.onelist.com/ad/mindspring4 ">Click Here</a ------------------------------------------------------------------------ |
|
Hi Jack, Thanks for your reply regarding my questions. I am not using the BX24 to power the LCD. I have both being powered from a 9 volt battery. The G12032 LCD has it's own voltage regulator like the BX24. The only connection between the BX24 and the LCD is the serial data and common ground. What you said about voltage sagging when the light is on doesn't happen. It still shows 5.0 volt at pin 21 whether the light is on or off. As I said before it is not that crucial, I don't need accurate temp, I am just displaying it because I can. I am just curious why this would happen. Thanks again. Chris Parker -----Original Message----- From: Jack Schoof <> To: <> Date: Monday, 29 November 1999 4:16 Subject: Re: [BasicX] ADC from an LM35? >From: "Jack Schoof" <> > >Are you using the 5 volts out of the regulator in the BX24 to power the LEDs >in the backlight? Or are you using some other regulator to power the BX24? >Backlights in the LCD devices eat alot of current and can cause your main >power to sag. > >The reference voltage used to measure ADC values is based on the "5 Volts" >that is provided to the main BasicX chip on the BX24. This 5 Volts can be >from our regulator, or it can come from you. > >If this voltage sags, the BasicX chip still cuts that new reference voltage >into 1024 pieces. > >to be more accurate the equation should have been: > >a = numeric value returned by ADC (integer) >v = voltage provided to the BasicX chip (single) normally 5.0 > >centigradetemp = csng(a) * (v / 1024.0) * 100.0 > >Look at the pin 21 of the BX24 and watch it when you turn the LED backlight >on and off. This should give you some idea of the magnitude of changes in >the power. If your calculation of off by + or - 2 degrees that means that >the BX24 is "seeing" a change of +-20 millivolts. This is easy to get with >the large power requirements of a backlight. > >I would suggest running the LCD display on its own power, and the BX24 on >its own power, both from a higher source like 9 volts. > >Jack >-----Original Message----- >From: Chris Parker <> >To: <> >Date: Sunday, November 28, 1999 3:25 PM >Subject: Re: [BasicX] ADC from an LM35? >>From: "Chris Parker" <> >> >>Hi Jack, >> >>Thanks for the help. As the sensor is only accurate to +/- 2C I am only >>displaying it as 2 digits, without the decimal point. This equation gives >me >>a similar readout to the equation I had, it is still a few degrees out. I >am >>using the sensor as it is used with a Basic Stamp2 and an ADC0831 in an >>example in Scott Edwards book. There are no diodes or load resistors. I >have >>5.0V on one pin, ground on the other, and the BX24 ADC pin on the other. >>Nothing like the circuits shown on the pdf file. Thanks for the link. >> >>Using a voltmeter I find that I am getting 0.25V @ around 22C. I am >>reasonably happy with the result I am getting now, except for one thing. I >>have a light sensor that turns the backlight on the LCD on or off >>automatically. When the backlight turns on, my temp reading drops 2 >degrees. >>When the light goes out, the reading gets the 2 degrees back. The voltage >at >>the sensor pins doesn't change either way? >> >>Thanks again for your help. I am lost, but learning rapidly. >> >>Regards >>Chris Parker >> >>-----Original Message----- >>From: Jack Schoof <> >>To: <> >>Date: Sunday, 28 November 1999 3:33 >>Subject: Re: [BasicX] ADC from an LM35? >> >> >>>From: "Jack Schoof" <> >>> >>>The equation is: >>> >>>a = numeric value returned by ADC >>> >>>centigradetemp = csng(a) * (5.0 / 1024) * 100. >>> >>>If you have a volt meter, how many millivolts are you reading on the input >>>pint to the ADC? Hopefully the ADC and the voltmeter agree. If they do, >>>then check your circuit for the LM35. The single supply suggestion (from >>>National) has two diodes and a 18K load resistor to make it work. Do you >>>have this circuit? >>> >>>http://www.national.com/ds/LM/LM35.pdf >>> >>>Jack >>> >>>-----Original Message----- >>>From: Chris Parker <> >>>To: <> >>>Date: Friday, November 26, 1999 6:33 PM >>>Subject: [BasicX] ADC from an LM35? >>> >>> >>>>Hi, >>>> >>>>Another simple question, I'm sorry. I know I should be able to figure >this >>>out myself, but I am stumped. I have an LM35DX temperature sensor which I >>>have connected to an ADC pin on the BX24. The sensor specs are 0 - 100C in >>>10mv per degree C. I have used the GetADC in Integer form and am getting >>>readings of around 68 when the temperature is more like 28. >>>> >>>>I am not sure how to get the correct degree C from this? I have read that >>>the GetADC splits the 0 - 5V into 1023 pieces. This gives a resolution of >>>approx, 4.98mv. As the LM35D has a resolution of 10mv per degree I have >>>divided the returned value by 2. But to get the reading to be close to >>>correct I have to subtract 6 from the value. Would this be the right way >to >>>do it or should I divide by 2.*? >>>> >>>>Any hints would be appreciated. >>>> >>>>Regards >>>>Chris Parker >>>> >>>> >>>>[Attachments have been removed from this message] >>>> >>>> >>> >>>> >> >> > > |