Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)


+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 55
  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    Scroll down to this post for a list of ZIP files:
    http://www.picbasic.co.uk/forum/show...286#post130286

    Darrel's site is down so his links no longer work. Some can be found at the archive:

    14 bit: http://web.archive.org/web/201201100...-14/intro.html

    18 bit: http://web.archive.org/web/201009201...S-18/home.html
    ------------------------------------------------------------------------------------------------------------

    Elapsed Timer Demo

    Attached to this post is a Zip file that contains a "Drop-In" elapsed timer that uses Timer1 and interrupts. It's waaay down there at the bottom of all this dribble. This may get rather long winded, so my first suggestion is to scroll down to the bottom of this post and check out the file then come back and read this post later.

    --------------------- ----------------------- -----------------------------
    The files contained in the Zip are:

    Test_Elapsed_SER.pbp ' Demo of Elapsed Timer using serout2 command and HyperTerminal
    Test_Elapsed_LCD.pbp ' Demo of Elapsed Timer using an LCD
    Elapsed.bas ' Elapsed Timer include file
    ASM_INTS.bas ' Assembly language Interrupt Stubs

    Note: These files are intended to be used on 14-bit core PICS (12F, 16C and 16F) that have a TIMER1 module.
    Note2: They are written for use as the only interrupt in the program. If you need to use other interrupts as well, the program will have to be modified before it will work.
    Note3: It will NEVER work in conjunction with PBP's ON INTERRUPT statement.

    In it's simplest form, this is all it takes to use the Elapsed Timer:
    Code:
        Include "Elapsed.pbp"
        Gosub ResetTime    ' Reset Time to  0d-00:00:00.00
        Gosub StartTimer   ' Start the Elapsed Timer
    This will create a Clock counting at 1/100 seconds. It runs in the background of PBP without any other program intervention required.

    The time is kept in the variables:
    Code:
        Ticks    var byte   ' 1/100th of a second
        Seconds  var byte   ' 0-59
        Minutes  var byte   ' 0-59
        Hours    var byte   ' 0-23
        Days     var word   ' 0-65535
    The time can be easily displayed with a single line:
    Code:
        LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes,":",dec2 Seconds
    For each of the variables (Seconds, Minutes, Hours and Days) there is a flag that indicates when the value of that variable has changed.
    The Flags are:
    Code:
        SecondsChanged   var bit
        MinutesChanged   var bit
        HoursChanged     var bit
        DaysChanged      var bit
    So, if you wanted to display the time like a clock, you could wait until SecondsChanged = 1, display the time, then reset the flag.
    Code:
        Loop1:
            if SecondsChanged = 1 then
               LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes,":",dec2 Seconds
               SecondsChanged = 0
            endif
        Goto Loop1
    If you only wanted to display the time each minute instead of every second just do the same thing using the MinutesChanged flag.
    Code:
        Loop1:
            if MinutesChanged = 1 then
               LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes<br>           MinutesChanged = 0
            endif
        Goto Loop1
    The timer can be Stopped and Started, like a stopwatch.
    Code:
        Gosub StopTimer
        Gosub StartTimer
    --------------------- ----------------------- -----------------------------
    The Elapsed.bas include file also Includes another file, ASM_INTS.bas This file can also be used in your other programs as well. It handles the "Context Saving" that is required for any Assembly language interrupt.

    It contains 2 macros:
    INT_START
    Saves the W, STATUS, PCLATH and FSR registers. This can be used at the beginning of your Interrupt routine.

    INT_RETURN
    Restores the W, STATUS, PCLATH and FSR registers after the Interrupt routine is finished and then returns from the Interrupt (RETFIE).

    Using it in a normal Assembly language interrupt might look something like this:

    Code:
        Define  INTHAND  INT_CODE    ' Tell PBP Where the code starts on an interrupt
    ASM
    INT_CODE
        INT_START                ' Save Context
            ... Your Interrupt routine goes here ...
        INT_RETURN               ' Restore Context
    EndAsm
    Well, I guess that covers most of it. if I've missed anything, or you still have questions, please don't hesitate to ask.

    Happy holidays,
    Attached Files Attached Files
    Last edited by Demon; - 23rd June 2015 at 17:26.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Elapsed-18.bas

    Here's the version for 18F's.

    It should be a drop-in replacement for the old version. Everything works the same, except for the registers saved on entry to the INT routine.

    So, you can still use the Test_Elapsed_LCD/SER.bas demo's from the original version for testing. Just add the "-18" to the INCLUDE line.
    <br>
    Attached Files Attached Files
    DT

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    Here's a simple INCLUDE file wich allow to scan any matrix KeyPad format on any PORT you decide. Yeah i know, a bit code hungry but simple to use and it's free...

    The defaults setings are
    1. Keypad ROW are connected to PORTB<3:0>
    2. Keypad COL are connected to PORTB<7:4>
    3. Debounce delay = 200 mSec
    4. No auto-repeat
    5. Keypad type 4X4

    Code example using the default setting
    Code:
        INCLUDE "KeyPad.bas"         
        myvar                    var byte
    
    start:
        @ READKEYPAD _myvar
        hserout ["Key=",dec myvar,13,10]
        goto start
    NOT MUCH!
    If you decide to change default settings, here's the DEFINEs list
    Code:
            DEFINE KEYPAD_ROW        4        ' 4 ROW keypad       
            DEFINE KEYPAD_ROW_PORT   PORTB    ' ROW port = PORTB
            DEFINE KEYPAD_ROW_BIT    4        ' ROW0 = PORTB.4
            DEFINE KEYPAD_COL        4        ' 4 COL keypad
            DEFINE KEYPAD_COL_PORT   PORTB    ' COL port = PORTB
            DEFINE KEYPAD_COL_BIT    0        ' COL0 = PORTB.0
            DEFINE KEYPAD_DEBOUNCEMS 200      ' debounce delay = 200 mSec
            DEFINE KEYPAD_AUTOREPEAT 1        ' use auto-repeat feature
    When using the auto-repeat feature, the delay is the debounce delay (DEBOUNCEMS)

    Code example #2: Using a 8X4 keypad
    Code:
        INCLUDE "KeyPad.bas"         
    
        '                      
        '    Hardware connection
        '    ===================
        DEFINE KEYPAD_ROW        8       ' 8 row 
        define KEYPAD_ROW_PORT   PORTB   '   on PORTB
        DEFINE KEYPAD_ROW_BIT    0       '      <7:0>
        DEFINE KEYPAD_COL        4       ' 4 col 
        DEFINE KEYPAD_COL_PORT   PORTA   '   on PORTA
        DEFINE KEYPAD_COL_BIT    0       '      <3:0>
        DEFINE KEYPAD_DEBOUNCEMS 200     ' debounce delay = 200 mSec
        define KEYPAD_AUTOREPEAT 1       ' use auto-repeat
        
        '
        '    Serial Communication definition
        '    ===============================
        DEFINE HSER_TXSTA 24h            ' enable transmit, BRGH=1
        DEFINE HSER_SPBRG 129            ' 9600 Bauds
    
        '   
        '    Variables definition 
        '    ===================
        myvar                    var byte
    
        '    ---------------------------------[Program Start]----------------------------------------------
    start:
        @ READKEYPAD _myvar
        hserout ["Key=",dec myvar,13,10]
        goto start
    It set the according TRIS register for you everytime you call the MACRO.. kinda bullet-proof

    Everything is explain in the attach file... don't forget to rename it
    Attached Files Attached Files
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    This is a series of include files that simplify the process of creating interrupt driven programs for PicBasic Pro. MPASM required.

    Once you try this, you may never use ON INTERRUPT again.

    Features:
    Assembly language Interrupts
    Basic language Interrupts
    Both ASM and Basic interrupts in the same program
    Service Multiple Interrupt sources
    Prioritized execution order
    Very easy to use


    No ON INTERRUPT "Code Bloat"
    No ON INTERRUPT " I'll service your interrupt whenever I feel like it." mentality.
    .
    One of the best things about this system, is that you don't have to remember where all the Enable bits and Interrupt flags are located.

    Each interrupt "source" is given a unique name that is used to reference it.
    The system "Looks Up" the correct bit locations for that name. Reducing those RTFM sessions to a minimum.
    The following table lists the Named Interrupts.
    Note: More interrupts have been added .. please visit http://darreltaylor.com/DT_INTS-14/intro.html

    Available Interrupt Sources 14-bit
    Code:
     INT_INT -- INT External Interrupt
     RBC_INT -- RB Port Change Interrupt
     TMR0_INT -- TMR0 Overflow Interrupt 16F
     TMR1_INT -- TMR1 Overflow Interrupt
     TMR2_INT -- TMR2 to PR2 Match Interrupt
     TX_INT -- USART Transmit Interrupt
     RX_INT -- USART Receive Interrupt
     CMP_INT -- Comparator Interrupt
     EE_INT -- EEPROM/FLASH Write Operation Interrupt
     BUS_INT -- Bus Collision Interrupt
     PSP_INT -- Parallel Slave Port Read/Write Interrupt
     AD_INT -- A/D Converter Interrupt
     SSP_INT -- Master Synchronous Serial Port Interrupt
     CCP1_INT -- CCP1 Interrupt
     CCP2_INT -- CCP2 Interrupt
    Here's a simple example of toggling an LED using the external interrupt (INT). (Hello World)
    Code:
    LED1   VAR  PORTB.1
    
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    
        INT_ENABLE   INT_INT     ; enable external (INT) interrupts
    ENDASM
    
    Main:
      PAUSE 1
    GOTO Main
    
    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    Code Size = 234 words

    This project, and it's associated files, have been moved.
    Please download them from my website.
    DT_INTS-14 (12F-16F)
    http://darreltaylor.com/DT_INTS-14/intro.html

    DT_INTS-18 (18F)
    http://darreltaylor.com/DT_INTS-18/home.html

    .

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Example 2

    The ultimate overkill Blinky Light program ... using Timer 1
    Code:
    LED1   VAR  PORTB.1
    
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    T1CON = $31                ; Prescaler=8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    
    Main:
      PAUSE 1
    GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    Code Size = 240 words

    OK, Why? ... You might ask.
    Well, for one, this Blinky Light program will continue Blinking at the same rate, no matter what else you add to the Main: program loop. Try doing that with pauses.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Elapsed Timer

    The NEW Elapsed Timer does, ... well .. it does exactly the same thing as the old Elapsed Timer. But now it works with the Instant Interrupt system. Which means that you can use many other interrupts in the same program without much trouble at all. Unlike the last version.

    Here's an example of just the Elapsed Timer by itself.
    Code:
    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    INCLUDE "Elapsed_INT.bas"  ; Elapsed Timer Routines
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ClockCount,   PBP,  yes
        endm
        INT_CREATE            ; Creates the interrupt processor
    
        INT_ENABLE  TMR1_INT  ; Enable Timer 1 Interrupts  
    ENDASM
    
    GOSUB ResetTime           ' Reset Time to  0d-00:00:00.00
    GOSUB StartTimer          ' Start the Elapsed Timer
    
    Main:
      IF SecondsChanged = 1 THEN  
         SecondsChanged = 0
         LCDOUT $FE,2, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds
      ENDIF
    GOTO Main
    Code Size = 537 Words

    This will create a Clock counting at 1/100 seconds. It runs in the background of PBP without any other program intervention required.

    The time is kept in the variables:
    Code:
        Ticks    var byte   ' 1/100th of a second
        Seconds  var byte   ' 0-59
        Minutes  var byte   ' 0-59
        Hours    var byte   ' 0-23
        Days     var word   ' 0-65535
    The time can be easily displayed with a single line:
    Code:
        LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes,":",dec2 Seconds
    For each of the variables (Seconds, Minutes, Hours and Days) there is a flag
    that indicates when the value of that variable has changed. The Flags are:

    SecondsChanged var bit
    MinutesChanged var bit
    HoursChanged var bit
    DaysChanged var bit

    If you wanted to display the time like a clock, you could wait until
    SecondsChanged = 1, display the time, then reset the flag.

    Code:
        Loop1:
            if SecondsChanged = 1 then
               LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes,":",dec2 Seconds
               SecondsChanged = 0
            endif
        Goto Loop1
    If you only wanted to display the time each minute instead of every second
    just do the same thing using the MinutesChanged flag.

    Code:
        Loop1:
            if MinutesChanged = 1 then
               LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes
               MinutesChanged = 0
            endif
        Goto Loop1
    The timer can be Stopped and Started, like a stopwatch.
    Code:
        Gosub StopTimer
        Gosub StartTimer
    Attached Files Attached Files

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Bringing them together

    So far I've shown one interrupt source being used at a time, but as I said in the first post, you can easily service Multiple Interrupt Sources. &nbsp; So what if we wanted to join the previous 3 examples into one program. &nbsp; NOT a problem!

    To add more interrupt "Handlers", simply add them to the INT_LIST, and create a subroutine for them.

    Since both the Blinky Light, and Elapsed Timer used TMR1, lets move the Blinky Light over to TMR0. Elapsed will still use TMR1.
    Code:
    LED1   VAR  PORTD.0
    LED2   VAR  PORTD.1
    
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    INCLUDE "Elapsed_INT.bas"    ' Elapsed Timer Routines
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,  _ToggleLED1,   PBP,  yes
            INT_Handler   TMR0_INT,  _ToggleLED2,   PBP,  yes
            INT_Handler   TMR1_INT,  _ClockCount,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    
        INT_ENABLE   INT_INT     ; enable external (INT) interrupts
        INT_ENABLE  TMR0_INT     ; enable Timer 0 interrupts
        INT_ENABLE  TMR1_INT     ; Enable Timer 1 Interrupts  
    ENDASM
    
    OPTION_REG = OPTION_REG & $80 | 1  ; Set TMR0 Prescaler to 256, leave RBPU alone
    GOSUB ResetTime              ' Reset Time to  0d-00:00:00.00
    GOSUB StartTimer             ' Start the Elapsed Timer
    
    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
    
    <font size=-2>Code Size = 711 Words</font>

    Now we have all three interrupt sources working together in the same program.
    LED1 responds to the external INT
    LED2 flashes, timed by TMR0
    and, the elapsed timer is maintained via TMR1
    And, all of this is happening behind the scenes of your normal PBP program.
    Attached Files Attached Files

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default The Base Layer - ASM interrupts

    <table cellpadding=6><tr><td valign=center></td><td>The Instant Interrupt System consists of several "Layers".

    The Bottom Layer is "DT_INTS-14.bas". This file contains everything required to use Interrupts at the ASM level. &nbsp; It handles all of the "Context Saving/Restoring", detects which interrupt has been triggered, and calls the appropriate "User Routine".

    The next layer up is created from the INT_LIST macro you define in the program. &nbsp; It defines the Interrupt sources to use and the corresponding subroutines that will be called. &nbsp; They can be either simple subroutines, or complete "Modules" in a separate Include file, like the Elapse Timer. &nbsp; Up to 14 separate INT_Handler's can be in the LIST.

    And, the Top Layer is the normal PBP program that runs in the foreground.

    If Basic Laguage interrupts are not being used, then DT_INTS-14.bas is the only file you need to include.</td></tr></table>Here's another example of a Blinky Light program using TMR1 with an Assembly Language Interrupt handler
    Code:
    LED1   VAR  PORTD.0
    LOW  LED1                    ; Set to Output Low
    
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,   ToggleLED1,   ASM,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    
        INT_ENABLE  TMR1_INT     ; Enable Timer 1 Interrupts  
    ENDASM
    
    T1CON = $31                  ; Prescaler=8, TMR1ON
    
    Main:
        PAUSE 1
    GOTO Main
    
    '---[TMR1_INT - interrupt handler]------------------------------------------
    ASM
    ToggleLED1
        btfsc  _LED1
        goto   $+3
        bsf    _LED1
        goto   $+2
        bcf    _LED1
        INT_RETURN
    ENDASM
    
    <font size=-3>Code Size = 104 Words</font>

    Notice that the INT_Handler's Type is ASM, and the Label does not have an underscore before it.<hr><table cellpadding=6><tr><td></td><td valign=top>By using this type of Layering scheme. It allows us more flexability, depending on the type of interrupt we want to use. &nbsp; If we want to add Basic Language Handlers, all we need to do is Include "ReEnterPBP.bas", and it will insert another Layer in-between the Base and the Handlers.

    With this layer included, you can have any combination of ASM and PBP interrupts in the same program</td></tr></table>
    <br>

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default ReEnterPBP.bas - An adaptation of INT_CTRL.pbp

    October 05, 2002 was a good day. &nbsp; Because that's the day that Tim Box released his "INT_CTRL.pbp" program. &nbsp; The original "Instant Interrupts"

    Tim had discovered that the only reason you couldn't use Basic statements in a normal interrupt, was because the PBP system variables currently being used by the statement that got interrupted, would be overwritten by the Basic statements in the interrupt routine. &nbsp; And that, all you have to do is save the state of the system vars at the start of the interrupt, and restore them back to the way they were before exiting the interrupt and you can use any Basic statements you want.

    I've probably said it too many times already but ... Thanks again Tim!
    <hr>
    ReEnterPBP.bas is an adaptation of the same concept, but it allows the Interrupt system to determine if it needs to save the variables or not.

    For instance, if you have a program with both ASM and PBP interrupt handlers, and an interrupt triggers an ASM handler, there's no need to save the variables first, it would just be waisting valuable time. And if more than 1 Basic handler is triggered at the same time, it only saves the variables once, and processes all the Interrupts on the same pass, before restoring the system vars, again saving time.

    However, it does still take a lot of time to save all those variables. Usually it takes around 70 instruction cycles to save the vars. Then another 70 cycles to restore them again. At 4mhz it's 140us total save and restore time, which limits the maximum interrupt frequency to just over 7khz. At 20mhz OSC, you can go up to almost 36khz. That's fast enough to receive RS232 at over 250Kbaud with the USART. &nbsp; But is still considerably slower than you can get with ASM interrupts.

    <br>

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Cool DT_INTS-18 Interrupts for 18F's Now Available

    <table><tr><td></td><td>
    At long last.

    The Instant Interrupt system for 18F PIC's is now available.

    It's become increasingly harder to keep things up to date here on the forum, so I've moved everything over to my website.
    I'm still working on some of the pages, but everything you need is already there. It seems to take longer to make the web pages, than it does to write the program.

    http://darreltaylor.com/DT_INTS-18/home.html</td></tr></table>

    <br>
    DT

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Interrupts and the MCSP debugger, don't get along together very well.

    You should use DISABLE DEBUG before any interrupt routines, Including the Handlers.

    Then ENABLE DEBUG after them.

    It is possible to save the debugger variables in the same way as ReEnterPBP, but it's a waste of space when not debugging, so I didn't include them

    HTH,
    &nbsp; DT

  12. #12
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi ozion,

    First rule of interrupts, Never Wait for anything.

    Interrupt handlers should execute as fast as possible, and exit as soon as possible.

    With 18F's you can get away with using HSERIN/HSEROUT with Waits and Pauses, by putting them in a LOW priority interrupt handler. But with the 16F's, you don't have that option.

    If you want to use interrupts to receive serial data on 16F's, then you should only grab 1 byte at a time then exit. You can keep track of how many bytes have been received and set a Flag when finished so that it can be dealt with in the Main loop. Then you can HSEROUT to your hearts content.

    Otherwise, do all the serial stuff in the main loop, RX and TX. The main loop should run fast enough to catch everything. And the interrupts will continue on like they should.

    HTH,
    &nbsp; Darrel

  13. #13
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Cool Software PWM for DT_INTS-xx

    Ok Willem,

    Well, I decided to forget about the things I should have done this weekend, and went ahead and re-wrote the SPWM program to work with the Instant Interrupt system.

    I've added a few things, and it works a little different this time around. So, be sure to look close at the example.

    It'll work with either the 18F or 14-bit versions, even though I only put it in the DT_INTS-14 section for now.

    SPWM_INT
    http://www.darreltaylor.com/DT_INTS-14/SPWM.html

    Enjoy,
    DT

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    MULTICALC


    Hi all,
    Few times ago i did this little utility to help in Timer, Usart, Eusart and PWM calc. It have been tested by some user here and there. Thanks to them

    'till now, it's seems to be bug free. It assume a minimum of knowledge on your side so far.

    I plan to do another version wich will be more complete. It will include more code generation tool. It's still a work in progress but once i'm fixed on the whole idea, i'll post a Trial version.

    It will create code for PBP, Swordfish and probably some other compiler.

    You have to know it's a tedious job to read all datasheet and be sure everything is correct. For this reason, there's no release date.

    Any wish, comments, suggestions are welcome.

    Enjoy!


    EDIT: Mister Es site is down, get v1.3.1 down at Alain's post:
    http://www.picbasic.co.uk/forum/show...267#post130267
    Attached Files Attached Files
    Last edited by Demon; - 23rd December 2014 at 16:28.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  15. #15
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    Hi all,
    Since the USB stuff is coming more and more popular, and as we see more and more questions, i decided to post my little contribution.

    OK OK You already asked... but i'm in a good moon today, so let me believe it never been asked before

    The whole thing will use a PIC18F4550 and a 4MHz crystal + few Leds, 2 trim pot... you should be able to figure this out easy.

    There we go, here's the PC interface,

    <img SRC="http://www.mister-e.org/Pics/USBDemo.JPG">

    Sounds good eh?

    With this you can
    1. play with both CCP (PWM) duty cycle and show it on 2 leds attach to your PIC CCP i/o (PORTC.1, PORTC.2)
    2. modify each PORTB bits status as you wish.

    You can also
    1. see the results of AN<1:0> ADC results in the progress bars
    2. monitor the status of those push-buttons attach to PORTA<5:2> inputs (with pull-down resistors)
    3. receive text string
    4. Display your VendorName and ProductName.
    So almost everything EASY will be covered in both code.

    I tried to stay away of the cryptic-fashioned coding but i couldn't resist to use some macro etc etc. Eh, maybe you'll learn from it? Who knows?

    In attachment, you'll find ALL FILES. PBP source code and VB6 source code AND a ready to run USBDemo.exe file. Everything is hardly commented so, read it carefully... it won't hurt!

    The original folder was c:\PBP_PROG\USBDemo but it shouldn't cause any problem... well i guess. If so, you know where to send them.

    NOTE: If you're going to use LONG variables, you MUST copy the PIC18Xxxxx.BAL file in your source directory as well, unless you'll receive some compilation errors.

    The .BAL file is located in \PBP\USB18 directory.

    Those who want to use PIC18F2455, 18F2550, have a look at post 99.
    http://www.picbasic.co.uk/forum/show...8&postcount=99


    Enjoy!
    Attached Files Attached Files
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  16. #16
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Steve,

    I got my parts in for USB (gotta love ebay), and I've built up a breadboard with a 4550 and LED's, switches etc.
    I've looked at the example from post #143, the second one, with DT_INTS, and found two problems. The ...

    INTCON = %10100000 ' Enable global and TMR0 interrupts

    was causing the TMR0 interrupts to start servicing the USB before it was initialized. DT_INTS handles all the interrupt enable bits, so you don't need it anyway.

    The other problem was ...

    goto skipmacro

    was skipping over the interrupt defintion. That section of code needs to execute so that it can handle the enable bits and setup a couple other variables.

    Once I made those changes, the program works as expected, and never looses connection.
    <hr>
    But here's the good part,

    After going through the USB18.ASM file and seeing how things worked, it soon became apparent that those routines are setup to use the USB interrupts(even though PBP doesn't use them that way). It just needs a "kick-start" to get it going. The "kick-start" is simply a tight loop servicing the USB until the driver gets to the "CONFIGURED_STATE". After that it takes off and handles itself.

    But the best part is that it doesn't use ANY PBP system variables to service the USB. So the whole thing can be treated like ASM interrupts, and tied directly into the USB_INT interrupt.

    This also seems to improve the response time since it can react immediately to each step of the USB protocol, instead of after each interval of the timer, or whenever ON INTERRUPT get's around to it, but I don't have any hard data to back that up yet.

    Here's your PIC program from the [USBDemo, something to learn USB a little bit ]thread /.zip file.
    Modified to use DT_INTS-18 and the USB interrupt.
    All the other files are the same.

    http://www.darreltaylor.com/files/USBDemo2_DT.txt

    Works great with the "Mister E USBDemo" program.
    <br>
    DT

  17. #17
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    O.K. the original code was for a 4550. You need to rebuild the project in EasyHid for a 2550. There's a load of needed files.

    I've uploaded the 2455 and 2550 stuff here. let me know what happen now. The 2550 have been tested... but i don't have any handy 2455.

    I've also uploaded the schematic, if some need it.

    NOTE: If your going to use LONG variables, you MUST copy the PIC18Xxxxx.BAL file in your source directory as well, unless you'll receive some compilation errors.

    The .BAL file is located in \PBP\USB18 directory.
    Attached Images Attached Images
    Attached Files Attached Files
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  18. #18
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    This has come up several times, and likewise, I've tried to approach it several times...

    After a 6 month pause from working on it, suddenly all my problems were staring me right in the face, leaving me to wonder ... "What the Hell was I thinking!" Or, maybe Not thinking.

    After fixing the now obvious mistakes ...
    Finally, "A Winner!"

    Here's a viable solution to ...

    "How do I scatter the pins of the LCD data bus across multiple ports with PicBasic Pro?"

    First, let me show you what a sample program might look like...
    Code:
    ;----[ Change these to match your LCD ]--------------------------------------- 
    LCD_DB4    VAR PORTA.0 
    LCD_DB5    VAR PORTB.3 
    LCD_DB6    VAR PORTB.7 
    LCD_DB7    VAR PORTC.1 
    LCD_RS     VAR PORTD.4 
    LCD_E      VAR PORTA.1 
    LCD_Lines  CON 2 ' # of Lines on LCD, 1 or 2 (Note: use 2 for 4 lines) 
    LCD_DATAUS CON 50 ' Data delay time in us 
    LCD_COMMANDUS CON 2000 ' Command delay time in us 
    INCLUDE "LCD_AnyPin.pbp" ; *** Include MUST be AFTER LCD Pin assignments ****
    
    ;----[ Your Main program starts here ]---------------------------------------- 
    LoopCount VAR WORD
    PAUSE 500 : LCDOUT $FE,1 : PAUSE 250 ; Initialize LCD (You may not need this, 
                                         ; but some displays are picky) 
    
    Main: 
        LCDOUT $FE,1 ; clear screen 
        LCDOUT $FE,$87,"Hello,",$FE,$C8,"From DT!"
    
        FOR LoopCount = 0 TO 65535 
            LCDOUT $FE,$80, IDEC LoopCount 
            LCDOUT $FE,$C0, IHEX4 LoopCount 
        NEXT LoopCount
    GOTO Main
    Pretty simple ey?

    Just assign the Pins, Include the file, and away you go, using LCDOUT just like you always have.

    Ok, so now for the other Simple part that can go tragically wrong if you're not careful.
    Yes, ... that's right, ... I'm modifying the Library again.

    Or, more accurately, ... "You" are modifying the Library.
    And before "You" change anything, ...
    "MAKE SURE" you have a backup of the file.
    Don't blame me if it gets messed up and you don't have anything to restore it with.
    And, I will apologize to MeLabs Support ahead of time for the extra support calls this will generate.
    Back it up! and they won't have a problem.


    In your PBP folder (the one with PBPW.EXE in it), open the Library file for the type PIC you are using.

    For 16F's open PBPPIC14.lib with Notepad.
    For 18F's open PBPPIC18.lib

    Search for this string ";* LCDOUT ". That's "semicolon star space LCDOUT space".
    You should see a section that looks like this ...
    Code:
    ;****************************************************************
    ;* LCDOUT     : Send char to LCD                                *
    ;*                                                              *
    ;* Input      : W = char                                        *
    ;* Output     : None                                            *
    ;*                                                              *
    ;* Notes      :                                                 *
    ;****************************************************************
     
        ifdef LCDOUTJ_USED
      LIST
    LCDOUTJ    movf    FSR, W    ; Jumpman entry
      NOLIST
    LCDOUT_USED = 1
        endif
     
        ifdef LCDOUT_USED
    ; NEW Code goes here...
      LIST
    LCDOUT  movwf   R3 + 1          ; Save char
    That one is from PBPPIC14.lib, for PBPPIC18.lib the only difference is it will show FSR0L, instead of FSR.

    Insert this code into the spot marked ; NEW Code goes here...
    It's very important that you get the EXACT line. Be careful ...
    Code:
    ;****************************************************************
    ;*               Added for HighJack                             *
    ;****************************************************************
    HIGHJACK_USED = 1                                              ;*
    LCDOUT_HIGHJACKED = 1                                          ;*
        ifdef HJ_LCDOUT                                            ;*
      LIST                                                         ;*
    LCDOUT                                                         ;*
            L?GOTO  HJ_LCDOUT                                      ;*
      NOLIST                                                       ;*
        else                                                       ;*
    ;****************************************************************
    Now, scroll down past the LCDOUT code, and you should see this ...
    Code:
      NOLIST
    DUNN_USED = 1
    PAUSEUS_USED = 1
        endif
    ; Second piece of NEW Code goes here ...
     
    ;****************************************************************
    ;* LOOK2      : Get data from any register                      *
    ;*                                                              *
    ;* Input      : R0 address / constant                           *
    ;*            : W data type                                     *
    ;* Output     : R0 result                                       *
    ;*                                                              *
    ;* Notes      :                                                 *
    ;****************************************************************
    Insert this code into the spot marked ; Second piece of NEW Code goes here ...
    Code:
    ;****************************************************************
    ;*               Modified for HighJack                          *
    ;****************************************************************
        endif
    If you got it right, you can now use your HD44780 LCD on any pins you wish.
    If you got it wrong, restore the file you backed up (You did back it up, right?). Then try again. It work's. Really! Trust me!

    GoodNote: This modification will NOT interfere with your normal PBP LCDOUT routines.
    In order to invoke the Custom LCD port routines, the main file must have the statement ...

    INCLUDE "LCD_AnyPin.pbp"
    If that statement is NOT included in your program, the LCDOUT commands will work the same way they always have.

    There are 2 files required to implement this approach ...

    LCD_AnyPin.pbp
    VirtualPort.bas -- (Included from the LCD_AnyPin.pbp file)

    Both files are included in the Zip file below. Extract them to your PBP folder.
    Attached Files Attached Files
    DT

  19. #19
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,619


    Did you find this post helpful? Yes | No

    Wink

    MULTICALC


    Hi, Bill

    Here it is

    Enjoy ...

    Alain
    Attached Files Attached Files
    Last edited by Demon; - 23rd December 2014 at 16:28.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  20. #20
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    MIBAM (pronounced "My BAM")
    Which stands for ... "Mirror Imaged Bit Angle Modulation"
    An include module for PicBasic Pro.
    http://www.pbpgroup.com/files/MIBAM/MIBAM.swf

    After a year and a half of playing with this thing ... One statement from RadikalQ3 made all my problems go away.
    Thank you Radikal dude!

    Also many thanks to BCD for beta testing the module.

    I really liked the name "BAM-BAM", but MIBAM is probably a more descriptive acronym, so I've changed it. No matter what you call it ... I think you'll find that My "BAM" ... was the sound of hitting the nail on the head.

    This module is a modification of the BAM (Bit Angle Modulation) idea presented by Artistic License.
    For more information about BAM, it's blinking problem and how this program came to be, please see this thread ...
    http://www.picbasic.co.uk/forum/showthread.php?t=7393

    Click image for larger Interactive version.

    Click image for larger Interactive version.

    What can it do?

    Well ... it can turn almost every pin on your PIC into an LED dimmer. (limitations apply)

    First, let's take a look at the basic MIBAM setup,
    For an RGB LED (3 outputs) it might look like this ....
    Code:
    ;----[ MIBAM Setup ]--------------------------------------------------------
    BAM_COUNT CON 3                     ; How many BAM Pins are used?
    INCLUDE "MIBAM.pbp"                 ; Mirror Image BAM module
    
    
    RED    VAR BYTE
    GREEN  VAR BYTE
    BLUE   VAR BYTE
    
    
    ASM
    BAM_LIST  macro                     ; Define PIN's to use for BAM
         BAM_PIN (PORTB,0, RED)         ;   and the associated Duty variables
         BAM_PIN (PORTB,1, GREEN)
         BAM_PIN (PORTB,2, BLUE)
      endm
      BAM_INIT  BAM_LIST                ; Initialize the Pins
    ENDASM
    ;_________________________________________________  __________________________
    At this point, each BAM_PIN has been automatically set to OUTPUT, and the PINs will idle LOW until the Dutycycle variables are changed.

    The Dutycycle range is from 0-255, 0 = OFF, 255 = brightest.
    To change the brightness of an LED simply set the Dutycycle variable to the desired level.
    You don't need to call any subroutines.

    Here's an example of just fading the RGB LED's up and down.
    Code:
    Speed       CON 20   ; Smaller=Faster
    Brightness  CON 200  ; Max DutyCycle
      
    Main:
        FOR Red = 0 to Brightness -1          ; Ramp up 1 by 1
            PAUSE Speed
        NEXT RED
        FOR GREEN = 0 to Brightness -1
            PAUSE Speed
        NEXT GREEN
        FOR BLUE = 0 to Brightness -1
            PAUSE Speed
        NEXT BLUE
    
    
        FOR Red = Brightness to 1 STEP -1     ; Ramp down 1 by 1
            PAUSE Speed
        NEXT RED
        FOR GREEN = Brightness to 1 STEP -1
            PAUSE Speed
        NEXT GREEN
        FOR BLUE = Brightness to 1 STEP -1
            PAUSE Speed
        NEXT BLUE
    GOTO Main
    FOR loops always leave the variable 1 count further than the loop specifies.
    when using direct FOR loops, you must account for the difference.

    The module will work on most 16F's, ALL 18F's and some 12F's
    If you are using a 14-bit PIC. You'll need to add these variables to your program for the Interrupt Context.
    For 18F's you don't need to add these save locations. And they may cause errors if you do.
    Code:
    ;____[ For 12F/16F only - Interrupt Context save locations]_________________
    wsave       var byte    $20     SYSTEM  ' location for W if in bank0
    ;wsave       var byte    $70     SYSTEM  ' Alternate save location for W 
                                            ' if using $70, comment out wsave1-3
    ' --- IF any of these next three lines cause an error ?? -------------------
    '       Comment them out to fix the problem ----
    ' -- The chip being used determines which variables are needed -------------
    wsave1      VAR BYTE    $A0     SYSTEM      ' location for W if in bank1
    wsave2      VAR BYTE    $120    SYSTEM      ' location for W if in bank2
    wsave3      VAR BYTE    $1A0    SYSTEM      ' location for W if in bank3
    '---DO NOT change these-----------------------------------------------------
    ssave       VAR BYTE    BANK0   SYSTEM      ' location for STATUS register
    psave       VAR BYTE    BANK0   SYSTEM      ' location for PCLATH register
    Limitations and Requirements
    • In order to use this module, you MUST be using MPASM for the assembler.
      PBP's default PM.exe assembler will not work.
      &nbsp;
    • This module takes over the Interrupts on the PIC because the timing of the waveforms must be exact.
      With 16F's, You can NOT use any other interrupts, this includes ON INTERRUPT.
      With 18F's, The module uses High Priority interrupts, and no other High Priority interrupts can be used.
      Low priority Interrupts are available, but you still can NOT use ON INTERRUPT.
      &nbsp;
    • The module uses Timer1, and it cannot be used for any other purposes.
      Consequently, the PIC being used must have a Timer1.
      &nbsp;
    • The number of LED's you can use is limited by the OSC frequency.
      It's not that the module uses so much processor time that it needs more speed.
      The limitation is the LSB (Least Significant Bit) of the DutyCycle, which is so short that it doesn't leave much time to do a whole lot of code.

      @ 4Mhz, you can only run 4 LEDs MAX. This can be useful for RGB LED's on small chips.
      @ 20Mhz, you can run 20 LEDs since there are more instructions available per period.
      @ 48Mhz, you can run 48 LEDs, and anywhere in-between you can have the equivelant number of LEDs to match the OSC frequency.
      If you attempt to use too many LEDs for a specific OSC frequency, the program will give a warning to indicate the results will be "Blinky".
      &nbsp;
    • DO NOT overload your PIC.
      A PIC can only source so much current. The specific amount is listed in the datasheet for the PIC you are using.
      If you are driving a lot of LED's, you may need to buffer them with transistors or various other drive mechanisms.
    Attached is the MIBAM.pbp module.
    Download and unzip it to your PBP folder. (The one with PBPW.exe, usually C:\PBP)
    Attached Files Attached Files
    DT

  21. #21
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default MIBAM - More Info

    Option DEFINEs and Constants
    • BAM_COUNT CON xx
      This constant must match the number of BAM_PINS being used.
      If they do not match, an error will be displayed.
      &nbsp;
    • DEFINE BAM_FREQ xxx
      By default, the module determines what the maximum refresh rate is for any given setup, and uses that rate. Depending on the conditions, it may be 700hz or more.
      If desired, you can set the frequency lower with this define.
      &nbsp;
    • DEFINE BAM_INFO 1
      When using this define, MIBAM will display some information about the Refresh Rate (Frequency), Minimum Period, and number of pins used.
      &nbsp;
    • ScopeSync VAR PORTx.x
      If this alias is used, MIBAM will output a sync signal on the specified pin for use with an oscilloscope.
      This gives a nice stable view of the waveform.
      The Pin is automatically set to output.

    <hr>Error/Warning messages
    • Error: Symbol not previously defined (wsave)
      When using a 12F or 16F, you need to add the wsave block shown above to your program.
      This is not necessary for 18F's, so the vars have been omitted from the module.
      &nbsp;
    • ERROR: Variable wsaveX position request beyond RAM_END xx
      If the chip you are using doesn't have GP RAM in all 4 banks, then you have to comment out the wsave variables for any of the banks that don't have any. The ERROR message(s) tell you which ones need to be commented.
      If the chip has ACCESS RAM at address $70, then it's best to use that location, instead of wsave1-3.
      &nbsp;
    • Error: BAM_COUNT (x) is less than # of Pins used (x)
      The BAM_COUNT constant MUST match the number of BAM_PINs being used.
      Increase BAM_COUNT to fix the Error.
      &nbsp;
    • Error: Duplicate label ("BAM_PIN" or redefining symbol that cannot be redefined)
      The module requires case sensitivity in MPASM. But sensitivity has been turned off in MCS.
      In MicroCode Sudio, View | Compile and Program Options | Compiler Tab ...
      Check the "Case sensitive" box.
      &nbsp;
    • WARNING: Too many BAM pins for xx Mhz - Results will be BLINKY!
      The module can only run 1 LED per Mhz of the CPU's main Oscillator.
      Reducing the number of LED's or increasing the OSC frequency should eliminate the warning.
      &nbsp;
    • WARNING: BAM frequency (xxHz) is Less than Requested (xxHz)
      The module determines what the maximum refresh rate is for any given setup.
      If a BAM_FREQ has been defined that is higher than the maximum frequency, the module will warn you of the situation. This warning is not critical, and may still work in your application.
      Commenting the DEFINE BAM_FREQ line will squelch the warning.
      &nbsp;
    • MESSAGE: 'BAM_INFO' - MinPeriod= xx inst, Cycle= xxxx inst, Pins= xx, FREQ= xxx Hz
      This is an informational message that will be shown if you have set DEFINE BAM_INFO 1 or get a "BAM frequency WARNING".
    DT

  22. #22
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Cylon Scanner

    Here's another quick example that simulates a Cylon or Kitt car scanner.

    It's running on a 16F887 with 8Mhz internal OSC. The PCB is the Microchip 44-pin Demo Board that comes with the PICkit2 Debug Express package.

    It's not too bad with 8 LEDs, but 16 would be better. The sequence will automatically use however many LEDs you define.

    By adjusting the constants, you can make it look like most of the different seasons of the shows. (Excluding the New "Knight Rider" 2009). 2009 can be done too, but it'll take a little modification.



    http://www.pbpgroup.com/files/MIBAM/Cylon.MOV

    The main difference is in the way the Duytcycle variables are declared.
    By grouping them in an Array, they can be used with FOR loops to control all the LEDs, instead of having to access each one individually like the RGB's.


    Code:
    ;----[ MIBAM Setup ]--------------------------------------------------------
    BAM_COUNT CON 8                     ; How many BAM Pins are used?
    INCLUDE &quot;MIBAM.pbp&quot;                 ; Mirror Image BAM module
    
    
    BAM_DUTY  VAR BYTE[BAM_COUNT]
      LED1    VAR BAM_DUTY[0]           ; group them in an array for easy access
      LED2    VAR BAM_DUTY[1]           ; with FOR loops etc.
      LED3    VAR BAM_DUTY[2] 
      LED4    VAR BAM_DUTY[3] 
      LED5    VAR BAM_DUTY[4] 
      LED6    VAR BAM_DUTY[5] 
      LED7    VAR BAM_DUTY[6] 
      LED8    VAR BAM_DUTY[7] 
    
    
    ASM
    BAM_LIST  macro                     ; Define PIN's to use for BAM
         BAM_PIN (PORTD,0, LED1)        ;   and the associated Duty variables
         BAM_PIN (PORTD,1, LED2)
         BAM_PIN (PORTD,2, LED3)
         BAM_PIN (PORTD,3, LED4)
         BAM_PIN (PORTD,4, LED5)
         BAM_PIN (PORTD,5, LED6)
         BAM_PIN (PORTD,6, LED7)
         BAM_PIN (PORTD,7, LED8)
      endm
      BAM_INIT  BAM_LIST                ; Initialize the Pins
    ENDASM
    Then with all the dutycycles in the array, you can do something like this.

    Code:
    
    Speed       CON 6         ; Smaller=Faster
    TracerSpeed CON 15        ; Smaller=Faster Left/Right
    Brightness  CON 200       ; Tracers DutyCycle
    DrainSpeed  CON 30        ; Smaller=Shorter Trail
    
    
    Idx         VAR BYTE
    LoopCount   VAR BYTE
    NextLED     VAR BYTE
    TraceDIR    VAR BIT
    
    
      TraceDIR  = 0
      LoopCount = 0
      NextLED   = 0
        
    Main:
        if LoopCount = TracerSpeed then             ; __[ Cylon/Kitt Scanner ]__
          LoopCount = 0
          BAM_DUTY(NextLED)=Brightness
          if TraceDIR then                          ; if scanning left
            NextLED = NextLED - 1
            if NextLED = 0 then TraceDIR = 0
          else                                      ; else scanning right
            NextLED = NextLED + 1
            if NextLED = BAM_COUNT-1 then TraceDIR = 1
          endif
        endif
        
        FOR Idx = 0 to BAM_COUNT - 1                ; Drain all dutycycles
           IF BAM_DUTY(Idx) > 0 then
               BAM_DUTY(Idx)=BAM_DUTY(Idx)*DrainSpeed/(DrainSpeed+1)
           ENDIF
        NEXT Idx
        pause Speed
        LoopCount = LoopCount + 1
    GOTO Main
    Attached is the full code and HEX file for the 887 on the Demo Board.
    Attached Files Attached Files
    DT

  23. #23
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    ALLDIGITAL.pbp

    If you want to use all the pins on your PIC as general Input/Output, you must first enable the DIGITAL inputs that are multiplexed with the ADC and Comparator pins.

    MICROCHIP in their infinite(simal) wisdom has DISABLED the DIGITAL inputs on Power-Up. Leaving everyone to figure out which of the 10 different ways they need to use to turn them on for the chip they're programming at any given time.
    Sometimes it's ADCON1 and CMCON, other times it's ANSEL and CMCON0, and still others it might take ANSELA ANSELB ANSELC and ANSELD.

    This file is an attempt to rectify that situation.
    I've tested it on all the common chips we use with PBP, and it workes extremely well.
    <hr>

    Simply INCLUDE the file, and all PINs will have any DIGITAL inputs enabled. Whether it's from the A/D converter or the Comparator(s).
    A single line will remove that big thorn from your ...

    Code:
    INCLUDE "ALLDIGITAL.pbp"
    If you are using MPASM for the assembler, add the following line to your program and the registers that need to be set for the CPU you are compiling for will be shown in the "Results" window of MCS.
    Code:
    DEFINE  SHOWDIGITAL 1
    For example, with a 16F877A it would show ...
    Code:
     ... MESSAGE:(ADCON1 = 7)
     ... MESSAGE:(CMCON = 7)
    At that point, you can just add those lines to your program and delete the INCLUDE line.
    If it shows a 0x7F type number, change it to $7F.

    Or for better compatibility, you can leave the INCLUDE in your program, and it will work with whatever chip you are compiling for.

    Here's a simple example for blinking an LED on PORTA.0, without worrying about the analog registers.
    Code:
    INCLUDE "ALLDIGITAL.pbp"
    
    Main:
        TOGGLE PORTA.0
        PAUSE 500
    GOTO Main
    <hr>
    Current Version = 1.4 (7/19/2010)
    Version History:<table border=1 cellspacing=1 cellpadding=3><tr><td>Version</td><td>Reason</td><td align=center>Credit</td></tr><tr><td align=center>1.0</td><td>Initial release</td><td align=center>Darrel Taylor</td></tr><tr><td align=center>1.1</td><td>Added Shared address SFR support for 18F87J50 family</td><td align=center>mister_e/scalerobotics</td></tr><tr><td align=center>1.2</td><td>Removed MPASM specific opcode (variable), for PM.exe</td><td align=center>Tobias</td></tr><tr><td align=center>1.3</td><td>Added ANSELA,B,D and E for the 16F72x series</td><td align=center>Darrel Taylor</td></tr><tr><td align=center>1.4</td><td align=center>Added ANSEL0 and ANSEL1 for the 18F4431 series</td><td align=center>Darrel Taylor</td></tr><tr><td align=center>1.5</td><td align=center>unknown</td><td align=center>This could be you!</td></tr></table>
    The attached .zip has only one file, ALLDIGITAL.pbp extract it to your PBP folder (the one with PBPW.exe).
    <br>
    Attached Files Attached Files
    DT

  24. #24
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    USBDemo was a good starting point for me, Thanks Steve.
    But there are several problems that don't coincide with what you want.

    1) When you disconnect the cable, it will still try to send data, causing the PIC to enter a Locked Loop, waiting to send to an inactive bus.

    2) You really have no indication that anything was received.
    If there's no incoming data, it just goes ahead and sets the dutycycles again, using the old data left over in the buffer.

    3) There's no indication of when it's connected, when something was received or when it's ok to send.

    4) With the 1mS servicing from Timer0, it's a bit sluggish when enumerating, overall data rates suffer and it uses TMR0 when it doesn't need to.

    5) EasyHID no longer works with 2.60, so it's difficult to make changes to the descriptors.

    6) I don't use Visual Basic, so I can't update the PC program.
    My main language is Delphi, and I stopped using mchid.dll a long time ago.

    I would have worked with Steve to build a better demo, but alas, he's not here.
    <hr>
    I'm thinking it's time to unveil DT_HID.
    It's the PIC side of USB, made ... yes, I'll say it ... EASY!

    The PC side is still up to you, but it even works with Steve's original VB prog, so that, or any other VB/Delphi program from EasyHID can be used as a "template".

    I'm not even going to tell you how it works.
    I defy you to not understand what it does.
    Up until you ask a question.

    Warning, the example is setup for 13K50/14K50.
    Comment the configs, and uncomment the other configs (if needed).
    Change ANSELs to ADCON1 (if needed).

    Also note: This is for PBP 2.60 only.
    BasicUSB.pbp is the test program.

    Don't shoot me, I can't even play a piano ...
    Attached Files Attached Files
    DT

  25. #25
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Apparently, I missed the CONFIG2L.
    I always miss that one, weird ...
    Code:
       __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
    And try the HIDmonitor program from the .zip

    When I said it works with Steve's original program, well it will, but it's not set up to send/receive the same analog values and switches/LED's. With HIDmonitor you should see when it connects and what data it's sending.

    hth,
    DT

  26. #26
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    OK, this program should work with Steve's original USBDemo GUI.

    18F2550/4550, 8Mhz, DT_INTS-18, DT_HID260.

    Cheers,
    Attached Files Attached Files
    DT

  27. #27
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Nothing wrong there.

    There are two different actions that can change the way INT_ENABLE works with version 1.10.

    DEFINE INT_ENABLECLEARFIRST 1 ; (default)
    With the above define, which is also the default, whenever you INT_ENABLE, the flag is automatically cleared before the interrupt is enabled.

    DEFINE INT_ENABLECLEARFIRST 0
    Whith this define, the flag is NOT cleared.
    This can dramatically change the results and cause immediate interrupts if the flag is already set.

    If INT_ENABLECLEARFIRST is 0, then INT_ENABLE takes one instruction cycle.
    If INT_ENABLECLEARFIRST is 1, then INT_ENABLE takes two instruction cycles.

    INT_DISABLE always takes one instruction.
    DT

  28. #28
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,983


    Did you find this post helpful? Yes | No

    Default Re: New PIC Utility. PICMultiCalc

    MULTICALC


    I had to download & install Microsoft ActiveX control Pad to get LCD tool working.

    I had to download & register MSSTDFMT.DLL to get Timer tool working.

    All tools worked after that.

    Nice utility, I had the old SPBRG version.
    Last edited by Demon; - 23rd December 2014 at 16:28.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  29. #29
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,983


    Did you find this post helpful? Yes | No

    Default Re: New PIC Utility. PICMultiCalc

    MULTICALC


    If you get this in Win 7 64bit:

    ActiveX Control Pad Setup:
    the app was unable to start correctly (0xc0000142)


    Run in XP compatibility mode.



    To register MSSTDFMT.DLL in Win 7 64bit:

    - download the file from microsoft.
    - copy to C:\Windows\SysWOW64 folder
    - RUN REGSVR32 C:\Windows\SysWOW64\MSSTDFMT.DLL


    Robert
    Last edited by Demon; - 23rd December 2014 at 16:28.

  30. #30
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer Demo

    It keeps running in the background.
    The interrupts will not wait for PBP statements to finish.

    Ok fine, ... for many years I've resisted making a count down elapsed timer for humanitarian reasons.
    But if you guys are going to do it anyhow, I might as well make a new version of the Elapsed Timer.
    I can only hope that if somebody uses it for nefarious purposes, they end up blowing themselves up.

    Here's the test circuit.



    Here's the test program ...
    Code:
    ' Define LCD connections
    DEFINE LCD_DREG PORTC   ' Set LCD Data port
    DEFINE LCD_DBIT 4       ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTC  ' Set LCD Register Select port
    DEFINE LCD_RSBIT 2      ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTC   ' Set LCD Enable port
    DEFINE LCD_EBIT 3       ' Set LCD Enable bit
    DEFINE LCD_BITS 4       ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2      ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2000 'Command delay time in us
    DEFINE LCD_DATAUS 50 'Data delay time in us
    
    DEFINE  OSC 4
    
    INCLUDE "Elapsed_DN.bas"  ; Elapsed Timer Routines
    
    ZERO_LED   VAR PORTB.3
    
    ANSEL = 0                 ' All Digital
    ANSELH = 0
    LOW ZERO_LED              ' start with LED OFF
    OPTION_REG.7 = 0          ' enable PORTB pull-ups
    PAUSE 250                 
    LCDOUT $FE,1              ' Initialize LCD
    PAUSE  250
    
    Days = 1                  ' set initial time
    Hours = 1
    Minutes = 3
    Seconds = 10
    
    GOSUB StartTimer          ' Start the Elapsed Timer
    
    Main:
    CountDown = !PORTB.0
      IF SecondsChanged = 1 THEN  
         SecondsChanged = 0
         LCDOUT $FE,2, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds
      ENDIF
      IF ZERO_LED != ZERO THEN ZERO_LED = ZERO
    GOTO Main
    If the button on PORTB.0 is pressed it counts down.
    If it is not pressed, it counts up.
    The LED comes on when it reaches 0.

    If you are using the countdown for a movie set, it has to stop at 1 second.
    Put this in the main loop.
    Code:
      IF (CountDown=1) AND (Days=0) AND (Hours=0) AND (Minutes=0) and (Seconds=1) _
          THEN GOSUB StopTimer
    You'll need the ASM_INTS include from the original Elapsed Demo.
    Attached Files Attached Files
    DT

  31. #31
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,983


    Did you find this post helpful? Yes | No

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    NOTE: Posts will be copied into this thread, so some will appear ABOVE this post. That is normal, they are dated sooner.


    After busting my nose for 3 days against Elapsed Timer at 64MHz on a 18F44K22 and finding out today Darrel released a K22 version, I thought it was high time to centralize all these modules along with corresponding information.

    This thread is not limitted to DT's works, it's also there for Mr E's Multicalc and any other utility that we may be losing over time. Once accumulated, I'll post them up in a sticky in the PBP Extension/Add-On subforum.

    If you see a utility that is not mentionned in this thread, please post a link to that utility. I will copy Darrel's entire post in this thread.

    Robert
    Last edited by Demon; - 23rd December 2014 at 16:29.

  32. #32
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,983


    Did you find this post helpful? Yes | No

    Default Re: Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc

    Since Darrel's site is down and the archives might have older versions, this is what I have so far.

    DT_INTS-14_V110.zip
    v1.1 Aug 13, 2010 DT_INTS-14.bas
    v3.4 Aug 13, 2010 ReEnterPBP.bas

    DT_INTS-18.ZIP
    v3.3 Mar 24, 2008 DT_INTS-18.bas
    v1.4 Mar 24, 2008 ReEnterPBP-18.bas
    v1.4 Mar 24, 2008 ReEnterPBP-18LP.bas

    Elapsed-18.ZIP
    v1.0 Jul 11, 2006 Elapsed_INT-18.bas

    picmulticalc_v_1_3_1.zip
    v1.3.1 2006 PicMultiCalc.exe

    ALLDIGITAL.zip
    v1.4 Jul 19, 2010 ALLDIGITAL.pbp

    SPBRGCalcV2.zip
    v2 V2SPBRGCalc.exe

    DT_CodeSize.zip
    v2 Jan 20,2009 DT_CodeSize.pbp

    DT Analog Oversampling.zip
    v1 May 23,2009 DT_Analog.pbp

    HPWM10.zip
    v1.1 May 5, 2007 HPWM10.pbp

    SPWM.zip
    v1 SPWM_INT.bas


    Reached limit of 10 attachments per post.
    List continued here: http://www.picbasic.co.uk/forum/show...315#post130315


    If you have newer versions, please post them.


    Archives:
    http://web.archive.org/web/201206172...S-18/home.html

    Robert
    Last edited by Demon; - 24th December 2014 at 16:43.

  33. #33
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc

    Great idea!
    Just found this on my PC:
    DT_HID260.zip
    DT Analog Oversampling.zip
    codesize.zip

  34. #34
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,983


    Did you find this post helpful? Yes | No

    Default Re: Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc

    Thanks Pedja,

    I didn't have DT CodeSize and DT Analog Oversampling, added them to my list.

    Robert

  35. #35
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc

    didnt he do a software PWM code as well ???

  36. #36
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,983


    Did you find this post helpful? Yes | No

    Default Re: Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc

    Yup, like I said in chatbox, I'm looking for DT_SPWM and DT_Elapsed_K22.

    Robert

  37. #37
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc

    there is no elapsed k22 version just the int-18_k22 processor support , see other post in your elapsed thread

  38. #38
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc

    Here is my version of Darrels 10bit HPWM_L. Original version works with PBPW. There is comments in code, what is changed. Later Darrel publise his version on me labs forum.
    Example:
    Code:
    include "HPWM_L.pbp"
    DutyCycle1  VAR WORD
    DutyCycle2  VAR WORD
    Frequency  VAR WORD
    @ HPWM10  1, _DutyCycle1, _Frequency
    @ HPWM10  1, _DutyCycle2, _Frequency
    Frequency must be same for all channels.
    HPWM10_L.zip
    EDIT:
    Here is archive with original code and example:HPWM10.zip
    I can't find S_PWM
    Last edited by pedja089; - 23rd December 2014 at 23:16.

  39. #39
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,983


    Did you find this post helpful? Yes | No

    Default Re: Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc

    USBDemo.zip
    v1 Dec 30,2006 USBDemo.pbp (PBP & VB)

    USBDemo_2455.zip
    v1 May 8, 2007 USBDemo_2455.pbp (PBP)

    USBDemo_2550.zip
    v1 May 8, 2007 USBDemo_2550.pbp (PBP)

    USBDemo_2455_2550.pdf

    DT_HID260.zip
    v2.0 Jul 23,2009 DT_HID260.pbp (PBP & VB)

    DT_HID_Test.zip
    v2.1.1.29 2007 HIDmonitor.exe (PBP)

    Robert
    Last edited by Demon; - 24th December 2014 at 17:02.

  40. #40
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,993


    Did you find this post helpful? Yes | No

    Default Re: Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc

    Great work Robert! Many thanks.

    Ioannis

Similar Threads

  1. Darrel Taylor Interrupts and MultiCalc
    By AvionicsMaster1 in forum General
    Replies: 6
    Last Post: - 14th February 2012, 07:18
  2. Question on Mister E's PIC MultiCalc.
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th December 2011, 14:37
  3. Darrel Taylor's SPWM code usage
    By Homerclese in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th July 2010, 15:13
  4. using darrel taylor's instant interrupts
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st July 2007, 05:07
  5. Replies: 18
    Last Post: - 23rd May 2006, 06:57

Members who have read this thread : 11

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