0-10v dc


Closed Thread
Results 1 to 25 of 25

Thread: 0-10v dc

Hybrid View

  1. #1
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Sorry should be:
    if DownButton =0 then
    If Vduty>0 then Vduty=Vduty-B0
    Gosub HpwmSet
    endif

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Sorry should be:
    if DownButton =0 then
    If Vduty>0 then Vduty=Vduty-B0
    Gosub HpwmSet
    endif
    You know you can EDIT your own posts right?
    Look down by the QUOTE button after you've submitted your post.

  3. #3
    Join Date
    Sep 2006
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Sorry should be:
    if DownButton =0 then
    If Vduty>0 then Vduty=Vduty-B0
    Gosub HpwmSet
    endif
    Hi all, no luck, Please gothru my code...Thanks.

    Include "MODEDEFS.BAS" ' Include Shiftin/out modes

    @ device PIC16F877A , xt_osc, wdt_on, pwrt_on, protect_on ,lvp_off
    Define Osc 4 ' using a 4 MHz oscillator


    ; 76543210
    TRISA = %00000000 ' ALL OUTPUTS
    TRISB = %11111111 ' ALL INPUTS- KEYBRD
    TRISC = %11110001 '
    OPTION_REG.7=0 'Enable internal pull-ups
    OPTION_REG = %11111000 ' Assign prescaller to WDT

    TRISA = 0 ' Set PORTA as output
    T1CON.1 = 0 ' Set TIMER1 clock source to internal clock
    INTCON = %01000000 ' Enable peripheral interrupts
    PIE1 = %00000001 ' Enable TMR1 overflow interrupt
    CCP1CON=%00001100 ' PWM MODE


    UpButton Var PORTB.0
    DownButton var PORTB.1
    PWMOut Var PORTC.1 ' PWM Output


    DEFINE CCP1_REG PORTC 'Hpwm 1 pin port
    DEFINE CCP1_BIT 2 'Hpwm 1 pin bit

    DEFINE HPWM2_TIMER 1 'Hpwm 2 timer select

    B0 var Byte
    Vduty var Byte

    Vduty=0
    B0=1

    pause 100

    Main:

    if UpButton =0 then
    If Vduty<255 Then Vduty=Vduty+B0
    Gosub HpwmSet
    endif

    if DownButton =0 then
    If Vduty>0 then Vduty=Vduty-B0
    Gosub HpwmSet
    endif
    goto Main


    HpwmSet:

    HPWM 1,25,1000 '4.00khz
    'HPWM 1,25,250 '16.00khz. tried this also.

    Return

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Do you have a couple of LEDs handy?
    I always add a 'heart beat' LED to whatever I'm doing, even if I know the hardware is working... Really helps for troubleshooting...
    And if you're using the internal pullups, you're turning on the internal pull-ups, then turning them right back off...
    Code:
                     OPTION_REG.7=0 'Enable internal pull-ups
    	         OPTION_REG = %11111000 ' Assign prescaller to WDT

  5. #5
    Join Date
    Sep 2006
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Do you have a couple of LEDs handy?
    I always add a 'heart beat' LED to whatever I'm doing, even if I know the hardware is working... Really helps for troubleshooting...
    And if you're using the internal pullups, you're turning on the internal pull-ups, then turning them right back off...
    Code:
                     OPTION_REG.7=0 'Enable internal pull-ups
    	         OPTION_REG = %11111000 ' Assign prescaller to WDT
    Hi, Still not working..need help..

    Thanks.

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    naga

    Go back to your post #17

    In it you are changing a variable Vduty. This part is good.

    You then call a subroutine HpwmSet. Explain to me how in your code Vduty changes the HPWM setting?

    Go to the PICBASIC manual, look up HPWM and how it is used, an then install Vduty correctly so it actually changes your PWM setting.

  7. #7
    Join Date
    Sep 2006
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    naga

    Go back to your post #17

    In it you are changing a variable Vduty. This part is good.

    You then call a subroutine HpwmSet. Explain to me how in your code Vduty changes the HPWM setting?

    Go to the PICBASIC manual, look up HPWM and how it is used, an then install Vduty correctly so it actually changes your PWM setting.
    @Melanie, Should i change " HPWM 1,25,1000" TO " HPWM 1,127,1000" ? as per the PBPManual. And please let me know if any other value needs to be changed.. Actaully i'll have to finish this project as soon as possible..

    Thank you verymuch..

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    What Melanie meant was to examine this piece of code:
    Code:
    HpwmSet:
    HPWM 1,25,1000   '4.00khz
    'HPWM 1,25,250   '16.00khz. tried this also.
    Return
    1 is a constant, 25 is a constant, 1000 is a constant.
    If the values in the HPWM statement are all constants, how is a variable in your main loop supposed to change that constant?

    If you change
    HPWM 1,25,1000
    to
    HPWM 1,127,1000
    all you've done is change the 25 to a 127.

    So, WHAT in your code is going to change ANYTHING in your HPWMset subroutine?

Similar Threads

  1. DC to AC convertor
    By The Master in forum Off Topic
    Replies: 11
    Last Post: - 6th February 2010, 17:44
  2. Replies: 24
    Last Post: - 1st December 2009, 08:01
  3. from 5v dc to 1.00v dc precise vref 10mA ?
    By phoenix_1 in forum Schematics
    Replies: 10
    Last Post: - 28th July 2009, 08:11
  4. PIC data along dc line
    By sswcharlie in forum General
    Replies: 0
    Last Post: - 30th August 2008, 08:38
  5. H-Bridge control DC motor
    By Paul F in forum General
    Replies: 2
    Last Post: - 2nd March 2005, 21:04

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