ADC on 12F683

Closed Thread
Results 1 to 2 of 2

Thread: ADC on 12F683

  1. #1
    Join Date
    Jul 2017

    Default ADC on 12F683

    I am not able to get the ADC on a 12F683 to work. The values it reports fluctuate seemingly randomly.

    I have two 4.7K resistors attached in series between +5V and GND. A wire from Pin 4 (bit 3) is attached between them so I should be seeing a constant 2.5V. But instead, the ADC gives me numbers fluctuating from 0 to 255.

    I am using the program (ADCINX4) that I got off the meLABS site, but it does not seem to work. The only change I made to the program below is to make my LCD display work.

    I had tried a number of things on my own, but none of them worked, so I am turning to this collection of experts for help.

    I had been using the POT command in the past and it worked fine, I was told that ADC was a better way to go.



    ' Name : ADCINX4.pbp
    ' Compiler : PICBASIC PRO Compiler 2.6
    ' Assembler : PM or MPASM
    ' Target PIC : PIC12F683
    ' Hardware : LAB-X4 Experimenter Board
    ' Oscillator : 4MHz internal
    ' Keywords : ADCIN, SEROUT
    ' Description : PICBASIC PRO program to display result of 8-bit A/D
    ' conversion on LCD.

    Include "modedefs.bas" ' Mode definitions for Serout

    ' Define ADCIN parameters
    Define ADC_BITS 8 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    LCD Var GPIO.1 ' LCD TX pin

    ' I added these lines to make the chip work with my LCD display
    I var byte '*
    I = 254 '*
    clr var byte '*
    clr = 1 '*
    hm var byte '*
    hm = 2 '*
    L1 var byte '*
    L1 = 128 '*

    adval Var byte ' Create adval to store result

    ANSEL = %00111000 ' Set AN3 analog, rest digital
    CMCON0 = 7 ' Analog comparators off
    Pause 1000 ' Wait 1 second for LCD to init

    serout lcd, 4, [I, clr] ' getting the LCD ready to display
    serout lcd, 4, [I, hm]
    serout lcd, 4, ["ready to begin"]
    pause 2000
    serout lcd, 4, [I, clr]

    ADCIN 3, adval ' Read channel 3 to adval

    Serout LCD, 4, [I, clr] ' Clear screen
    Serout LCD, 4, ["Value: ", #adval] ' Display the decimal value

    Pause 200 ' Wait 0.2 second
    Goto mainloop ' Do it forever


  2. #2
    Join Date
    Jul 2017

    Did you find this post helpful? Yes | No

    Default Re: ADC on 12F683

    I found my mistake:

    Pin 4 is GP3

    Pin 3 is GP4, but AN3

    I had the wire attached to the wrong pin.


Similar Threads

  1. ADC values above 4095 for 12 bit ADC
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st February 2015, 22:24
  2. ADC problem on 18F46K22 device using all 28 ADC pins
    By JimAvanti in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd February 2012, 20:22
  3. pic 12f683 adc help please
    By Helgeland in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd February 2012, 14:31
  4. ADC in 12F683; puzzled
    By mikebike in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 23rd September 2010, 20:27
  5. 12f683 ADC help
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 26th November 2009, 21:37

Members who have read this thread : 2

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