Pic12f615 pwm output w/ analog a/d control input


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1


    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

  2. #2


    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 : 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