16F1828 HPWM and ADC


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: 16F1828 HPWM and ADC

    Thx Richard, now I understand.

    Now, AN6 work corectly. The value of CCPR1L is 2 x adval. If I divide adval to 2 , exist a little diference betwen PWM1 and PWM2 on outputs (~ 0,8 units)

    Code:
    t2con=4
    PR2 = 255
    ccp1con=12
    
    pause 200
    '========================PROGRAM=============================
    main:
    adcin 6 , adval 
    pause 10
    
    CCPR1L = adval/2            ;set pwm
    duty1 = adval
    
    hpwm 2 , duty1, 2000 
    
    high inh1
    high inh2
    
    goto main
    end
    '=============================================================

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: 16F1828 HPWM and ADC

    some more things to consider

    1.
    Many devices allow a selection of Timer resource for some or all of the PWM
    channels. The HPWM command will automatically determine the preset Timer
    selection upon execution. Note that PWM channels that share a single timer may
    not operate at independent output frequencies. While duty-cycle settings are
    always independent from one channel to the next, independent frequency settings
    require independent timer resources.
    you have not set any individual timer resource options [ CCPTMRS0 ]
    so
    t2con=4
    PR2 = 255
    settings get overwritten by use of

    hpwm 2 , duty1, 2000

    2.
    you have not specified how your "pot" is connected , if its connected between vdd an ground then use of a fvr of 2.048 v is totally inappropriate and
    may even damage your chip. analogue in voltage should never exceed vref


    3.
    all your trouble was probably caused by incorrect adc settings , hpwm1 should now work






Similar Threads

  1. ADC values above 4095 for 12 bit ADC
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st February 2015, 22:24
  2. ADC problem on 18F46K22 device using all 28 ADC pins
    By JimAvanti in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd February 2012, 20:22
  3. Replies: 3
    Last Post: - 23rd October 2011, 12:53
  4. Newbie HPWM / ADC question
    By Johan in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 25th June 2007, 12:52
  5. HPWM of the port of two HPWM
    By ja2rqk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 15:05

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