How to make PWM to all the pins at the portB in same time on 16f628


Closed Thread
Results 1 to 12 of 12
  1. #1

    Default How to make PWM to all the pins at the portB in same time on 16f628

    How to make PWM to all the pins at the portB in same time on 16f628
    or is there another command: for example, eight LEDs connected portb 0,1,2,3,4,5,6,7 to work with 50% at the same time.
    At the same time to light and perish one by one with 100%.
    but never to perish under 50%.

    please help

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Use a 7408.

    Connect one input of each "AND" to PWM output of F628A, all other inputs to your PORTB pins.

    Whenever and whichever of your PORTB pin is high, you will get the same PWM output.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

  4. #4


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by sayzer View Post
    Use a 7408.

    Connect one input of each "AND" to PWM output of F628A, all other inputs to your PORTB pins.

    Whenever and whichever of your PORTB pin is high, you will get the same PWM output.
    CAN YOU tell me examples of how to do it

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    This picture is from WEB.
    Attached Images Attached Images  
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6


    Did you find this post helpful? Yes | No

    Default

    http://picprojects.org.uk/projects/l...rpwm/index.htm
    vivi this. In assembly language, I do not understand assembly,
    Watch the clip 1.30 to 1.50 min. That I want to do but do not know how the PICBASIC PRO

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dejankengur View Post
    http://picprojects.org.uk/projects/l...rpwm/index.htm
    vivi this. In assembly language, I do not understand assembly,
    Watch the clip 1.30 to 1.50 min. That I want to do but do not know how the PICBASIC PRO
    There are a lot of effects in that video. This will do the "scanner" part: http://www.picbasic.co.uk/forum/showthread.php?t=10564&p=70256#post70256
    http://www.scalerobotics.com

  8. #8


    Did you find this post helpful? Yes | No

    Default

    errors with 16f628
    Fatal TEST.ASM 435 : [308] macro buffer overflow
    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 (PORTB,0, LED1)        ;   and the associated Duty variables
         BAM_PIN (PORTB,1, LED2)
         BAM_PIN (PORTB,2, LED3)
         BAM_PIN (PORTB,3, LED4)
         BAM_PIN (PORTB,4, LED5)
         BAM_PIN (PORTB,5, LED6)
         BAM_PIN (PORTB,6, LED7)
         BAM_PIN (PORTB,7, LED8)
      endm
      BAM_INIT  BAM_LIST                ; Initialize the Pins
    ENDASM
    
    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
    Last edited by ScaleRobotics; - 26th December 2010 at 20:31.

  9. #9
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dejankengur View Post
    errors with 16f628
    Fatal TEST.ASM 435 : [308] macro buffer overflow
    I did not get that error with your code, but I did need to add the stuff about wsave psave etc variables, which is explained in the mibam thread.

    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

    Last edited by ScaleRobotics; - 27th December 2010 at 16:44.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    The macro buffer overflow happens when you use PM for the assembler.

    Use MPASM instead.
    DT

  11. #11


    Did you find this post helpful? Yes | No

    Default

    Thanks guys
    But how to high with 2.5 volts all pins at PirtB in the same time.

  12. #12


    Did you find this post helpful? Yes | No

    Default

    Help help

Members who have read this thread : 1

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