PICBasic newbie problem


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    Join Date
    Feb 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Thanks I've commented the Picbasic fuses in the include...

    Fuses is ok but on compiling this code:

    Code:
    ASM
        CONFIG FOSC=HS    ; Use HS oscillator (20MHZ here)
        CONFIG BOR=OFF    ; Brown out reset ON  
        CONFIG WDT=ON    ; Watch dog timer ON
        CONFIG LVP=OFF   ; Low Voltage programming OFF
        CONFIG DEBUG=OFF ; Background debugger OFF
        ENDASM
    led VAR PORTB.5
    steps VAR WORD
    cycles CON 2
    
    ' Change limits for steps to play around 0 or 100% brightness
    ' Change steps for different duration of ramps
    ' Works good even with high brightness LEDs, harder to control linearly
    
    
    fade:
    
    up:
    For steps=0 TO 255
    PWM led,steps,cycles
    Next
    High led
    
    Pause 2500
    
    down:
    For steps=255 TO 1 STEP -1
    PWM led,steps,cycles
    Next
    Low led
    
    Pause 2500
    
    
    GoTo fade
    
    End
    i receive many errors :


    maybe it's the code that is faulty or it's something else ?

    Could you show me a code that will ABSOLUTELY compile (and tested to work), ex: blink a led so i can start to debug the previous code , to see if its my compile that freaks out or it just a simple issue....


    Many thanks!

    Have a nice week!

    Best Regards,

    Laurent

  2. #2
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    I just went through the same problems. See the thread below post#6 regarding editing the .inc file


    http://www.picbasic.co.uk/forum/show...ighlight=fuses
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  3. #3
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    Code:
    ASM
        CONFIG FOSC=HS    ; Use HS oscillator (20MHZ here)
        CONFIG BOR=OFF    ; Brown out reset ON  
        CONFIG WDT=ON    ; Watch dog timer ON
        CONFIG LVP=OFF   ; Low Voltage programming OFF
        CONFIG DEBUG=OFF ; Background debugger OFF
        ENDASM
    I never did get this method to work. I use this method of setting the fuses on my 18F2410:

    Code:
    @       __CONFIG    _CONFIG1H, _OSC_INTIO67_1H
    @       __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    @       __CONFIG    _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H 
    @       __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    Last edited by krohtech; - 8th February 2008 at 21:27.
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Refer to post #20 in the above thread link. PBP still does not support the new style config directive without the double underscore.

    You need to do it the old fashioned way as indicated in the above post by krohtech.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Feb 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Thanks ! You fix all my problems !

    However i have another question about this code and the function PWM...

    How to have multiple pwms output ?

    take a look to the following code

    Code:
    @       __CONFIG    _CONFIG1L, _PLLDIV_3_1L & _CPUDIV_OSC1_PLL2_1L
    @       __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
    @       __CONFIG    _CONFIG2L, _VREGEN_OFF_2L
    @       __CONFIG    _CONFIG2H, _WDT_OFF_2H 
    @       __CONFIG    _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H 
    @       __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    DEFINE OSC 48
    led VAR PORTD
    'changed WORD for BYTE ... using 32bit int for 8bit value is taking more cycle to do operation to it
    step0 VAR byte
    step1 VAR byte
    step2 VAR byte
    step3 VAR byte
    step4 VAR byte
    step5 VAR byte
    step6 VAR byte
    step7 VAR byte
    cycles CON 2
    
    ' Change limits for steps to play around 0 or 100% brightness
    ' Change steps for different duration of ramps
    ' Works good even with high brightness LEDs, harder to control linearly
    
    
    fade:
    
    
    For step0=0 TO 100
    PWM led.0,step0,cycles
    Next
    For step1=0 TO 100
    PWM led.1,step1,cycles
    Next
    For step2=0 TO 100
    PWM led.2,step2,cycles
    Next
    For step3=0 TO 100
    PWM led.3,step3,cycles
    Next
    For step4=0 TO 100
    PWM led.4,step4,cycles
    Next
    For step5=0 TO 100
    PWM led.5,step5,cycles
    Next
    For step6=0 TO 100
    PWM led.6,step6,cycles
    Next
    For step7=0 TO 100
    PWM led.7,step7,cycles
    Next
    
    For step0=100 TO 1 STEP -1
    PWM led.0,step0,cycles
    Next
    For step1=100 TO 1 STEP -1
    PWM led.1,step1,cycles
    Next
    For step2=100 TO 1 STEP -1
    PWM led.2,step2,cycles
    Next
    For step3=100 TO 1 STEP -1
    PWM led.3,step3,cycles
    Next
    For step4=100 TO 1 STEP -1
    PWM led.4,step4,cycles
    Next
    For step5=100 TO 1 STEP -1
    PWM led.5,step5,cycles
    Next
    For step6=100 TO 1 STEP -1
    PWM led.6,step6,cycles
    Next
    For step7=100 TO 1 STEP -1
    PWM led.7,step7,cycles
    Next
    
    GoTo fade
    
    End
    What i want is to fade ON all led each by each while keeping them ON
    then after Turn them OFF (while fading) one by one

    The code only do pwm on 1 led at time only :S

    Any clues ?

    oh btw, searching through the forum is PITA ... it doesn't take words like PWM , because it's too short ... hence rendering the search practically useless for "Multiple PWM"

    Cheers,


    Best Regards,

    Laurent

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ELCouz View Post
    Thanks ! You fix all my problems !
    How to have multiple pwms output ?
    PWM is a blocking command. You can only do one PWM at any one time, PBP only has one 'hand' available to do PWM. You have to write good interrupt driven software to do multiple channels. Well, you don't HAVE to do anything. There are many ways to do multiple channel PWM, software based PWM...

    oh btw, searching through the forum is PITA ... it doesn't take words like PWM , because it's too short ... hence rendering the search practically useless for "Multiple PWM"
    Look in the FAQ's...

  7. #7
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Multi SPWM

    I use Darrel’s Multi SPWM code to get 8 ch of PWM at 100 Hz. Works GREAT (((thanks Darrel)))

    See:
    http://www.pbpgroup.com/modules/wfse...p?articleid=12
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by krohtech View Post
    I use Darrel’s Multi SPWM code to get 8 ch of PWM at 100 Hz. Works GREAT (((thanks Darrel)))
    See:
    http://www.pbpgroup.com/modules/wfse...p?articleid=12
    Forgot about that one.
    I've done it myself on an 18F8722 to the tune of 48 channels of LEDs at 40Mhz, refreshing at 7152.2Hz. Same principle, but relatively easily done. If you can do 2 channels, you can do 100.

  9. #9
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Forgot about that one.
    I've done it myself on an 18F8722 to the tune of 48 channels of LEDs at 40Mhz, refreshing at 7152.2Hz. Same principle, but relatively easily done. If you can do 2 channels, you can do 100.
    Hey skimask,

    How did you do 48 CHannels. Did you have to modify Darrel's asm code?
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by krohtech View Post
    Hey skimask,

    How did you do 48 CHannels. Did you have to modify Darrel's asm code?
    Didn't use DT's code for that one.
    Just a simple Tmr0 overflow running as fast as it can... When the interrupt hits, I update the channels/pins according to their duty cycle 'register' variable. Outside the interrupt sub, in the main loop, I update the duty cycle 'register' itself depending on whatever I'm doing. Theoretically, assuming there's enough clock cycles in the day, you can run as many channels as you want.
    On the '8722, you could have up to 70 channels of halfway decent PWM (well, 69, one of those pins is input only if I remember right). I only stopped at 48 'cause that's all the red LEDs I had on hand at the time.

Similar Threads

  1. Newbie? Problem with LCD
    By lew247 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th December 2009, 19:48
  2. Picbasic Newbie Problem
    By Stargazer3141 in forum mel PIC BASIC
    Replies: 4
    Last Post: - 21st August 2007, 17:40
  3. Problem on writing EEPROM in Winpic800 with picbasic pro
    By selimkara in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th May 2007, 16:33
  4. PicBasic Pro Math Problem??
    By Glen65 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th March 2006, 04:36
  5. DMX & PicBasic coding problem
    By magicmarty in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th September 2004, 15:35

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