Hi all,
I 'm new to MCU's and I want some advice with the new project that I have started. the purpose of this project is to understand how A/D work in PIC based MCU's. I have already set up a Proteus sim module for this circuit and wrote picBasic Pro code for it, but I couldn't get it to work properly and the readings I'm getting, does not match with the DC multimeter. i have couple of questions if any of you guys can help,
1: how can I configure any of the Pic18f4550's analog terminals to be a Analog input.
2: how to configure it properly
I will really appreciate your help.
Thanks
Code
Define LOADER_USED 1
Define OSC 48 ' Core is running at 48MHz
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds
adval var word
ADCON1= %00001000
TRISA = %00000000
TRISB = %00001000
TRISE = %0001
Pause 500
lcdout $FE, 1
mainloop:
ADCIN 5, adval ' Read channel 0 to adval (0-1023)
adval = (adval */ 500)>>2 ' equates to: (adval * 500)/1024
LCDOut $FE,$80,"DC Volts= ",DEC (adval/100),".",DEC2 adval ' Display the decimal value
'lcdout $FE, $C0, "Actual= ", #adval
Goto mainloop ' Go back to loop and blink LED forever
End
I 'm new to MCU's and I want some advice with the new project that I have started. the purpose of this project is to understand how A/D work in PIC based MCU's. I have already set up a Proteus sim module for this circuit and wrote picBasic Pro code for it, but I couldn't get it to work properly and the readings I'm getting, does not match with the DC multimeter. i have couple of questions if any of you guys can help,
1: how can I configure any of the Pic18f4550's analog terminals to be a Analog input.
2: how to configure it properly
I will really appreciate your help.
Thanks
Code
Define LOADER_USED 1
Define OSC 48 ' Core is running at 48MHz
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds
adval var word
ADCON1= %00001000
TRISA = %00000000
TRISB = %00001000
TRISE = %0001
Pause 500
lcdout $FE, 1
mainloop:
ADCIN 5, adval ' Read channel 0 to adval (0-1023)
adval = (adval */ 500)>>2 ' equates to: (adval * 500)/1024
LCDOut $FE,$80,"DC Volts= ",DEC (adval/100),".",DEC2 adval ' Display the decimal value
'lcdout $FE, $C0, "Actual= ", #adval
Goto mainloop ' Go back to loop and blink LED forever
End