PDA

View Full Version : LM71 reads garbage sometimes.



CuriousOne
- 31st January 2014, 14:56
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:



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?

Demon
- 31st January 2014, 15:21
Totally off the top of my head, are the variables the proper size for that math?

Robert

CuriousOne
- 31st January 2014, 15:24
THC and result variables are WORD type.

mackrackit
- 31st January 2014, 16:11
Do you have the pins on the 71 pulled high?

CuriousOne
- 31st January 2014, 16:12
No, I should?

CuriousOne
- 31st January 2014, 16:18
Tried 4.7k pull-ups on all pins, does not helps.

aratti
- 31st January 2014, 17:06
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.

Archangel
- 31st January 2014, 19:11
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:



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

CuriousOne
- 31st January 2014, 19:45
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.

Archangel
- 1st February 2014, 07:44
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.

CuriousOne
- 1st February 2014, 08:12
Well, I'm not using breadboard at all. I've tried to make different PCBs, switched power supplies, etc. no help.

Charlie
- 1st February 2014, 13:14
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.

CuriousOne
- 3rd February 2014, 05:54
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.