PDA

View Full Version : RB port sequencer



freelancebee
- 17th August 2005, 20:58
Hi, All:
Finally, I came to idea to use PIC in my applications.
Small, cheap and easy to make application than by using
digital IC.
Bought PICBasic compiler and got problems:
-not debugging options
-not able to use assembler
-limited number of operators.
So I wrote my the first program for PIC16F84A
and appreciate any help to correct my program.
I want to buy in nearest future PICBadic Pro and now my focus is
to learn what kind of applications could be supported by PICBasic
compiler.
Best Regards,
Leonid
Here is the first program:
Because of limited numbers of operators in PICBasic I used Pulsout to hold output pins configuration during W7 -time.
Full sequence inRight rotattion is B1,B2,B3,B4,B5,B6
and during Left rotation is B7,B8,B9,B10,B11,B12.
B1-B12 numbers could be any depends of application.
Pin RB6 connected to LED indicates status of PIC Run/Stop
Pin RB7 does not used.

'PIC16F84A
Symbol PortA=$05
Symbol TRISA=$85
Symbol PortB=$06
Symbol TRISB=$86
'Symbol Period=10000
'Set Ports
Poke TRISA, 255'31
Poke TRISB, 0
'Set constant

B1=%01100110
B2=%01101111
B3=%01101001
B4=%01111011
B5=%01011110
B6=%01110110
B7=%01110110
B8=%01011010
B9=%01111011
B10=%01101001
B11=%01101101
B12=%01100110
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 Bit3=0 Then Task
Goto Check

Task:
IF Bit2=0 Then RLft
IF Bit2=1 Then RRht
Goto Task

RLft:

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
IF Bit3=1 Then Check
Call minus
Goto Task


RRht:
IF Bit3=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
IF Bit3=1 Then Check
Call minus
Goto Task

Minus:
If Bit0=1 Then Plus
W7=W7 - 1
If W7<$100 Then LimM
Goto Task

Plus:
If Bit1=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