PICBasic newbie problem


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    3 channels ...
    No, No, No!
    You said you could do 48 channels.
    That's what they want.
    Frankly, I like to see 48 chanels of 8-bit software PWM too.
    <br>
    Well, the basics are there (as you well know)...
    And the 48 channels...I'll post some differences:
    18F8722 vs. 16F628A
    40Mhz vs. 20Mhz
    Timer 0 prescale is 1:2 instead of 1:1, thereby keeping the same 76Hz Freq of PWM...
    ...got 512 cycles to work with instead of 256. 48 channels in 512 cycles = 10 cycles per channel with even some extra leftover.
    Code is practically the same, except:
    PWM 0-7 on PortB (along with PGC/PGD/PGM, LVP disabled)
    PWM 8-15 on PortD (serial comm's on PortC, along with a couple of buttons)
    PWM 16-23 on PortE
    PWM 24-31 on PortF
    PWM 32-39 on PortH
    PWM 40-47 on PortJ
    The rest of the pins are either used for buttons, indicators, or whatever, the usual crap.

    At first I had a heck of a time finding enough cycles to run everything thru the interrupt loop and not miss any interrupts, that's when I figured out to keep all of the PWM channels in blocks of 8, byte writes to each port instead of bit writes saved just enough time to make it work reliably and leave a bit of time leftover to actually have a MAINLOOP to do other things. There's a few other shortcuts in the interrupt loop, such as checking the high bit of each DCR instead of checking the whole thing when doing the comparisons. That's one of the places where the PWM jitters a bit (I never said it was a ROCK SOLID 48 channels!). If too many of the channels have to take the jump where it sets or resets the pin, the PWM for all of them hiccups a bit. Worst case scenario is when all DCRs for each channel are exactly the same, they all have to take the jump to reset the pins. But if they're spread out, it's not bad at all. I can even trace it on the 'scope and only get a couple of us of jitter.

    THERE! Now everybody knows all of my secrets!

    You know, come to think of it...this might be one of those things just would go good with that little 'code optimization' exercise that went on awhile back.
    Get an '8722 to use every available pin for software driven PWM'ing of LEDs, while using the serial port for control at high speed, and still have solid PWM.
    Last edited by skimask; - 10th February 2008 at 04:04.

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