I have written a program to control the servos of my device ,while a digital compass reads the direction and shows south.
The compass is working fine up until the point I jump to the interrupt to control the servos.The compass completely freezes .
My code is
--------------------------------------------------------------------------'+++++++++++++++++++++
SYMBOL TX_PIN = 0
'SYMBOL RX_PIN =
SYMBOL NORTH = pin7
SYMBOL EAST = pin6
SYMBOL SOUTH = pin5
SYMBOL WEST = pin4
SYMBOL Movs = B1 ' Declaring all Constants and Variables
dirsc = %00001110 ' Configuring Pins
init:
setint %00000001,%00000001 ' Defining Which Pin and State of Pin for Interrupt
main:
if North=0 and South=1 and East=1 and West=1 then label_18 ' North
if North=0 and South=1 and East=0 and West=1 then label_17 ' North East
if North=1 and South=1 and East=0 and West=1 then label_16 ' East
if North=1 and South=0 and East=0 and West=1 then label_15 ' South East
if North=1 and South=0 and East=1 and West=1 then label_14 ' South
if North=1 and South=0 and East=1 and West=0 then label_13 ' South West
if North=1 and South=1 and East=1 and West=0 then label_12 ' West
if North=0 and South=1 and East=1 and West=0 then label_11 ' North West
goto main ; *****
label_11:
low portc 1
low portc 2
low portc 3
low 3
low 2
low 1
low 0
high 4
serout 5,N2400,("2")
pause 500
goto main
label_12:
low portc 1
low portc 2
low portc 3
low 4'let pins = %01000 'Turns LED2 on
low 2
low 1
low 0
high 3
serout 5,N2400,("3")
pause 500
goto main
label_13:
low portc 1
low portc 2
low portc 3
low 4'let pins = %00100 'Turns LED3 on
low 3
low 1
low 0
high 2
serout 5,N2400,("4")
pause 500
goto main
label_14:
low portc 1
low portc 2
low portc 3
low 4
low 3
low 2
low 1
low 0
high 1
serout 5,N2400,("5")
pause 500
goto main
label_15:
low portc 1
low portc 2
low portc 3
low 4
low 3
low 2
low 1
high 0
serout 5,N2400,("6")
pause 500
goto main
label_16:
low portc 1
low portc 2
low 4
low 3
low 2
low 1
low 0
high portc 1 'Turns LED6 on
serout 5,N2400,("7")
pause 500
goto main
label_17:
low portc 1
low portc 3
low 4
low 3
low 2
low 1
low 0
high portc 2 'Turns LED7 on
serout 5,N2400,("8")
pause 500
goto main
label_18:
low portc 2
low portc 3
low 4
low 3
low 2
low 1
low 0
high portc 3 ' Turns LED8 on
serout 5,N2400,("1")
pause 500
goto main
Interrupt:
SERIN 0,N2400,b1
moving:
servopos 6,147 ‘ move servo to one end
servopos 7,150 ‘ move servo to one end
pause 2000 ‘ wait 2 seconds
select case Movs
case = 111 'Moving Forward
servopos 6,149 'move servo to one end
servopos 7,151 'move servo to one end
pause 2000 'wait 2 second
case = 110 'Moving Left
servopos 6,149 ‘ move servo to one end
servopos 7,149 ‘ move servo to one end
case = 101 'Moving Right
servopos 6,151 ‘ move servo to one end
servopos 7,151 ‘ move servo to one end
case = 100 'Moving Back
servopos 6,151 ‘ move servo to one end
servopos 7,149 ‘ move servo to one end
end select
let Movs=0
Do
Loop Until Pin0 = 0
setint %00000001,%00000001 ' Defining Which Pin and State of Pin for Interrupt
RETURN
-----------------------------------------------------------------------
I want the compass to carry on functioning whilst i just to the interrupt
who do I achieve this??
This is really urgent . I have to submit my project in 2hour
Thank you
The compass is working fine up until the point I jump to the interrupt to control the servos.The compass completely freezes .
My code is
--------------------------------------------------------------------------'+++++++++++++++++++++
SYMBOL TX_PIN = 0
'SYMBOL RX_PIN =
SYMBOL NORTH = pin7
SYMBOL EAST = pin6
SYMBOL SOUTH = pin5
SYMBOL WEST = pin4
SYMBOL Movs = B1 ' Declaring all Constants and Variables
dirsc = %00001110 ' Configuring Pins
init:
setint %00000001,%00000001 ' Defining Which Pin and State of Pin for Interrupt
main:
if North=0 and South=1 and East=1 and West=1 then label_18 ' North
if North=0 and South=1 and East=0 and West=1 then label_17 ' North East
if North=1 and South=1 and East=0 and West=1 then label_16 ' East
if North=1 and South=0 and East=0 and West=1 then label_15 ' South East
if North=1 and South=0 and East=1 and West=1 then label_14 ' South
if North=1 and South=0 and East=1 and West=0 then label_13 ' South West
if North=1 and South=1 and East=1 and West=0 then label_12 ' West
if North=0 and South=1 and East=1 and West=0 then label_11 ' North West
goto main ; *****
label_11:
low portc 1
low portc 2
low portc 3
low 3
low 2
low 1
low 0
high 4
serout 5,N2400,("2")
pause 500
goto main
label_12:
low portc 1
low portc 2
low portc 3
low 4'let pins = %01000 'Turns LED2 on
low 2
low 1
low 0
high 3
serout 5,N2400,("3")
pause 500
goto main
label_13:
low portc 1
low portc 2
low portc 3
low 4'let pins = %00100 'Turns LED3 on
low 3
low 1
low 0
high 2
serout 5,N2400,("4")
pause 500
goto main
label_14:
low portc 1
low portc 2
low portc 3
low 4
low 3
low 2
low 1
low 0
high 1
serout 5,N2400,("5")
pause 500
goto main
label_15:
low portc 1
low portc 2
low portc 3
low 4
low 3
low 2
low 1
high 0
serout 5,N2400,("6")
pause 500
goto main
label_16:
low portc 1
low portc 2
low 4
low 3
low 2
low 1
low 0
high portc 1 'Turns LED6 on
serout 5,N2400,("7")
pause 500
goto main
label_17:
low portc 1
low portc 3
low 4
low 3
low 2
low 1
low 0
high portc 2 'Turns LED7 on
serout 5,N2400,("8")
pause 500
goto main
label_18:
low portc 2
low portc 3
low 4
low 3
low 2
low 1
low 0
high portc 3 ' Turns LED8 on
serout 5,N2400,("1")
pause 500
goto main
Interrupt:
SERIN 0,N2400,b1
moving:
servopos 6,147 ‘ move servo to one end
servopos 7,150 ‘ move servo to one end
pause 2000 ‘ wait 2 seconds
select case Movs
case = 111 'Moving Forward
servopos 6,149 'move servo to one end
servopos 7,151 'move servo to one end
pause 2000 'wait 2 second
case = 110 'Moving Left
servopos 6,149 ‘ move servo to one end
servopos 7,149 ‘ move servo to one end
case = 101 'Moving Right
servopos 6,151 ‘ move servo to one end
servopos 7,151 ‘ move servo to one end
case = 100 'Moving Back
servopos 6,151 ‘ move servo to one end
servopos 7,149 ‘ move servo to one end
end select
let Movs=0
Do
Loop Until Pin0 = 0
setint %00000001,%00000001 ' Defining Which Pin and State of Pin for Interrupt
RETURN
-----------------------------------------------------------------------
I want the compass to carry on functioning whilst i just to the interrupt
who do I achieve this??
This is really urgent . I have to submit my project in 2hour
Thank you