+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 41 to 54 of 54
  1. #41
    Join Date
    Sep 2009
    Posts
    652

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

    SPWM_INT with example:
    SPWM.zip

  2. #42
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,249

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

    Great, got Mister E's 2 USB routines, just have to put comments in those and Darrel's.

    Then fix up the interrupt for K22 series and that'll be most of it.

    Robert


    Edit: still need LCD ANYPIN though.
    Last edited by Demon; - 24th December 2014 at 14:22.

  3. #43
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,249

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

    Temporary post, just storing attachments lifted from old computer.
    (Attachments get deleted after a while if they are not linked to a post.)

    USBDemoDT_Steve_RH.zip
    DT_HID_Test.zip
    USBscope_Scalerobotics.zip
    USBDemo_Steve.zip
    USBscope_Scalerobotics_with_README.zip
    USBdemo_DT_Steve.zip

    Will sort through these later. I'm just lifting everything and anything I can find on my PCs.

    Robert
    Last edited by Demon; - 24th December 2014 at 17:03.
    Not as dumb as yesterday, but stupider than tomorrow!

  4. #44
    Join Date
    Sep 2009
    Posts
    652

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

    Here is Run-Time Config :
    Original thread:
    http://www.picbasic.co.uk/forum/showthread.php?t=4093

    Quote Originally Posted by Darrel Taylor View Post
    How many times have you been told that CONFIG settings can only be changed by an ICSP programmer while downloading the program's code? And how many times did you believe them? Well, for me, it was every time, until I ran across a BIT that I didn't recognize in the datasheets.

    CFGS: Flash Program/Data EEPROM or Configuration Select bit
    1 = Access Configuration registers
    0 = Access Flash program or data EEPROM memory

    Once I saw that, I knew it could be done, it was just a matter of figuring out how. The datasheet was really vague, and it simply said that it was similar to writing to Flash Memory. After a little trial and error, I found that it really is just that easy. So maybe, you want to add a routine to verify that the chip has been programmed with the proper config settings for the program. Or maybe you need to change the settings according to the users input from a menu. Now you can.

    This option is available on every 18F that I've looked at so far, so that means it's been around for years. And, no, it's not available on any 16F's that I've seen.<HR>
    This program presents the following macros:
    @ ReadConfig?CB _CONFIG3H, tempbyte
    Read the contents of a CONFIG register and place the results in a PBP byte variable. The constant for the CONFIG location can be either, one of the pre-defined names from the MPASM .inc file such as _CONFIG1H or _CONFIG3H, or the address of the location like 300001h
    @ ReadConfig?BB AddrByte, tempbyte
    Read the contents of a CONFIG register using a byte offset from the start of the CONFIG address space. For instance, to read register 300001h, the AddrByte variable will have the value 1. The result will be placed in a PBP byte variable.
    @ WriteConfig?CB _CONFIG1L, tempbyte
    Write a byte to the CONFIG register designated by a constant
    @ WriteConfig?BB AddrByte, tempbyte
    Write a byte to the CONFIG register using an offset to the CONFIG adress space
    @ WriteConfig?CC _CONFIG5L, 0Fh
    Write a byte sized constant to the CONFIG register designated by a constant
    Obviously there are some issues to think about before using these macro's. Such as, an oscillator must be running to be able to execute code. So trying to set the oscillator config at run-time will only work if you start off with a configuration that allows a system clock. Other changes in mid stream might put the CCP output on a pin that has a low impeadance signal on the input, causing damage. It's up to you to make sure these things don't happen. Which I guess is no different than if you're using ICSP.

    http://www.darreltaylor.com/RTconfig/RTconfig.inc.txt
    http://www.darreltaylor.com/RTconfig/TestConfig.pbp.txt
    New Files:Run-Time Config .zip

  5. #45
    Join Date
    May 2004
    Location
    Denmark
    Posts
    9

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

    ALLDIGITAL version 1.5

    ALLDIGITAL_V1_5.zip

    Kent

  6. #46
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,816

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

    DT_Analog
    From Darrel's website . . . all his words, not mine.

    You've probably noticed that when using the Analog to Digital converter, the numbers are NEVER stable. At best, the result will always be bouncing back and forth between two numbers.

    While it's extremely annoying, there is a reason for it, and the number of times it bounces between those two numbers is actually indicating the values of more bits of resolution that are not included in the original 10-bit result.
    This effect can be exploited to increase the effective number of bits in the result.

    By taking a number of consecutive samples and averaging the results with a lower divisor, you can get up to 16-bit accuracy from that poor little 10-bit converter.

    An explanation of the Oversampling technique can be found on Wikipedia.
    http://en.wikipedia.org/wiki/Oversampling

    A/D Bits Samples Required MAX result Conv. Time (1)
    10 1 1023 24.2us
    11 4 2046 96.8us
    12 16 4092 387us
    13 64 8184 1.54ms
    14 256 16368 6.2ms
    15 1024 32736 24.7ms
    16 4096 65472 99.1ms
    (1) Conversion Time based on 5 us acquisition with 1.6 us Tad
    Samples required:
    For each additional bit of resolution, the number of samples required is multiplied times 4 (22(n-10)). The samples are accumulated in a 32-bit variable, then divided by a number that is doubled for each additional bit (2(n-10)). [This is all handled by the module.]

    Maximum results:
    Since the highest value provided by the converter is 1023, it can't bounce between 1023-1024.
    This limits the maximum values to slightly lower than expected, which is (1023 << (bits-10))
    For 16-bits, the maximum is (1023 << 6) or 65472. This value is returned in the ADmax variable after the conversion for easy voltage calculations.

    Practicality:
    Taking 1/10th of a second to convert a 16-bit value seems like a colossal waste of time. But it's nice to know you can do it if you really need to.

    To me, the real winner is 12-bit, at under 400us conversion time, with a 4 fold increase in resolution, on almost any PIC, ... I doubt I'll be using 10-bit much anymore. But even 14-bit's not too bad @6ms, although the extra time for 14-bit probably isn't worth it for most analog projects.

    Conversion time:
    The time it takes to complete a conversion depends on a couple of factors.


    1. The Acquisition time specified in the DEFINE ADC_SAMPLEUS statement. If there is no DEFINE, PBP will default to 50us, which is for the absolute worst case scenario with high impedance. It's very likely that you will be able to use a much smaller value. With an impedance of 1K or less, you can usually get away with 3-5us. Also, the minimum ADC_SAMPLEUS is limited to the minimum PAUSEUS delay, which at 4Mhz OSC is 24us, @20Mhz it's 3us. Use as low a value as you can possibly get away with because this time happens for every sample. With 256 or more samples being taken, it adds up pretty quick.
    2. The ADC clock source should be set as close as possible to 1.6us Tad. And it takes 12 Tad to complete a 10-bit conversion. This one's hard to explain, so I'll just list the recommended values. Use the highlighted values in your DEFINE ADC_CLOCK statement, based on your oscillator frequency.

    OSC DEFINE ADC_CLOCK Clk source Tad(us) 12 Tad(us)
    4 1 Fosc/8 2 24
    8 5 Fosc/16 2 24
    10 5 Fosc/16 1.6 19.2
    12 2 Fosc/32 2.6 31.2
    16 2 Fosc/32 2 24
    20 2 Fosc/32 1.6 19.2
    24 6 Fosc/64 2.6 31.2
    32 6 Fosc/64 2 24
    40 6 Fosc/64 1.6 19..2
    48 3 FRC 4 48us

    Noise in the system:
    As previously mentioned, it's the number of times the value bounces back and forth between two numbers that allows it to gain more bits of resolution.
    If (due to poor design) your A/D values are swinging wildly even at normal 10-bit, this system will also help calm them down (some) since it will find an average of the samples taken. Usually it's the mid-point of those swings that you want to find anyway. Naturally, you should minimize ALL noise as much as possible to begin with.

    Using the Module:
    You must first configure your PIC to have the desired Analog inputs and use the correct Oscillator source. This module will not do it for you.
    You must also set the ADC DEFINE's for the fastest available 10-bit results, depending on your oscillator frequency.
    Then INCLUDE the file somewhere near the top of your program.

    Set the ADchan variable to the AN channel you wish to read. (ADchan = 1)
    Set the ADbits variable to the desired resolution. (ADbits = 12)
    Then GOSUB GetADC.

    The resulting value will be returned in the ADvalue word sized variable.
    And the maximum A/D value for the selected resolution is returned in the ADmax variable.


    Code:
    'http://www.darreltaylor.com/DT_Analog/
    '****************************************************************
    '*  Name    : DT_Analog.pbp                                     *
    '*  Author  : Darrel Taylor                                     *
    '*  Notice  : Copyright (c) 2009                                *
    '*  Date    : 5/23/2009                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : Up to 16 bit A/D with a 10-bit A/D converter      *
    '*          : http://en.wikipedia.org/wiki/Oversampling         *
    '****************************************************************
    GOTO OverDTAnalog
    
    ADchan       VAR BYTE        ; global - A/D channel to use
    ADbits       VAR BYTE        ; global - # of bits in result
    ADvalue      VAR WORD        ; global - the final A/D value
    ADmax        VAR WORD        ; global - Max A/D value at this resolution
    ;--------------------
    DTadCount    VAR WORD        ; local - sample count
    DTadDivisor  VAR WORD        ; local - averaging divisor
    DTadShiftR   VAR BYTE        ; local - bits to shift for UnderSampling
    DTadAccum    VAR WORD[2]     ; local - 32-bit sample accumulator
    
    ;---------------------------------------------------------------------------
    GetADC:
      IF (ADbits >= 10) THEN
        DTadShiftR = 0   ; 10 11 12 13  14   15   16
        LOOKUP2 ADbits-10,[ 1, 4,16,64,256,1024,4096],DTadCount
        LOOKUP  ADbits-10,[ 1, 2, 4, 8, 16,  32,  64],DTadDivisor
      ELSE
        DTadCount = 1
        DTadDivisor = 1
        DTadShiftR = 10 - ADbits
      ENDIF  
      LOOKUP2 ADbits,[0,1,3,7,15,31,63,127,255,511,1023, _
                      2046,4092,8184,16368,32736,65472],ADmax
      
      DTadAccum = 0 : DTadAccum[1] = 0     ; clear the accumulator
    DTadLoop:
      ADCIN  ADchan, ADvalue               ; get 10-bit sample
      DTadAccum = DTadAccum + ADvalue      ; add it to the accumulator
      IF DTadAccum < ADvalue THEN          ; if low word overflowed
         DTadAccum[1] = DTadAccum[1] + 1   ;   increment the high word
      ENDIF
      DTadCount = DTadCount - 1            ; done with this sample
      IF DTadCount > 0 THEN DTadLoop       ; loop if not done with ALL samples
      
      R2 = DTadAccum                       ; put 32-bit accumulated value in PBP
      R0 = DTadAccum[1]                    ;   registers, prepare for DIV32
      ADvalue = DIV32 DTadDivisor          ; get the average value
      ADvalue = ADvalue >> DTadShiftR      ; Shift right if < 10-bit
    RETURN
    OverDTAnalog:
    ************************************************** ***************************
    ************************************************** ***************************
    Code:
    Here's a simple example that displays 12-bit A/D values on an LCD.        
    Of course, by changing one number it will display 16-bit values too. 	
    
    Download 12-bit example Download example code.
    (Save it to a new folder.  Not the PBP folder)
    	View 12-bit DEMO in browser View 
     
    
    ;--- Set your __configs here as needed ---
    DEFINE OSC 20
    INCLUDE "DT_Analog.pbp"     ; DT's 16-bit Analog Module
    
    DEFINE ADC_BITS 10          ; Set-up ADC for fast 10-bit results
    DEFINE ADC_CLOCK 2
    DEFINE ADC_SAMPLEUS 5
    
    ;----[Change these to match your hardware]----------------------------------
    DEFINE LCD_DREG    PORTB    ; LCD Data Port
    DEFINE LCD_DBIT    0        ; Starting Data Bit
    DEFINE LCD_RSREG   PORTB    ; Register Select Port
    DEFINE LCD_RSBIT   4        ; Register Select Bit
    DEFINE LCD_EREG    PORTB    ; Enable Port
    DEFINE LCD_EBIT    5        ; Enable Bit
    DEFINE LCD_BITS    4        ; Data Bus Size
    DEFINE LCD_LINES   2        ; Number of Lines on LCD
    DEFINE LCD_COMMANDUS  2000  ; Command Delay time in uS 
    DEFINE LCD_DATAUS  50       ; Data Delay time in uS
    
    ADCON1 = %10001101          ; right justify, AN0 & AN1 analog
    PAUSE 250 : LCDOUT $FE,1    ; Initialize LCD
    PAUSE 100 : LCDOUT $FE,1    ;  not all LCDs need both lines
    
    ADbits = 12                 ; set to 12-bit resolution
    ;---------------------------------------------------------------------------
    Main:
      FOR ADchan = 0 to 1       ; Do both AN0 and AN1
        GOSUB GetADC            ; Get A/D value
        IF ADchan = 0 THEN
           LCDOUT $FE, $80      ; LCD line 1
        ELSE
           LCDOUT $FE, $C0      ; LCD line 2
        ENDIF
        LCDOUT "CH-",DEC1 ADchan," = ",DEC ADvalue,"   "
      NEXT ADchan
    GOTO Main:
    ************************************************** ********************************
    ************************************************** ********************************
    Code:
    Here's another example that shows all the resolutions from 1-16 bit from a single A/D channel via the USART with HyperTerminal or other ANSI terminal program.
      	
    
    Download ALL-bit example Download example code.
    (Save it to a new folder.  Not the PBP folder)
    	View ALL-bit DEMO in browser View 
    
    ;--- Set your __configs here as needed ---
    DEFINE OSC 20
    INCLUDE "DT_Analog.pbp"           ; DT's 16-bit Analog Module
    
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 2
    DEFINE ADC_SAMPLEUS 5
    
    DEFINE HSER_SPBRG 10              ; 115200 @ 20 Mhz
    DEFINE HSER_RCSTA 90h             ; Hser receive status init 
    DEFINE HSER_TXSTA 24h             ; Hser transmit status init 
    DEFINE HSER_CLROERR 1             ; Hser clear overflow automatically 
    
    Volts   VAR WORD                  ; Volts calculated from the A/D reading
    
    ADCON1 = %10001101                ; right justify, AN0 & AN1 analog
    HSEROUT [27,"[2J"]                ; Clear screen
    ;---------------------------------------------------------------------------
    Main:
      HSEROUT [27,"[H"]               ; home cursor
      HSEROUT [27,"[34m",27,"[1m"]    ; bold blue text
      HSEROUT ["ADbits   DEC    HEX       BIN16         ADmax   Volts"]
      HSEROUT [27,"[37m",13,10]       ; black text
      
      ADchan = 1                      ; Select channel AN1
      FOR ADbits = 1 to 16            ; cycle thru all bit resolutions
        GOSUB GetADC                  ; get the A/D value
        GOSUB ShowAD                  ; show the A/D results
      NEXT ADbits                     ; do next resolution
    GOTO Main
    
    ;---------------------------------------------------------------------------
    ShowAD:
      IF ADbits < 10 THEN HSEROUT [" "]
      HSEROUT [DEC ADbits,"-bit = ",DEC ADvalue,"    "]
      HSEROUT [27,"[",DEC ADbits+1,";16H",HEX4 ADvalue,"  ",BIN16 ADvalue, _
              "   ",DEC ADmax]
      IF ADbits < 16 THEN             ; calculate the Voltage with 4 decimals
        Volts = 50000 * ADvalue
        Volts = DIV32 ADmax
      ELSE                            ; with 16-bit, ADmax is too big for DIV32 
        ADmax = ADmax >> 1            ;   cut it in half
        Volts = 25000 * ADvalue       ;   and scale the multiplier accordingly
        Volts = DIV32 ADmax           ; PBPL & Longs, doesn't have that problem
      ENDIF  
      HSEROUT [27,"[",DEC ADbits+1,";49H", _
               DEC Volts/10000,".",DEC4 Volts//10000 ,13,10]
    RETURN
    
    
    
    This is a screen shot of the ALLBitDEMO in action.
    
    
    And before you ask Charles ...
    This will not work (as is) on a PIC with a 12-bit A/D converter.
    ************************************************** ********************
    ************************************************** ********************
    Code:
    'http://www.darreltaylor.com/DT_Analog/
    '****************************************************************
    '*  Name    : AllBitDEMO.pbp                                    *
    '*  Author  : Darrel Taylor                                     *
    '*  Notice  : Copyright (c) 2009                                *
    '*  Date    : 5/24/2009                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : Example program for DT_Analog.pbp                 *
    '*       Displays all possible A/D resolutions for a single     *
    '*       channel using the USART and HyperTerminal or other     *
    '*       ANSI terminal program                                  *
    '****************************************************************
    ;--- Set your __configs here as needed ---
    DEFINE OSC 20
    INCLUDE "DT_Analog.pbp"           ; DT's 16-bit Analog Module
    
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 2
    DEFINE ADC_SAMPLEUS 5
    
    DEFINE HSER_SPBRG 10              ; 115200 @ 20 Mhz
    DEFINE HSER_RCSTA 90h             ; Hser receive status init 
    DEFINE HSER_TXSTA 24h             ; Hser transmit status init 
    DEFINE HSER_CLROERR 1             ; Hser clear overflow automatically 
    
    Volts   VAR WORD                  ; Volts calculated from the A/D reading
    
    ADCON1 = %10001101                ; right justify, AN0 & AN1 analog
    HSEROUT [27,"[2J"]                ; Clear screen
    ;---------------------------------------------------------------------------
    Main:
      HSEROUT [27,"[H"]               ; home cursor
      HSEROUT [27,"[34m",27,"[1m"]    ; bold blue text
      HSEROUT ["ADbits   DEC    HEX       BIN16         ADmax   Volts"]
      HSEROUT [27,"[37m",13,10]       ; black text
      
      ADchan = 1                      ; Select channel AN1
      FOR ADbits = 1 to 16            ; cycle thru all bit resolutions
        GOSUB GetADC                  ; get the A/D value
        GOSUB ShowAD                  ; show the A/D results
      NEXT ADbits                     ; do next resolution
    GOTO Main
    
    ;---------------------------------------------------------------------------
    ShowAD:
      IF ADbits < 10 THEN HSEROUT [" "]
      HSEROUT [DEC ADbits,"-bit = ",DEC ADvalue,"    "]
      HSEROUT [27,"[",DEC ADbits+1,";16H",HEX4 ADvalue,"  ",BIN16 ADvalue, _
              "   ",DEC ADmax]
      IF ADbits < 16 THEN             ; calculate the Voltage with 4 decimals
        Volts = 50000 * ADvalue
        Volts = DIV32 ADmax
      ELSE                            ; with 16-bit, ADmax is too big for DIV32 
        ADmax = ADmax >> 1            ;   cut it in half
        Volts = 25000 * ADvalue       ;   and scale the multiplier accordingly
        Volts = DIV32 ADmax           ; PBPL & Longs, doesn't have that problem
      ENDIF  
      HSEROUT [27,"[",DEC ADbits+1,";49H", _
               DEC Volts/10000,".",DEC4 Volts//10000 ,13,10]
    RETURN
    Last edited by Archangel; - 30th January 2015 at 17:23. Reason: add tables & examples
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #47

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

    Here is another one of DT's gems "MBAM". Maybe one of the moderators could move it here?

    http://www.picbasic.co.uk/forum/showthread.php?t=10564


    Edit: Thank you, done!
    Last edited by Demon; - 13th April 2015 at 02:08. Reason: Copy posts

  8. #48
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,532

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

    another one : The custom character generator ...Darrel.zip

    .zip file to be extracted to the folder you want

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  9. #49
    Join Date
    May 2013
    Location
    australia
    Posts
    1,444

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

    this is worth a mention . a mplax compatible version of dt_ints-18 (ver 3.4)

    http://support.melabs.com/threads/11...ghlight=mplabx

  10. #50

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

    Searching for Read/Write examples I found this thread by DT. Which has examples using macros for reading and writing to eeprom

    http://www.picbasic.co.uk/forum/show...t=write+eeprom

  11. #51

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

    After reading the complete thread. DT states in one of the last post, that most of the benifits are now incorporated
    in PBP3. So this thread is only useful for older versions of pbp or those studying macros. He was a very generous
    person.

  12. #52
    Join Date
    Apr 2003
    Location
    Cambridge - UK
    Posts
    871

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

    UPDATE

    A new repository has been created, to make finding and using the information imparted by the late Darrel Taylor.

    ---> See Here <---
    Lester - Forum Administrator
    -----------------------------------
    www.crownhill.co.uk

  13. #53
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,723

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

    Maybe this can show also as a link on forums main page?

    Ioannis

  14. #54
    Join Date
    Apr 2003
    Location
    Cambridge - UK
    Posts
    871

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

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

    Maybe this can show also as a link on forums main page?
    At the top of the main forum page there is a menu, on that menu there is an entry "interrupts" which takes you to dt.picbasic.co.uk
    Lester - Forum Administrator
    -----------------------------------
    www.crownhill.co.uk

Similar Threads

  1. Darrel Taylor Interrupts and MultiCalc
    By AvionicsMaster1 in forum General
    Replies: 6
    Last Post: - 14th February 2012, 06: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, 13:37
  3. Darrel Taylor's SPWM code usage
    By Homerclese in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th July 2010, 14:13
  4. using darrel taylor's instant interrupts
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st July 2007, 04:07
  5. Replies: 18
    Last Post: - 23rd May 2006, 05:57

Members who have read this thread : 56

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