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


+ Reply to Thread
Results 1 to 40 of 55

Hybrid View

  1. #1
    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.
       
    • 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.
       
    • 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.
       
    • 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

  2. #2
    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

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 : 8

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