Darrel Taylor's SPWM code usage


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Posts
    35

    Unhappy Darrel Taylor's SPWM code usage

    Hello All

    A while ago I tried using Darrel Taylor's "Instant Interrupts. The demo showed that

    three separate items could run (seemingly) at the same time using this interrupt scheme. It is a great piece of code.

    Recently I tried to use the SPWM code with a 16F628a and three LEDs. After a day of

    "it won't run at 20MHZ problems", I finally found the problem in posts concerning "setting fuses". If you are

    venturing from 4MHZ to 20 MHZ for the first time, take the time to read these posts. Fuses are a real "gotcha" and

    this may save you hours of frustration.

    http://www.picbasic.co.uk/forum/show...ighlight=fuses
    http://melabs.com/support/config_defaults.htm

    Anyway...I finally got the SPWM demo to run. The problem I have is

    that the only advantage I can find here is that the PWM function can be held at a certain value

    after leaving a for next loop. That's good! I could not do that with the basic PWM function

    since the pulse generation stops when the loop is ended.

    What I don't see in the demo is an example of the (magic) seemingly simultaneous interrupt scheme put to use as in

    the "Instant Interrupts" code. I would like to run three PWM outputs independently controlled

    using a technique similar to the one shown below. The SPWM demo uses a nesting of "for next" statements

    but never seems to use the interrupt handlers. I have played around with INT settings in the

    belly of the ASM beast but I'm just guessing.

    Is this possible? Am I making this clear, or should I have another beer?



    Something like below except for SWPM......

    Main:
    IF SecondsChanged = 1 THEN
    SecondsChanged = 0
    LCDOUT $FE,$C0, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds
    ENDIF
    GOTO Main


    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:
    TOGGLE LED1
    @ INT_RETURN

    '---[TMR0 - interrupt handler]-------------------------------(Blinky Light)------
    T0Count VAR WORD
    ToggleLED2:
    T0Count = T0Count + 1
    IF T0Count = 512 THEN T0Count = 0 : TOGGLE LED2
    @ INT_RETURN



    "LISA, JUST ANSWER THE QUESTION, DADDY SHOULD BET ON!......"


    Thanks in advance.
    Thanks,
    Homerclese

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Homerclese View Post
    What I don't see in the demo is an example of the (magic) seemingly simultaneous interrupt scheme put to use as in the "Instant Interrupts" code. I would like to run three PWM outputs independently controlled
    Here is an example of using his Instant Interrupt code to perform SPWM. I am cheating here a bit, using the R/C receiver as my 20ms timer. But it gives you an idea how to pulse your pins for a set amount of time. It uses one interrupt timer to SPWM out to 4 pins. http://www.scalerobotics.com/stamps/84-projects/pwm/71-pwm-passthrough.html

    Edit: Mybad, I forgot about Mibam. If you are interested in PWM for lighting/led control, you can use Mibam, basically a SPWM for smooth lighting effects on multiple pins. See: http://www.picbasic.co.uk/forum/showthread.php?t=10564
    Last edited by ScaleRobotics; - 11th October 2011 at 06:06.

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts