I neat some help on 12F675 ad


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Location
    Denmark
    Posts
    9

    Cool I neat some help on 12F675 ad

    Hi

    I have make this program, but i have some problems with the AD 0 on a 12F675. I try to measure m volt (400mV) on this, it look to be ok, then the mV drobt dovn to 200mV, and the output4( gipo4) shut go low after som time, but it stay high???..
    But if i drobt the it down to 0V output 4 go low.

    Can som body on thi forum help me on this.

    This is the program.

    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    @ DEVICE pic12F675, WDT_ON
    @ DEVICE pic12F675, PWRT_ON
    @ DEVICE pic12F675, MCLR_OFF
    @ DEVICE pic12F675, BOD_ON
    @ DEVICE pic12F675, CPD_OFF
    @ DEVICE pic12F675, PROTECT_OFF

    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    DEFINE OSC 4


    'GPIO.0 AD 0
    'GPIO.1 AD 1
    set VAR GPIO.2
    relae VAR GPIO.4
    led2 VAR GPIO.5


    ledlys VAR BYTE
    setpt1 VAR WORD
    gange VAR BYTE
    adval0 VAR WORD
    adval1 VAR WORD
    i VAR BYTE
    relaeset VAR BIT
    time VAR BYTE


    CMCON = 7 'comparators off
    ANSEL = %00110011 'GPIO.0,1 - A/D in ,rest digital
    ADCON0.7 = 1 'right justify for 10 bit
    TRISIO = %00000111 'GPIO.0 = input, rest output

    relaeset = 0
    relae = 0
    time = 0
    ledlys = 0


    Main:
    GOSUB laesead
    If set = 1 THEN
    i = 1
    FOR i = 1 TO 75
    led2 = 1
    PAUSE 50
    led2 = 0
    PAUSE 50
    NEXT i
    IF set = 1 THEN ' Save setpt
    led2 = 1
    GOSUB setpt
    PAUSE 5000
    relae = 1
    relaeset = 1
    led2 = 0
    time = 0
    ELSE
    relae = 1
    relaeset = 1
    time = 0
    ENDIF
    ENDIF
    IF (adval0 > setpt1) AND (relaeset = 0) THEN 'turn on
    relae = 1
    relaeset = 1
    time = 0
    ENDIF
    IF (adval0 <= setpt1) AND (relaeset = 1) THEN
    time = time + 1
    IF time = 6 THEN
    relae = 0
    relaeset = 0
    ENDIF
    ELSE
    time = 0
    ENDIF
    IF ledlys < 2 THEN
    ledlys = ledlys +1
    ENDIF
    IF ledlys => 2 THEN
    IF adval1 < %1111001100 THEN ' low batteri
    i = 1
    FOR i = 1 TO 10
    led2 = 1
    PAUSE 250
    led2 = 0
    PAUSE 250
    led2 = 1
    PAUSE 250
    led2 = 0
    PAUSE 250
    NEXT i
    ENDIF
    led2 = 1
    pause 15
    led2 = 0
    ledlys = 0
    ENDIF
    NAP 7
    NAP 7
    NAP 7
    NAP 7
    NAP 7
    NAP 7
    GOTO main

    setpt:
    GOSUB laesead
    setpt1 = adval0
    RETURN

    laesead:
    'adval0 = 0
    ADCIN 0, adval0 'read ad0 mv
    ADCIN 1, adval1 'read ad1 batteri
    RETURN


    END


    Thaks

    Kent

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i haven't check your whole code and it's logic, but i'll suggest you to send the result of your ADC result to your PC to see what happen with your result.

    You may need to do some averaging and/or use external filter to smooth your results, try to put a 0.1uF capacitor on each ADC input and see if it do something better.

    If you have any, please post your schematic.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    May 2004
    Location
    Denmark
    Posts
    9


    Did you find this post helpful? Yes | No

    Smile

    I have found the fault, i reset a variabel whole time, it work now.

    I will put a0.1uF capacitor on each AD. thanks Mister e

    Kent

Similar Threads

  1. 16F876 AD comparisation help needed
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th April 2008, 18:41
  2. Problem with AD inputs at PIC16f873a
    By wurm in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2008, 10:01
  3. PLEASE HELP ME! pic16f876a and AD tlc4541
    By luca_sheva in forum mel PIC BASIC
    Replies: 1
    Last Post: - 1st February 2005, 17:32
  4. ADC problem
    By NacNud in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th December 2004, 02:27
  5. 12f675 programming question
    By puggy in forum General
    Replies: 3
    Last Post: - 30th November 2004, 23:34

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