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.. "
Bookmarks