MIBAM and 12F1822...


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: MIBAM and 12F1822...

    the circuit is just a phototransistor and a resistor for the detector, I added a IR led next to it as well so it works in the dark. I sample the ADC every few ms and calculate the difference from previous/last sample, to get a delta value, and just trigger some flahsy lights if the delta exceeds the threshold value, which controls how sensitive the trigger is.

    I now have 1 pin left to do something with (I used it for debug output to see what my adc output was, thinking of using it to trigger adjacent modules perhaps, to create a cascading effect perhaps)

    funny didn't intend to build this earlier, but it's kinda fun, so I'll just keep going with it and see what I can get this tiny pic to do..

    and the 12f1822 is dirt cheap so perhaps I'll build a few dozen at least and
    see how it goes.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,144


    Did you find this post helpful? Yes | No

    Default Re: MIBAM and 12F1822...

    Am I the only one that cannot see the video?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default Re: MIBAM and 12F1822...

    Doies it start or it says it's blocked due to copyright plah plah? Works here though (Firefox)
    Steve

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

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,144


    Did you find this post helpful? Yes | No

    Default Re: MIBAM and 12F1822...

    Hmm, curious. Now I am at home with a Vista/IE9 and it works OK.

    By the way very nice project alesniak.

    On my office XP-IE8 it was pure white. No youtube window no message. Nothing.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default Re: MIBAM and 12F1822...

    I would try to re-install flashplayer and see what happen. Never messed that much with IE though...FireFox FTW
    Steve

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

  6. #6
    Join Date
    Aug 2011
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: MIBAM and 12F1822...

    hmm, must be a IE thing, I use firefox or chrome and the video seem to work fine.

    so sorry for the delay, I decided to make a about a hundred modules to build a
    interactive light table, so took me a few days to get the layout finished before I sent off a test pcb run, here's the pbp code if anyone is interested, feel free to make it better, cooler, etc.... I'm going to wait to post the pcb gerber files, I placed an order that should be here next few days, just to check that everything works as planned then I'll post the pcb files.. (don't really like posting stuff that I'm not 100% sure is working, untill I have the boards in hand)

    Code:
    '****************************************************************
    '     MIBAM TEST pic12F683 / pic12f1822                         *
    '****************************************************************
    
    #IF __PROCESSOR__ = "12F1822"
        #MSG "Compililng for 12F1822..."
        #CONFIG
           __config _CONFIG1, _FOSC_INTOSC & _MCLRE_OFF
           __config _CONFIG2, _PLLEN_OFF & _LVP_OFF
        #ENDCONFIG
        OSCCON = %01110000        '8mhz
        TRISA  = %00011000        'setup inputs/outputs
        'ANSELA = %00010000        'RA4 = analog
        ANSELA = %00001000 
        CM1CON0 = 0               'disable comarators
        ADCON0 = %00001101        'Select AN3 enable ADC
        ADCON1 = %11010000        'Right Justify - Fosc/16 & 8mhz
        BTN var PORTA.3
    #ELSE
        #if __PROCESSOR__ = "12F683"
            #msg "Compiling for 12F683..."
            #CONFIG
                __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
            #ENDCONFIG
            OSCCON = %01110001       '8mhz
            TRISIO = %00011000       'setup inputs/outputs
            ANSEL  = %01011000       'RA4 = analog
            CMCON0 = %00000111       'disable comarators
            ADCON0 = %10001101       'Right Justify - Fosc/16 & 8mhz
            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 wsave1-3
            
            ' --- IF any of these three lines cause an error ?? ------------------------
            '       Comment them out to fix the problem ----
            ' -- Which variables are needed, depends on the Chip you are using -- 
            ;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
            ssave       VAR BYTE    BANK0   SYSTEM      ' location for STATUS register
            psave       VAR BYTE    BANK0   SYSTEM      ' location for PCLATH register
            ' --------------------------------------------------------------------------
            disable debug
            ;---------------------------------------------------------------------------
            BTN var GPIO.3
        #else
            #ERROR "Only 12F1822 & 12F683 are supported!"
        #endif
    #ENDIF
    
    DEFINE OSC 8              '8mhz
    
    DEFINE DEBUG_REG PORTA              'serial output to get ADC levels
    DEFINE DEBUG_BIT 5
    DEFINE DEBUG_BAUD 9600
    DEFINE DEBUG_MODE 0
    
    BAM_COUNT CON 3                     ; How many BAM Pins are used?
    INCLUDE "MIBAM.pbp"                 ; Mirror Image BAM module
    
    RED  VAR BYTE
    GRN  VAR BYTE
    BLU  VAR BYTE
    
    adc_val     var word                'adc value variable
    adc_last    var word                'previous adc value
    adc_thresh  var word                'adc trigger threshold variable
    adc_delta   var word                'change in adc/value
    Mode        var byte                'currently selected effect mode
    x           var byte                'just a byte
    
    ASM
    BAM_LIST  macro                     ; Define PIN's to use for BAM
         BAM_PIN (PORTA,0, BLU)         ;   and the associated Duty variables
         BAM_PIN (PORTA,1, RED)
         BAM_PIN (PORTA,2, GRN)
      endm
      BAM_INIT  BAM_LIST                ; Initialize the Pins
    ENDASM
    
    Speed CON 5         'led fade speed   
    adc_thresh = 20     'trigger threshold (adjust to change sensitivity)
    red = 0
    blu = 0
    grn = 0  
    MODE = 0
    
    
    '------------------------ MAIN PROGRAM LOOP ------------------------
    main:
    
        if btn = 0 then      'check mode button
            mode = mode + 1
            pause 400
            if btn = 0 then  'check to see if press/hold mode button (reset)
                pause 2000      'reset if modules get out of sync on modes.
                GIE = 1         'press mode button > 2.5 sec
                for x = 1 to 5
                    red = 50
                    pause 40
                    red = 0
                    pause 40
                next x
                GIE = 0
                red = 0
                mode = 0
            endif
            if mode > 4 then 
                mode = 0
            endif
        endif
        
    
        pause 30
        gosub do_adc           'get ADC reading
        gosub get_delta        'calculate delta since last reading
        'debug "ADC: ", dec4 adc_Val, "--> ",dec4 adc_last," D: ", dec3 adc_delta,13,10
         
        if adc_delta > adc_thresh then 'trigger effect if threshold exceded 
            GIE = 1
            select case mode
                case 0
                    gosub fadeR
                
                case 1 
                    gosub fadeG
                    
                case 2 
                    gosub fadeB
                    
                case 3
                    gosub sparkle
                    
                case 4
                    gosub flash
                    
            end select
            
            GIE = 0
            pause 30       
            gosub do_adc
            gosub get_delta
        endif 
        
    goto main
    
    '------------------------- SUBROUTINES ---------------------------------------
    
    Do_Adc:                 'sample ADC pin
        adc_last = adc_val
        pauseus 50
        ADCON0.1=1
        WHILE ADCON0.1 : WEND
        adc_val.highbyte = ADRESH
        adc_val.lowbyte = ADRESL
    return
        
    Get_Delta:
        if adc_last = adc_val then
            adc_delta = 0
            return
        else
            if adc_last > adc_val then
                adc_delta = adc_last - adc_val
            else
                adc_delta = adc_val - adc_last
            endif
        endif
    return
    
    
    '------------------- EFFECTS SECTION ------------------------
    
    fadeB:
        FOR BLU = 255 to 1 STEP -1
                PAUSE Speed
        NEXT BLu
        blu = 0
    return
    
    fadeG:
        FOR grn = 255 to 1 STEP -1
                PAUSE Speed
        NEXT grn
        grn = 0
    return
    
    fadeR:
        FOR red = 255 to 1 STEP -1
                PAUSE Speed
        NEXT red
        red = 0
    return
    
    
    sparkle:
        for x = 255 to 1 step -10
            red = x
            BLU = x
            pause 30
            red = 0
            BLU = 0
            pause 30
        next x
    return
    
    flash:
        red = 255
        grn = 255
        blu = 255
        pause 30
        red = 0
        grn = 0
        blu = 0
        pause 30
    return
    I've tested the code on both 12F683 and 12F1822, works great, don't forget to grab the latest version of MIBAM in this thread above! thanks again Darrel!.

    I'll post more pictures and video once I get the modules... stay tuned..

  7. #7
    Join Date
    Aug 2011
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: MIBAM and 12F1822...

    took a little while (day job gets in the way!) but here's what I ended up with..
    still have to finish my table assembly but the building blocks are nearly done
    I have hand assembled about 120 modules, they still need some wiring but
    all work like my original video above.

    front and back of the module, each is 1"x1" square


    a small pile of assembled modules, smt assembly really goes quickly, using a toaster to reflow the pcb's. only wish I had a pick & place machine.


    cnc'd some frosted acrylic to make individual tiles, which will become the tabletop..

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