MIBAM - (Mirror Imaged Bit Angle Modulation)


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    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 "MIBAM.pbp"                 ; 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
    Last edited by Darrel Taylor; - 5th June 2014 at 15:36. Reason: Trying to fix HTML
    DT

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Bit Angle Modulation (BAM) in a PIC
    By Bronx68 in forum mel PIC BASIC Pro
    Replies: 150
    Last Post: - 24th February 2015, 13:41
  3. Bit Angle Modulation
    By BH_epuk in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th November 2008, 07:01
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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