Why doesn't this servo code work?


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2009
    Posts
    2

    Smile Why doesn't this servo code work?

    I am trying to use this simple servo code on a 16F684 using portc.1. What am I missing? Why doesn't it work? All that happens is the servo twitches when downloading the hex file, then that's all.

    OSCCON = %01100001 '4 Mhz on internal osc

    TRISC = %00000000
    PORTC = %00000000

    x var byte
    y var byte

    main:

    for x = 0 to 50
    pulsout portc.1, 75
    pause 20
    next x

    pause 2000

    for y = 0 to 50
    pulsout portc.1, 175
    pause 20
    next y

    pause 2000

    goto main

    end

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    The answer is in your Datasheet ...

    PortC1 is shared with the on chip ADC ... so you must tell the chip you want to use it as a DIGITAL pin ...

    BTW ... Comparator also shares this pin ... soooo ...

    Two datasheet sections to review ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Dec 2009
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Thanks!

    Thanks! That helps a lot. I use a lot of different PIC chips
    and it's been a long while since I used a 684. I thought I
    had remembered all the details.





    Quote Originally Posted by Acetronics View Post
    Hi,

    The answer is in your Datasheet ...

    PortC1 is shared with the on chip ADC ... so you must tell the chip you want to use it as a DIGITAL pin ...

    BTW ... Comparator also shares this pin ... soooo ...

    Two datasheet sections to review ...

    Alain

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  3. Replies: 3
    Last Post: - 1st July 2008, 22:07
  4. Problem with 12F629, servo and EEPROM
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 1st March 2008, 10:53
  5. Servo Code problem
    By ALFRED in forum General
    Replies: 1
    Last Post: - 2nd March 2006, 04:30

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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