problems wen I disconnect serial
kevintherobot
Posts: 3
hello,
I am building a robot as a yearproject, I am using a basic stamp (bs2).
I have made the programme for my robot and it works but everytime I disconnect the serial cable from my PCB the basic stamp doesn't do wat I want.
On one input I am using a switch, when the computer is connected he does everything correct when i use this switch, when there is no computer connected he doesn't wait for the switch to do something else. I am confused and I can't find a way to solve this problem.
kevin
I am building a robot as a yearproject, I am using a basic stamp (bs2).
I have made the programme for my robot and it works but everytime I disconnect the serial cable from my PCB the basic stamp doesn't do wat I want.
On one input I am using a switch, when the computer is connected he does everything correct when i use this switch, when there is no computer connected he doesn't wait for the switch to do something else. I am confused and I can't find a way to solve this problem.
kevin
Comments
here is the programme:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!" ,CR, CRSRUP
'---[noparse][[/noparse] Variables ]
irDetectLeft VAR Bit
irDetectRight VAR Bit
pulseCount VAR Byte
'---[noparse][[/noparse]Initialization]---
IF IN7 = 1 THEN 'this is just for the show
DO
HIGH 0
HIGH 14
LOW 1
LOW 15
PAUSE 250
HIGH 1
HIGH 15
HIGH 0
HIGH 14
PAUSE 250
LOW 0
LOW 14
HIGH 1
HIGH 15
PAUSE 250
LOW 0
LOW 15
LOW 1
LOW 14
PAUSE 250
LOOP UNTIL IN7 = 0
ENDIF
'---[noparse][[/noparse] Main Routine ]
IF IN7 = 0 THEN
DO 'this is the actuall programme
FREQOUT 3, 1, 38500
irDetectLeft = IN4
FREQOUT 12, 1, 38500
irDetectRight = IN11
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (irDetectLeft = 0) THEN
GOSUB Turn_Right
ELSEIF (irDetectRight = 0) THEN
GOSUB Turn_Left
ELSE
GOSUB Forward_Pulse
ENDIF
'---[noparse][[/noparse] Subroutines ]----
Forward_Pulse:
LOW 0
LOW 14
HIGH 1
HIGH 15
PULSOUT 13, 1000
PULSOUT 2, 500
PAUSE 20
RETURN
Turn_Left:
LOW 14
LOW 15
HIGH 0
HIGH 1
FOR pulseCount = 0 TO 40
PULSOUT 13, 850
PULSOUT 2, 850
PAUSE 20
NEXT
RETURN
Turn_Right:
LOW 0
LOW 1
HIGH 14
HIGH 15
FOR pulseCount = 0 TO 40
PULSOUT 13, 650
PULSOUT 2, 650
PAUSE 20
NEXT
RETURN
Back_Up:
LOW 0
LOW 1
LOW 14
LOW 15
HIGH 14
HIGH 0
FOR pulseCount = 0 TO 20
PULSOUT 13, 650
PULSOUT 2, 850
PAUSE 20
NEXT
RETURN
LOOP UNTIL IN7 = 1
ENDIF
in the programme IN7 is the switch
13 and 2 are servos
and 0,1,14 and 15 are LEDS
so when I disconnect the serial cable he doesn't look after IN7 anymore, he does the main routine or the initialization through each other, there is no more order.
I have searched the internet after schematics and I have found someting that could maybe be the problem, does the VSS of the serial cable (pin on the BS2) need to be connected to the other VSS pin on the basic stamp?
kevin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Also may want to check how your switch is connected. Are you pulling them up or down to keep the input at pin 7 from floating?
rick
I don't think the switch is connected badly, I have connected it the way the manuals of Basic Stamp say how to connect it.