At 14:46 16/05/97 -0400, Carlton Haycock wrote: >I am relatively new to PIC's. Using a part like the PIC16C84, what would be >the most straight forward way to interface to the TMP04 temperature sensor? >The TMP04 is a 3-wire device (+5v,gnd,data_out). The temperature is encoded >using ratiometric encoding. Basically what is done is that the data_out line >is held high for a certain period of time (T1) and held low for a certain >period of time (T2) and this repeats, over and over. To read the >temperature, you >measure the times T1 & T2 and plug them into the following formula: > >F degrees = 455 - ((T1*720)/T2) (if memory serves....) > >Anyway, I need to find the least complicated scheme to measure the two times >T1 and T2. I have looked at the sensor on a scope and manually calculated the >temperature and it was very close. The average timing is 35hz, so it is not >very high speed. Since the c/f84 don't have any fancy timer stuff, but have these interrupt-on-change port b (bits 4..7), I'd probably put it on one of these and on interrupt read the timer value. (You have to make sure that you take care of the timer overflows: either handle them in a timer ov interrupt routine, effectively creating a 16bit timer, or make sure the timer runs slow enough to not overflow twice between two port interrupts.) The rest is simple math, it seems. (I have only _very_ limited and still mostly theoretical PIC knowledge... :-)