PIC16F676 Problem


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Atom058 View Post
    Thanks Skimask. I tried your code and it did the same thing. The problem must be on my board. I will look closer at my circuit and let you know what I find. Atom058
    My program was flawed. Timing isn't right for a 4mhz oscillator.
    Try replacing the 1000 and 2000, with 100 and 200.

    In fact, in your original program, change the line:

    posit = rcval + 350

    to

    posit = rcval

    and see what happens.

    The pulsout command at 4mhz sending out pulses in increments of 10us.
    You're minimum pulse width the way you wrote the program would automatically send out a pulse width of 3500us (3.5ms) which is above the 2ms (average) pulse width for a servo. If this works, post back. You might only have a little bit of POT movement for a lot of servo movement, but that part of the program can be rewritten to compensate for that. (think pause statement instead of pulsout)
    Last edited by skimask; - 18th April 2007 at 17:49.

  2. #2
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94


    Did you find this post helpful? Yes | No

    Smile I think you're on to it!

    Skimask - Thanks for the info - this would explain why I have been able to do this task on other chips - I have always been using a 20 mHz resonator. This is the first time that I am not. I'll try this out and post my results.
    Thanks again!

  3. #3
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94


    Did you find this post helpful? Yes | No

    Talking

    Skimask - Your info worked perfectly. My pot-controlled servo is now working just fine! Thanks for your help!!!

    Here is my updated code:

    @ DEVICE pic16F676, INTRC_OSC_NOCLKOUT

    CMCON = 7
    ANSEL = %00000000 ' Turn off analog input
    TRISC = %00000001

    RCVal var Word
    Posit var word

    PotIn var PORTC.0
    Servo var PORTC.3

    low servo

    MoveServo:
    gosub readpot

    'produce a value between 75 and 255 when running at 4 mhz
    posit = 75 + rcval + (rcval / 2)

    'produce a value between 350 and 950 when running at 20 mhz
    'Posit = 350 + RCVAL

    PULSOUT Servo, posit ' move the servo
    pause 25
    goto MoveServo

    ReadPot:
    'At 4 mhz, returns 0-120. At 20 mhz, returns 0-600
    ' with a 10K pot and 0.1 uf cap
    high potin
    pause 1
    rctime potin, 1, rcval
    return

    End

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I think I'd change your 'Pause 25' to something a bit lower.
    Servo's want to be updated at about 50-60hz. You've got it set up for no more than 37hz update rate (pause 25 + 1ms minimum pot read + 1ms minimum pulsout).
    I'd put it somewhere around Pause 14 or so...to give a minimum of 50hz.

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. 16F676 Please explain this problem...
    By Jayhovah in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th May 2008, 21:30
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. LCD Problem witch PIC16F676
    By microuser in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th August 2005, 08:11
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

Members who have read this thread : 0

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