Sequencer


Closed Thread
Results 1 to 3 of 3

Thread: Sequencer

  1. #1
    freelancebee's Avatar
    freelancebee Guest

    Lightbulb Sequencer

    Hi All:
    Here is the example of program written in PICBasic Compiler and adjusted
    to use in PICBasic PRO compiler to generate sequence on 6 pins PORTB in different ordrer and use PULSOUT function as timer on pin 7 because in
    PICBASI PRO Compiler I couldnot find any function to do that.
    Regards,
    Leonid

    'PIC16F84A
    'PICBASIC PRO compiler
    'Set variables
    b0 var BYTE
    w7 var WORD ' Just a Counter
    'Symbol Period=10000



    'set constant
    b1 con %01100100
    b2 con %01101101
    b3 con %01001001
    b4 con %01011011
    b5 con %01010010
    b6 con %01110110
    b7 con %01110110
    b8 con %01010010
    b9 con %01011011
    b10 con %01001001
    b11 con %01101101
    b12 con %01100100

    'Set Ports
    poke TRISA, 255 '31
    poke TRISB, 0
    'Initialize variable
    w7 = $2710
    'Start analizing input

    check:
    peek PORTA, b0
    'Bit0=0 Minus one step from W7
    'Bit1=0 Plus one step to W7
    'Bit2=1 Rotation Right
    'Bit2=0 Rotation Left
    'Bit3=0 Go
    'Bit3=1 Stop
    'Bit4
    If PORTA.3 = 0 Then task
    Goto check

    task:
    peek PORTA, b0
    If PORTA.2 = 0 Then rlft
    If PORTA.2 = 1 Then rrht
    Goto task
    'Because PULSOUT function has only one
    'pin for output I used multiply pin selection
    '6 pins in PORTB and count time by PULSOUT firing
    'in PORTB.7
    'PORTB.6 pin used to indicate status of PIC Run/Stop
    rlft:
    If PORTA.3 = 1 Then check
    poke PORTB, b7
    pulsout 7, w7
    poke PORTB, b8
    pulsout 7, w7
    poke PORTB, b9
    pulsout 7, w7
    poke PORTB, b10
    pulsout 7, w7
    poke PORTB, b11
    pulsout 7, w7
    poke PORTB, b12
    pulsout 7, w7
    peek PORTA, b0
    If PORTA.3 = 1 Then check
    call minus
    Goto task


    rrht:
    If PORTA.3 = 1 Then check
    poke PORTB, b1
    pulsout 7, w7
    poke PORTB, b2
    pulsout 7, w7
    poke PORTB, b3
    pulsout 7, w7
    poke PORTB, b4
    pulsout 7, w7
    poke PORTB, b5
    pulsout 7, w7
    poke PORTB, b6
    pulsout 7, w7
    peek PORTA, b0
    If PORTA.3 = 1 Then check
    call minus
    Goto task

    minus:
    If PORTA.0 = 1 Then plus
    w7 = w7 - 1
    If w7 < $100 Then limm
    Goto task

    plus:
    If PORTA.1 = 1 Then task
    w7 = w7 + 1
    If w7 > $5000 Then limp
    w7 = $5000
    Goto task

    limm:
    w7 = $100
    Goto task

    limp:
    w7 = $5000
    Goto task

    End

    "In real World each individual able to get own information depends of own experience from same single source.. "

  2. #2
    Join Date
    Dec 2009
    Location
    Warrenton Mo
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Sequencer

    Waaay to much programming for me, dude.

    ' kitt 1
    for loop=1 to 20' do kitt twenty times
    for j=0 to 7: portb.0(j)=1: pause 40: portb.0(j)=0:next j ' pause 40 is on time
    for j=7 to 0 step-1: portb.0(j)=1: pause 40: portb.0(j)=0:next j
    next loop
    goto _____
    end

    or,

    for loop=1 to 20' do stay lit twenty times
    for j=0 to 7: portb.0(j)=1: pause 40:next j ' light 'em up
    for j=6 to 0 step-1: portb.0(j)=0: pause 40:next j ' turn 'em off
    next loop
    goto _____
    end

    simple huh? This applies for nearly all pics using portb, or c, or d, or a or whetever.
    The more I think about it the worse off I am

  3. #3
    Join Date
    Aug 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Sequencer

    so, what is this for? just makes some LED's turn on? lol

Similar Threads

  1. Corrected RB port Sequencer
    By freelancebee in forum mel PIC BASIC
    Replies: 0
    Last Post: - 19th August 2005, 20:14
  2. RB port sequencer
    By freelancebee in forum mel PIC BASIC
    Replies: 0
    Last Post: - 17th August 2005, 19:58

Members who have read this thread : 0

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