Pic12f615 pwm output w/ analog a/d control input


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2014
    Posts
    1

    Default Pic12f615 pwm output w/ analog a/d control input

    I am a total PIC newbie, so far my experience is limited to modifying a few example .asm files. But I have a very real practical application. I need to control a pwm (4-wire) fan away from the standard motherboard headers. So I know the PIC12F615 is on the lower end of pics, but it is what I have on hand. (I have some PIC12F683 on order). So here is my idea:

    put voltage into the A/d converter 5-10k pot controlling 0-5V scaling the 0-255 pwm.

    output the pwm signal directly to the control line (pulled up with a 1k resistor)

    Is this possible with a 615, I would think it would be simple code with low memory requirements - could someone hold my hand with this and walk me through the code - I know its newb, but it would help a lot..thanks!

    -Nhilar

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Pic12f615 pwm output w/ analog a/d control input

    Hi Nhilar. I'm not familiar with the 12F615 but we use this simple program to control the speed of a small motor. The Hpwm output goes to the gate of an N channel FET. The drain feeds the motor. Other side of motor to B+. Maybe this will help you to get it going.

    'COMPILED FOR 12F683

    CMCON0 = 7 'comparators off
    ANSEL = 0 'all inputs digital. adcin command will convert it to analog.
    DEFINE OSCCON_1K 1 ' Set OSCCON for 1K device
    @ DEVICE MCLR_OFF, INTRC_OSC_NOCLKOUT, WDT_ON, BOD_ON, PWRT_ON, PROTECT_ON
    TRISIO = %00010001 'GPIO.0 GPIO.4 (ANA3) INPUTS
    GPIO = 0 'ALL OUTPUTS LOW
    SPEEDPOT VAR BYTE

    START:
    CCP1CON = 0 'TURN OFF PWM
    NAP 0 'REDUCE BATTERY DRAIN
    IF GPIO.0 = 1 Then VIBRATE 'has pulldown 47K resistor
    GoTo START

    VIBRATE:
    ADCIN 3,SPEEDPOT 'USING 1M POT ACROSS SUPPLY
    HPwm 1,SPEEDPOT,15000 'THIS MOTOR WORKED BEST @ 15KHZ
    IF GPIO.0 = 1 Then VIBRATE
    GoTo START

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Pic12f615 pwm output w/ analog a/d control input

    Actually, the DEFINE OSCCON_1K 1 ' Set OSCCON for 1K device, should be DEFINE OSCCON_2K 1 ' Set OSCCON for 2K device. Compiles and works properly either way though.

Similar Threads

  1. Can you use the same pin as input/output and control led load?
    By FromTheCockpit in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 15th August 2013, 09:28
  2. 16f877 generate pwm according 2 analog input
    By madxice in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 9th July 2009, 14:47
  3. Analog Output from a PIC
    By robertmark68 in forum General
    Replies: 4
    Last Post: - 2nd August 2006, 18:06
  4. Using 4 input to control 10 output
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th November 2004, 12:08
  5. How to set analog pin to output 5V?
    By james in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th July 2004, 07:24

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