Help needed to troubleshoot


Closed Thread
Results 1 to 4 of 4
  1. #1
    ssocs45's Avatar
    ssocs45 Guest

    Default Help needed to troubleshoot

    Hi everyone, I would like some help to solve a problem with a project that I知 working on. Hope someone can point out what I知 doing wrong and help correct the mistake. Basically I知 doing a project using PIC12F675 which blinks one of the two LEDs depending on how much voltage is fed in the ADC pin (Analog to Digital Conversion pin). I have used a LDR ( Light Dependent Resistor ) in series with a resistor as in a voltage divider concept and taking the voltage from the center of the LDR and resistor as the input for the ADC pin. The function of this whole circuit is to tell if the light ambience in the room is below or above a predetermined amount. It should blink Green for above and Red for below the predetermined amount. (I have a schematic below for a clearer picture)

    This is how I have programmed the PIC12F675 using PIC Basic Pro. Thanks in advance for the help

    LED1 con 4
    LED2 CON 5

    CMCON=7
    ANSEL=%00001000
    TRISIO=%10000000
    ADVAL VAR BYTE
    K VAR WORD
    ROCK VAR WORD
    ROCK=%01010101

    CHECK:

    ADCIN 0, ADVAL

    notdone:

    IF ADVAL > ROCK THEN
    GOTO MMM
    ELSE
    GOTO MM2
    ENDIF

    MMM: FOR K = 1 TO 2
    HIGH LED1
    HIGH LED2
    PAUSE 250
    LOW LED2
    LOW LED1
    PAUSE 250
    NEXT K
    GOTO CHECK

    MM2: HIGH LED1
    PAUSE 250
    LOW LED1
    PAUSE 250

    GOTO CHECK

    END
    Attached Images Attached Images  

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    according to your schematic the output of the voltage divider is connected to AN1 (Pin6) but you are reading on AN0 (Pin7) "ADCIN 0"

    Change your Code to:

    CMCON=0
    ADCON=0

    ADCIN 1, ADVAL

    You should put some current limiting resistors in series with the LEDs (470R - 1k)

    Does the 10k resistor in the divider match the range of the LDR ?

    rgds

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Just glancing at your schematic, put Resistors (anywhere between 220R and 390R) in series with your LED's. You don't want to stress out the driver stages in your PIC.

  4. #4
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello !


    Please take my answer with a grain of salt, because I am EXTREMELY new with these chips. My knowledge is extremely limtied. But I think (Please someone correct me if I am wrong, and tell me why) you may have to change your TRISCIO value to somethign else...

    Yours->>TRISIO=%10000000

    I *think* the new one should be:

    TRISCO=%00001010 to make your IO port 1 a AD instead of a input/output.

    Dwayne (sorry if I am in error)

Similar Threads

  1. ASCII Viewer Needed
    By sougata in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th January 2008, 05:29
  2. Code space needed with MPASM??
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th September 2007, 10:24
  3. Programers Needed Still !
    By picawiner in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th June 2007, 13:51
  4. Newbee Hardware PWM clarification needed
    By emmett brown in forum General
    Replies: 3
    Last Post: - 9th July 2006, 09:18
  5. Circuit needed to allow a PIC to turn something on or off
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th October 2005, 21:17

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