PDA

View Full Version : problems wen I disconnect serial



kevintherobot
04-08-2010, 12:45 AM
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

Mike Green
04-08-2010, 01:38 AM
As with any question like yours, you have to provide more information since the Stamps are designed to work the way you describe (either connected to a PC or working on their own) without changing the program. Please attach a schematic and a source file for your program. Use the "Post Reply" button and you'll see a button for the "Attachment Manager" which will allow you to attach files to one of your messages. Use some kind of drawing program for the schematic or draw one by hand and scan it in, then attach a JPG or PDF file of it.

kevintherobot
04-08-2010, 02:36 AM
I can give you the programme I have made for my robot but for the schematics it's not so simple, the PCB is made out of 3 sections so I don't have a schematic of all three together.

here is the programme:

' {$STAMP BS2}
' {$PBASIC 2.5}

DEBUG "Program Running!" ,CR, CRSRUP

'---[ Variables ]---------

irDetectLeft VAR Bit
irDetectRight VAR Bit
pulseCount VAR Byte


'---[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
'---[ 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


'---[ 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

erco
04-08-2010, 04:11 AM
Yes, Sir. All grounds must be tied together.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you build it, they will come."

rixter
04-08-2010, 05:23 AM
Kevin,

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

kevintherobot
04-10-2010, 12:20 AM
I have connected the VSS of the serial cable with the other VSS and the problem is still the same.

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.