1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

16F88 PWM and A/D conversion

Discussion in 'Microcontrollers' started by williB, Jun 5, 2005.

  1. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,218
    Likes:
    641
    Location:
    Derbyshire, UK
    Sorry, but the PWM is designed for power control (motor speed etc.), it's not really suitable for servo control - it's usually just done in software, as it's not a very critical item to do.
     
  2. mrbogeyman

    mrbogeyman New Member

    Joined:
    Feb 9, 2006
    Messages:
    2
    Likes:
    0
    i wanted to do it this way so that i didnt tie up the PIC.

    its a bit of a spanner in the works to be honest. its an honours project you see, so time is critical. doh!
     
  3. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,218
    Likes:
    641
    Location:
    Derbyshire, UK
    You could use interrupts to do it? - or use a slave PIC (8 pin one would be enough) that takes a serial input and generates servo pulses.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,637
    Likes:
    109
    Location:
    Michigan, USA

    I hate to disagree with you again Nigel but I think the PWM module is a perfect candidate anytime you need a pulse or signal with very low resolution, in this case 10-usecs...

    In this application you won't get a 20.0-msec period directly from the PWM module but it would be relatively easy to produce a 1.0-msec PWM period with 1.0-usec resolution (use prescaler 4:1 and PR2 d'250') and use an Interrupt Service Routine that programs CCPR1L with a 500-usec (50%) to 2000-usec (200%) duty cycle spread between two 1.0-msec PWM periods and a 0.0-usec (00%) duty cycle for another eighteen 1.0-msec PWM periods... This would produce a "look no hands" 20-msec Interrupt driven Servo output on the CCP1 pin and Main would simply need to update one variable with a value of 500, 510, 520, up to 2000, to change the pulse width output...

    Regards, Mike
     
  6. williB

    williB New Member

    Joined:
    Aug 30, 2004
    Messages:
    2,217
    Likes:
    3
    Location:
    New Jersey
    hey mike !!
    long time no talk !!
    last time , i think you were working on tri color LEDs , how did that work out..??
     

Share This Page