PDA

View Full Version : ADC/DAC



hricks
03-22-2008, 09:41 PM
Hello
I want to interface a joystick with my development kit,. I am using demo board with p18F8680 mafe by MICROCHIP.
The joy stick has couple of potential meter(pot) which I am very well aware how the pot work.
However ever the real problem is I want to read the voltage level of each movement of the joystick be comverted into digital signal.

Here is a problem this the code that I have written: and I will explain below what is happing when the pot is connected to my anolog pin after the code is loaded:


#include<p18f8680.h>
#include<delays.h>
void anadig(void);

void main(void)
{
unsigned char delay1;
unsigned char delay;
TRISD=0x00;
TRISA=0x01;

ADCON0=0x01;
ADCON1=0x0E;
ADCON2=0xA6;
CCP2CON=0x0B;
ADCON0bits.GO=0;
while(!(ADCON0bits.GO));
ADCON0bits.DONE=0;
Delay1KTCYx(200);
delay=ADRESH;
delay1=ADRESL;
Delay1KTCYx(200);


}



what I see happen is that when the pot is turn the power supply light on the demo board goes very low including the LCD display.


Something is not right but I have little experience to know ....... please give idea

elecrom
03-26-2008, 02:55 PM
How exactly you have connected the connected the POT, mention that ... and which port pin ? PA.0 ?