scottl
- 25th February 2006, 02:26
I am trying to send my analog input data to a pc in float format. I am using an LM34 which sends 10mV/C to my analog input. I use the PIC12F675 to receive the value from the LM34 then send this to a pc. It seems to work fine but I need to display one more decimal place. Example 45.6
Here is my code:
' Connect analog input to GP0
' Internal VRef at VCC 3.3v 10000001
adval VAR WORD 'Create adval to store result
ANSEL = %00110001 ' Set ADC clock to Frc and GP0 to analog mode
ADCON0 = %10000001 ' Configure and turn on A/D Module:
' Right justify result, use Vref pin, channel 0
loop:
ADCON0.1 = 1 'Start Conversion
notdone:
IF ADCON0.1 = 1 Then notdone 'wait for low on bit-1 of ADCON0,
adval.highbyte = ADRESH 'move HIGH byte of result to adval
adval.lowbyte = ADRESL 'move LOW byte of result to adval
adval = (adval */ 330)>>2
SerOut2 GPIO.5,84, ["Celsius: ", DEC adval.highbyte, ".", DEC adval.lowbyte, 10, 13]
Pause 3000 'Wait .1 second
GoTo loop 'Do it forever
end
Should this work?
SerOut2 GPIO.5,84, ["Celsius: ", DEC adval.highbyte, ".", DEC adval.lowbyte, 10, 13]
What am I doing wrong? I must complete this by tomorrow so any help would be greatly appreciated!
Thanks,
Scott
Here is my code:
' Connect analog input to GP0
' Internal VRef at VCC 3.3v 10000001
adval VAR WORD 'Create adval to store result
ANSEL = %00110001 ' Set ADC clock to Frc and GP0 to analog mode
ADCON0 = %10000001 ' Configure and turn on A/D Module:
' Right justify result, use Vref pin, channel 0
loop:
ADCON0.1 = 1 'Start Conversion
notdone:
IF ADCON0.1 = 1 Then notdone 'wait for low on bit-1 of ADCON0,
adval.highbyte = ADRESH 'move HIGH byte of result to adval
adval.lowbyte = ADRESL 'move LOW byte of result to adval
adval = (adval */ 330)>>2
SerOut2 GPIO.5,84, ["Celsius: ", DEC adval.highbyte, ".", DEC adval.lowbyte, 10, 13]
Pause 3000 'Wait .1 second
GoTo loop 'Do it forever
end
Should this work?
SerOut2 GPIO.5,84, ["Celsius: ", DEC adval.highbyte, ".", DEC adval.lowbyte, 10, 13]
What am I doing wrong? I must complete this by tomorrow so any help would be greatly appreciated!
Thanks,
Scott