Steve, I'm doing this (exactly, in fact, down to the DS1620). You can download the whole thing from the PICLIST project file archive. I hope this is somewhat helpful. Please bear in mind that it was really my first shot at C with a compiler that had some pretty severe restrictions on complex statements, so it looks as bad as it really is 8-P. Here's what I do in C: void read_1620_temp_F() { read_1620_temp_C(); //get Celsius temperature DS1620_data >>= 1; //Round up, since .5C=.9F DS1620_data *= 9; //((F*9)/5)+32 = C DS1620_data /= 5; // DS1620_data += 32; // Carry = 0; // Clear carry bit DS1620_data <<= 1; //Shift left again. This // restores the LSB for the // ASCII conversion later! } And in assembler, courtesy of CC5Xfree - there may be more elegent ways to do it, especially since DS1620_data is a 16-bit variable. It holds a 9-bit temperatire reading from the DS1620, from which I drop the last bit before doing the conversion, since it's the .5C bit which equates to about .9F. One could probably chop quite a bit of code off of this if one were doing it all in assembler. ;void read_1620_temp_F() { read_1620_temp_F ; read_1620_temp_C();// get Celsius temperature CALL read_1620_temp_C ; DS1620_data >>= 1;// Round up, since .5C=.9F BCF 0x03,Carry RRF DS1620_data+1,1 RRF DS1620_data,1 ; DS1620_data *= 9;// ((F*9)/5)+32 = C BCF 0x03,Carry RLF DS1620_data,W MOVWF C2tmp RLF DS1620_data+1,W MOVWF C2tmp+1 MOVLW .4 MOVWF C1cnt m006 MOVF C2tmp+1,W ADDWF DS1620_data+1,1 MOVF C2tmp,W ADDWF DS1620_data,1 BTFSC 0x03,Carry INCF DS1620_data+1,1 DECFSZ C1cnt,1 GOTO m006 ; DS1620_data /= 5;// MOVF DS1620_data,W MOVWF C4tmp MOVF DS1620_data+1,W MOVWF C4tmp+1 CLRF C5rem MOVLW .16 MOVWF C3cnt m007 RLF C4tmp,1 RLF C4tmp+1,1 RLF C5rem,1 BTFSC 0x03,Carry GOTO m008 MOVLW .5 SUBWF C5rem,W BTFSS 0x03,Carry GOTO m009 m008 MOVLW .5 SUBWF C5rem,1 BSF 0x03,Carry m009 RLF DS1620_data,1 RLF DS1620_data+1,1 DECFSZ C3cnt,1 GOTO m007 ; DS1620_data += 32;// MOVLW .32 ADDWF DS1620_data,1 BTFSC 0x03,Carry INCF DS1620_data+1,1 ; Carry = 0;// Clear carry bit BCF 0x03,Carry ; DS1620_data <<= 1;// Shift left again. This BCF 0x03,Carry RLF DS1620_data,1 RLF DS1620_data+1,1 ;// restores the LSB for the ;// ASCII conversion later! ;} RETURN On Thu, 20 Jul 2000, Kosmerchock, Steve wrote: > Friends, > > I am wanting to do a temperature measurment project that > reads a DS1620 and will display between Celsius and Fahrenheit. > Has anybody ever done anything like this before on a PIC? > To convert from C to F you use: > F=(C*1.8)+32 > > To convert from F to C you use: > C=(F-32)/1.8 > > I have never tried to do multiplication and > division on a PIC. Does anybody have any advice or > some code I could look at. I have looked at the > math library for the PIC, but I am hoping some > of you PIC math gurus (Scott, Andy, Andrew,....etc.) > could give me an example. I appreciate your help very much! > > Best regards, > Steve > > > Steven Kosmerchock > Radio Frequency Systems > Phoenix Arizona USA > www.rfsworld.com > > www.geocities.com/researchtriangle/lab/6584 > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > --- The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" (I found it!) but "That's funny ..." -- Isaac Asimov -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu