LM71 reads garbage sometimes.
Hello.
I'm facing a strong problem with LM71. Sometimes it reads garbage. Changed IC, changed PIC, changed power supply - same problem. If I cycle power sometimes one time, sometimes 3 times, etc. it then works. The code is as follows:
Code:
READTEMP: 'READ TEMPERATURE
low thcs
pause 5
shiftin thdta,thclk,msbpre,[result\16]
pause 5
high thcs
THC=result>>2/28
THC=THC-3
RETURN
tried to play with pause times - no difference.
What I'm doing wrong?
Re: LM71 reads garbage sometimes.
Totally off the top of my head, are the variables the proper size for that math?
Robert
Re: LM71 reads garbage sometimes.
THC and result variables are WORD type.
Re: LM71 reads garbage sometimes.
Do you have the pins on the 71 pulled high?
Re: LM71 reads garbage sometimes.
Re: LM71 reads garbage sometimes.
Tried 4.7k pull-ups on all pins, does not helps.
Re: LM71 reads garbage sometimes.
From cs low to the out of data the maximum time delay is 70 ns. you are using 5 ms. play with that delay using pauseus.
See data sheet timing table.
Cheers
Al.
Re: LM71 reads garbage sometimes.
Quote:
Originally Posted by
CuriousOne
Hello.
I'm facing a strong problem with LM71. Sometimes it reads garbage. Changed IC, changed PIC, changed power supply - same problem. If I cycle power sometimes one time, sometimes 3 times, etc. it then works. The code is as follows:
Code:
READTEMP: 'READ TEMPERATURE
low thcs
pause 5
shiftin thdta,thclk,msbpre,[result\16]
pause 5
high thcs
THC=result>>2/28
THC=THC-3
RETURN
tried to play with pause times - no difference.
What I'm doing wrong?
Maybe enable Power up timer in the configs
Re: LM71 reads garbage sometimes.
Delay changes nothing, since I tried different values of PAUSE. The problem is startup, if once started OK, then it works OK. Also, I've tried to initialize it later, say after 5 seconds after power on - no luck.
Re: LM71 reads garbage sometimes.
Pause has nothing to do with power up , sometimes mcu does not get nice crisp power on and it doesn't like slow lazy power on like when capacitors are on it's input, power up delay holds in reset until voltage is up to snuff and then allows it to boot.
One other thought : you have changed everything except the breadboard, breadboards do go bad.
Re: LM71 reads garbage sometimes.
Well, I'm not using breadboard at all. I've tried to make different PCBs, switched power supplies, etc. no help.
Re: LM71 reads garbage sometimes.
You will need to post your whole code , but here are a couple clues... The device needs a write on the rising edge, then data will be available on the falling edge. While CS is held low, send a command with a PRE then receive data with a POST. Also, are you sure you get valid data ever? The datasheet looks like you should be using LSB first, not MSB.
Re: LM71 reads garbage sometimes.
The whole code, related to temperature measurement is posted above. Regarding the valid data, I had to add division by 28, to get reasonable output. I've used melting ice and boiling water to determine that coefficient.