Virtual AD Julio Cesar Palacios Reyes As you know the pic 16f628 doesn´t have AD so here you have a little solution. V_AD function is a virtual AD, it isnt so fast and only can measure 71.8% of VDD. If VDD=5V then 3.6>V_AD>0. If VDD=5.5 then 3.9>V_AD>0 It has 4 chanel conected to PORTA (A0, A1, A2, A4). it use the comparators and the Voltage Reference Module To obtain the closer voltage. The function return a value between 0 and 69 and you have 69>V_AD>0 voltage=(V_AD * VDD) /96 EJ. if the function return 40 and VDD=5 then voltage=( 40 * 5 ) /96 =2.08 volts. If the voltage is higer than 3.6 (3.9 if vDD=5.5) the function return 96. voltage=96*5/96, so voltage=5. you need to be sure that PORTA is config like input.