adc problems


Closed Thread
Results 1 to 2 of 2

Thread: adc problems

  1. #1
    Join Date
    Dec 2005
    Posts
    23

    Red face adc problems

    Hi, I'm using a 16F876A with a 20mhz resonator in a 2 motor robotic project. The program compiles and runs ok but can't get the A/D to run right. The input to Porta.0 and Porta.1 is a two axis joystick that outputs 2.5 volts in both axis's at center position. The output is the two PWM channels. The reverse is handled by seperate switches apart from the PIC. Below is a sample of the code:

    ADVAL0 VAR BYTE 'FORWARD/BACKWARD A/D STORE
    ADVAL1 VAR BYTE 'LEFT/RIGHT A/D STORE
    ADVALL VAR BYTE 'LEFT MOTOR SLOWER VARIABLE
    ADVALR VAR BYTE 'RITE MOTOR SLOWER VARIABLE
    DEFINE OSC 20 'SYSTEM OSCILLATOR 20 mhz
    DEFINE ADC_BITS 8 'NUMBER OF BITS = 8
    DEFINE ADC_CLOCK 3 'INTERNAL A/D RC CLOCK
    DEFINE ADC_SAMPLEUS 50 'SAMPLING TIME IN uS
    DEFINE CCP1_REG PORTC 'PORT C HPWM1 OUTPUT PORTC.2 (LEFT)
    DEFINE CCP1_BIT 2
    DEFINE CCP2_REG PORTC 'PORT C HPWM2 OUTPUT PORTC.1 (RITE)
    DEFINE CCP2_BIT 1
    TRISA = %11111111 'PORT A ALL INPUTS
    TRISB = %00000000 'PORT B ALL OUTPUTS
    TRISC = %00000000 'PORT C ALL OUTPUTS

    Can anyone look at this and tell me what I'm doing wrong - and what I need to make it right?
    Thanks for all help!
    Ron

  2. #2
    Join Date
    Sep 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Wink Re:

    Hi first of all, move all DEFINE's to the TOP. Then you may to configure de ADCON1 Register for ADC.

    ADCON1 = configuration for example:

    for 10bits adc, RA0 analog and VREF's you need to put:

    ADCON1= %10001111.

    For more configurations view the datasheet
    IF You = Know THEN
    Share it
    ENDIF

Similar Threads

  1. Problems with ADC
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th January 2009, 17:34
  2. 16F819 ADC problems
    By MUC in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 22nd March 2008, 18:36
  3. PIC18f2423 two 12bit adc input problems
    By Brandon in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th December 2007, 09:47
  4. I have problems with de ADC...
    By jomavilla24 in forum Off Topic
    Replies: 1
    Last Post: - 16th February 2007, 16:24
  5. Newby with ADC problems.
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th March 2005, 20:09

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts