Thanks Samo, Here what I had for setting A/D: start bsf status,rp0 ;switch to bank1 movlw b'00000011' ;input/output movwf trisa movlw b'00000000' movwf trisb ;output movlw b'00000011' ;config porta, bits 4,2,1,0 analog ;bits 7,6,5 digital I/O Bit 4,2,1,0 was configured as analog input. That mean if I wanna use two = analog input, all I have to do is connect two inputs to AN0 and AN1?? How does it know which input to store on the ADRES? Again thanks for your help Rith -----Original Message----- From: Samo Benedicic [mailto:samo_benedicic@YAHOO.COM] Sent: Thursday, August 07, 2003 12:30 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: PIC:8-bit ADC 16C765 please help! Hi! 8 bit A/D means that you have 255 discrete steps between 0 and Vref. That means one step is Vref/255. As far as I know, you can only measure voltages between 0 and 3V with your setup ( Vref in your case is 3V). If you want to measure voltages from 0-5V, make Vref=3DVcc in A/D module setup. If Vref=3D5V, than each step is approx. 19,6mV. Than 1V is 1/0.0196=3D51, 2V=3D102 and so on. Samo --- Rith Nachampasak wrote: > Hi Steve, thanks for the source code, I really > appreciate your help. > > I still hazy about the result. I connect 8 LEDs to > portb, all are lights up. > (b'11111111')at 5Vdc input.Here's my setting: > Vref =3D 3Vdc > AN0 =3D0 - 5Vdc (10k pot) > When I measured the voltage on each portb, I got > around 4.45Vdc. > How do I put these values on the table, etc., > Input(vdc) Hex Binary > 1 ? ? > 2 ? ? > 3 ? ? > 4 ? ? > 4.5 ? ? > 5 ? ? > > --Rith > > -----Original Message----- > From: Steve Murphy [mailto:smurph@METRONET.COM] > Sent: Friday, July 25, 2003 6:56 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: PIC:8-bit ADC 16C765 please help! > > > > > Rith, > > I don't see at first glance any glaring error that > jumps out at me. > I have never used the 16C765. Check the data sheet > for something (i.e. > comparator or CCP, etc.) and make sure these other > peripherals are > turned off. > > Make sure the watchdog is turned off until you get > things working. > > Keep in mind that the way the A/D works, is that in > the ADRES register > you will get a result in hex of how many 19.6mVolts, > (5V reference divided > by 8 bits of A/D =3D 5V/255 =3D .0196 =3D 19.6 mV.) are > read at the A/D port. > > For your example: 2V =3D (approx) 66 hex in ADRES( > 01100110 binary). > When you write 01100110 to port B, the leds that are > connected to ground > on the opposite side from the pic (0V) will light > with the bits that =3D 1. > > A lot of folks, including me wire leds so that the > side oposite the > pic is connected to VDD making them active low. If > your circuit is > like wired like that, you must invert the binary > 01100110 to 10011001 > to get the leds to light with the bits that =3D 0. > > To do that, use the comf instruction to negate: > > movf ADRES,W ;get a/d value > comf W, W ; invert bits. > > movwf PORTB ;output to port b > > > Regards, > > Steve > > > Could someone please help me interpret the result > of the Single channel A/D of the following code that > I down loaded from microchip, AN546. I substituted > the pic16C71 to pic16C765 Builded on the emulator > ICE2000 I got succeeded messaged. I connected a 2VDC > into pin2(RA0/AN0)...should I get the outputs from > PortB,etc., around 7.8mV?? > > > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > -- > http://www.piclist.com hint: The PICList is archived > three different > ways. See http://www.piclist.com/#archives for details. __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu