Newbie HPWM / ADC question


Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Jun 2007
    Posts
    56

    Default Newbie HPWM / ADC question

    Hello,

    I am new to PICBASIC and I want to read from a pot and output to HPWM with PIC 16 F 88

    OSCCON = $60 ' Internal oscillator frequency 4 Mhz

    TRISA = %11111111 ' Set PORTA to all input
    TRISB = %00000000 ' Set PORTB to all output
    ANSEL = %01111011 ' Analog channel 0,1,3-7 Digital channel 2,8
    ADCON1= %10000000 ' VDD & VSS as VREF

    DEFINE ADC_BITS 10 ' ADC resolution 10 bit
    DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 50 ' Sampling time 50ms
    define OSC 4 ' Clock 4 Mhz
    analogport VAR PORTA.0 ' Analog port pin RA.0
    analogvalue VAR word ' Value digital 0 - 1024
    pwmduty VAR word

    main:
    ADCIN analogport,analogvalue
    pwmduty = analogvalue / 2
    hpwm 1,pwmduty,7800
    goto main

    is the code correct, since I am not satisfied with the pwm output: the pwm turn off at 2.5v and portb.0 & portb.7 always on

    btw fuse is set on mikroe programmer

    Thanks
    Last edited by Johan; - 23rd June 2007 at 08:45.

Similar Threads

  1. Multiple HPWM question
    By Johan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th October 2007, 13:00
  2. ADC question
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 8th June 2007, 09:52
  3. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  4. HPWM and A to D interaction question 18F252
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 10th May 2006, 03:50
  5. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43

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