I've got a JAVA GUI which is receiving constantly data from my compass sensor and also is sending strings 1111 as a forward button, 1110 as right turn,1100 as left turn,1000 as reverse to move the servo motors. I've put an interrupt for call from my GUI but some reason in the simulation the program is not working properly. The first time it runs OK but then the interrupt cannot be initialised.
--------------------------------------------------------------------------
'+++++++++++++++++++++
SYMBOL TX_PIN = 2
SYMBOL RX_PIN = 3
SYMBOL NORTH = pin7
SYMBOL EAST = pin6
SYMBOL SOUTH = pin5
SYMBOL WEST = pin4
main:
init:
setint %00000100,%00000100
if North=0 and South=1 and East=1 and West=1 then label_11 ' North
if North=0 and South=1 and East=0 and West=1 then label_12 ' North East
if North=1 and South=1 and East=0 and West=1 then label_13 ' East
if North=1 and South=0 and East=0 and West=1 then label_14 ' South East
if North=1 and South=0 and East=1 and West=1 then label_15 ' South
if North=1 and South=0 and East=1 and West=0 then label_16 ' South West
if North=1 and South=1 and East=1 and West=0 then label_17 ' West
if North=0 and South=1 and East=1 and West=0 then label_18 ' North West
goto main ; *****
label_11: let pins = %10000000 ' LED1 on
serout TX_PIN,N2400,("2")
pause 500
goto main
label_12: let pins = %01000000 ' LED2 on
serout 2,N2400,("3")
pause 500
goto main
label_13: let pins = %00100000 ' LED3 on
serout 2,N2400,("4")
pause 500
goto main
label_14: let pins = %00010000 ' LED4 on
serout 2,N2400,("5")
pause 500
goto main
label_15: let pins = %00001000 ' LED5 on
serout 2,N2400,("6")
pause 500
goto main
label_16: let pins = %00000100 ' LED6 on
serout 2,N2400,("7")
pause 500
goto main
label_17: let pins = %00000010 ' LED7 on
serout 2,N2400,("8")
pause 500
goto main
label_18: let pins = %00000001 ' LED8 on
serout 2,N2400,("1")
pause 500
goto main
Interrupt:
SERIN 2,N2400,b1
moving:
servopos 0,150 ‘ move servo to one end
servopos 1,150 ‘ move servo to one end
pause 2000 ‘ wait 2 seconds
select case b1
case=87
servopos 0,180 ‘ move servo to one end
servopos 1,180 ‘ move servo to one end
case 86
servopos 0,180 ‘ move servo to one end
servopos 1,120 ‘ move servo to one end
case 76
servopos 0,120 ‘ move servo to one end
servopos 1,180 ‘ move servo to one end
case 232
servopos 0,120 ‘ move servo to one end
servopos 1,120 ‘ move servo to one end
end select
let b1=0
goto main
RETURN
------------------------------------------------------------------------------
Any help will be appreciated.
--------------------------------------------------------------------------
'+++++++++++++++++++++
SYMBOL TX_PIN = 2
SYMBOL RX_PIN = 3
SYMBOL NORTH = pin7
SYMBOL EAST = pin6
SYMBOL SOUTH = pin5
SYMBOL WEST = pin4
main:
init:
setint %00000100,%00000100
if North=0 and South=1 and East=1 and West=1 then label_11 ' North
if North=0 and South=1 and East=0 and West=1 then label_12 ' North East
if North=1 and South=1 and East=0 and West=1 then label_13 ' East
if North=1 and South=0 and East=0 and West=1 then label_14 ' South East
if North=1 and South=0 and East=1 and West=1 then label_15 ' South
if North=1 and South=0 and East=1 and West=0 then label_16 ' South West
if North=1 and South=1 and East=1 and West=0 then label_17 ' West
if North=0 and South=1 and East=1 and West=0 then label_18 ' North West
goto main ; *****
label_11: let pins = %10000000 ' LED1 on
serout TX_PIN,N2400,("2")
pause 500
goto main
label_12: let pins = %01000000 ' LED2 on
serout 2,N2400,("3")
pause 500
goto main
label_13: let pins = %00100000 ' LED3 on
serout 2,N2400,("4")
pause 500
goto main
label_14: let pins = %00010000 ' LED4 on
serout 2,N2400,("5")
pause 500
goto main
label_15: let pins = %00001000 ' LED5 on
serout 2,N2400,("6")
pause 500
goto main
label_16: let pins = %00000100 ' LED6 on
serout 2,N2400,("7")
pause 500
goto main
label_17: let pins = %00000010 ' LED7 on
serout 2,N2400,("8")
pause 500
goto main
label_18: let pins = %00000001 ' LED8 on
serout 2,N2400,("1")
pause 500
goto main
Interrupt:
SERIN 2,N2400,b1
moving:
servopos 0,150 ‘ move servo to one end
servopos 1,150 ‘ move servo to one end
pause 2000 ‘ wait 2 seconds
select case b1
case=87
servopos 0,180 ‘ move servo to one end
servopos 1,180 ‘ move servo to one end
case 86
servopos 0,180 ‘ move servo to one end
servopos 1,120 ‘ move servo to one end
case 76
servopos 0,120 ‘ move servo to one end
servopos 1,180 ‘ move servo to one end
case 232
servopos 0,120 ‘ move servo to one end
servopos 1,120 ‘ move servo to one end
end select
let b1=0
goto main
RETURN
------------------------------------------------------------------------------
Any help will be appreciated.