PDA

View Full Version : Sequencer



freelancebee
- 29th August 2005, 18:12
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.. "

electroken
- 2nd August 2011, 16:47
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.

pyrogeek
- 2nd August 2011, 22:15
so, what is this for? just makes some LED's turn on? lol