Scaling ADC in Pic 16F Micro (asm)

174 views Asked by At

I have an ADC working with a PIC16F676 (I appreciate there are probably better chips around to do this but the design is currently stable) and MC9700A temperature sensor.

At present it outputs the ADC value on PORT C (I am only using 6 bits)

 movwf     ADC_VALUE
     rrf       ADC_VALUE        ; 4 x Divide (1.5Vref (AN1) & 1.5V IP (AN3) = all 6 bits on)
     bcf       STATUS,C         ; Limits Digitiser Tag with MCP9700A -40C to +97C

 movf      ADC_VALUE,w
     movwf     PORTC          ; Copy the ADC value to PORTC

Instead of outputting the 'raw' value I want to convert that to degrees C. I know that temperature = (ADC_VALUE*5.0)/10.24 would achieve this in C but what is the equivalent in asm (I would prefer to stick with asm as this project took a while to achieve)?

Lastly before outputting the value on port C I want to 'strip out' all negative temperature values (-40C to -1C) and only output 1C to 97C. As I am only using 6 output pins I appreciate that this will max out at 63C but that is fine.

Any thoughts appreciated.

Regards Active

0

There are 0 answers