PIC16F877A ADC and PWM, HELP!

Discussion in 'Embedded Systems and Microcontrollers' started by Aladdin83, Jul 20, 2008.

  1. Aladdin83

    Thread Starter New Member

    Jul 20, 2008
    7
    0
    Hi all, I am new to the microcontrollers and programming and I have a few questions

    I am using a PIC16F877A microcontroller and PICBASIC PRO Compiler

    I am trying to configure the ADC, my input signal is -5 to +5 VDC
    it says on the manual that if I configure the control bits as 1000 I can use AN3 and AN2 as my VREF+ and VREF-, does that mean that I can have a negative reference voltage like -5 VDC or it just mean that my ref voltages can be two values between 0 and 5V?

    and can someone give me a sample code in BASIC that I can try, cause I tried a code from some website but it didnt work..

    here is the website where I got the code from:
    http://www.mikroe.com/en/books/picbasicbook/00.htm

    maybe the code is written in C! I cant tell cause I am no expert in programming

    Second question: after configuring the ADC, how do I refer to the ADC result and use it to set the dutycycle for PWM? I need to change vary the dutycycle between 10 and 90% for voltages between -5 and -0.1V and between 0.1 and +5V?

    Thanks in advance for your help :)
     
  2. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    You should not put -5V into the PIC. The Vref- is not a negative voltage input.

    I usually use C or asm on the PICs... the code in the link looks like BASIC. If I get a chance I'll look it over (unless someone more knowledgeable about mikroBASIC answers first)
     
  3. Aladdin83

    Thread Starter New Member

    Jul 20, 2008
    7
    0
    thanks for the reply, I think its basic too but when I try to copy the code and compile it, it gives me errors, I think something is missing..

    since Vref - doesn't mean that I feed negative voltage to the ucontroller then I guess it only means that I can have a low Vref instead of ground, is that right? :confused:
     
  4. Reshma

    Active Member

    Mar 11, 2007
    54
    0
    Please read the data sheet of PIC 16f877. They have clearly given the configuration details of the ADC & Capture-Compare-PWM (CCP) module.
     
  5. tallht

    New Member

    Jul 30, 2008
    3
    0
Loading...