adcin and HPWM


Closed Thread
Results 1 to 25 of 25

Thread: adcin and HPWM

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I tried the following program, very simple, still not getting anything out..
    using internal osc, trying to cut down on the hardware...



    'Test HPWM command
    '
    INCLUDE "modedefs.bas" 'Includes supoprt for PicBasic language
    @ DEVICE pic16F88, CCPMX_ON, INTRC_OSC_NOCLKOUT

    OSCCON = %110 ' Set OSC TO 4MHZ 'select the clock


    'DEFINE OSC 20 'use external 20mhz crystal
    PAUSE 100 ' start-up delay

    '/////////////////////////
    '// PIN configuration //
    '/////////////////////////

    DEFINE CCP1_REG PORTB 'Define output port of pulses out
    DEFINE CCP1_BIT 3 'Define output port of pulses out

    CMCON = 7 ' Disable analog comparator

    TRISB = %00000000 ' Set PORTB to all output
    TRISA = %11111111 ' Set PORTA to all input

    '///////////////////////////////////////////////
    '// Variable Declaration and initialization //
    '///////////////////////////////////////////////

    '//////////////////////////
    '// Program starts here //
    '//////////////////////////
    HPWM 1,126,3000
    PAUSE 200 ' delay

    Mainloop:

    GOTO Mainloop
    end

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I tried the following program, very simple, still not getting anything out..
    using internal osc, trying to cut down on the hardware...
    Which pin on the PIC are you looking at? And how are you looking at it?

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I am looking at B.3 through my scope.
    I am using the same hardware as my digital thermometer now, which was using B.3 to get the temperature and have a LCDout. (and that circuit is working fine, but no a/d or HPWM)
    So I removed that wire on B.3 (of course) , placed the new chip in place and I am not seeing anything to the scope

    k

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    CCPMX_ON .... that should be off....

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I found a working program from steve in another thread:
    @ DEVICE MCLR_ON, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF, CCPMX_ON
    OSCCON=$60 ' use internal 4MHZ osc
    PAUSE 100 ' start-up delay
    TRISB=0
    DEFINE CCP1_REG PORTB
    DEFINE CCP1_BIT 3
    HPWM 1,128,1000
    HERE: GOTO HERE

    I just change the oscillation to 20Mhz, and it si not working: I think this is the problem..
    I change the program to:

    @ DEVICE MCLR_ON, HS_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF, CCPMX_ON
    DEFINE OSC 20 'use external 20mhz crystal 'OSCCON=$60 ' use internal 4MHZ osc
    PAUSE 100 ' start-up delay
    TRISB=0
    DEFINE CCP1_REG PORTB
    DEFINE CCP1_BIT 3
    HPWM 1,128,1000
    HERE: GOTO HERE

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    CCPMX_ON .... that should be off....
    That's one problem I'm thinking of. Not reading the right pin...

    Quote Originally Posted by lerameur View Post
    I found a working program from steve in another thread:
    Look at your manual under HPWM. Can't do 1000 Hz at 20Mhz...

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    19531Hz for a 20Mhz

    I remember using 5Khz for one of my project for motor driver PWM.

    How can I change steve's program to use a 20Mhz crystal?

Similar Threads

  1. ADCIN > HPWM but with min/max limits - i failed maths
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th November 2009, 02:02
  2. 16F684 adcin and hpwm
    By astouffer in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 21st November 2008, 17:29
  3. Portc.3 latching?
    By Bronurstomp in forum mel PIC BASIC
    Replies: 4
    Last Post: - 10th November 2008, 17:47
  4. PIC16F819 HPWM CCP1 clariffication
    By earltyso in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th March 2008, 18:43
  5. Newbie HPWM / ADC question
    By Johan in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 25th June 2007, 12:52

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