My Programming....Need Help!!
ORIGINAL Program
MY Modified Program I'm using
my sensors arent reading right
·the left IR tells the rightside to slow down instead of speed up and my right IR isnt reading at all
'{$STAMP BS2}
'{$PBASIC 2.5}
' -----[noparse][[/noparse] Program Description ]-----------------
' -----[noparse][[/noparse] I/O Definitions ]---------------------
RightServo CON 12
LeftServo CON 13
GripServo CON 14
L_IR_out CON 11
Closing_IR_out CON 10
R_IR_out CON 9
L_IR_in VAR IN11
Closing_IR_in VAR IN10
R_IR_in VAR IN9
' -----[noparse][[/noparse] Constants ]--------------------------
CloseGripper CON 700
OpenGripper CON 1200
LeftStop CON 750
RightStop CON 750
Object CON 0
NoObject CON 1
' -----[noparse][[/noparse] Varibles ]---------------------------
left_IR VAR Bit
right_IR VAR Bit
closing_IR VAR Bit
pulses VAR Word
pulsewidth VAR Word
' -----[noparse][[/noparse] Initialization ]---------------------
DIR8 = %1 ' i believe this part is wrong
DIR9 = %1
DIR11 = %1
' -----[noparse][[/noparse] Main Code ]---------------------------
GOSUB Open
Look_For_Item:
GOSUB Spin_Pulse
GOSUB Read_LR_IRs
IF right_IR AND left_IR = NoObject THEN Look_For_Item
Center_On_Item:
GOSUB Forward_Pulse
GOSUB Zero_In
GOSUB Read_Closing_IR
IF closing_IR = Object THEN Move_Item
'else
GOTO Center_On_Item
Zero_In:
GOSUB Read_LR_IRs
IF left_IR = Object THEN Right_Pulse
IF right_IR = Object THEN Left_Pulse
RETURN
Move_Item:
GOSUB Close GOSUB Backward GOSUB Right GOSUB Forward GOSUB Open GOSUB Backward GOSUB Left GOSUB Left
GOTO Look_For_Item
' -----[noparse][[/noparse] Subroutine ]------------------------
Forward_Pulse:
PULSOUT RightServo, RightStop - 140
PULSOUT LeftServo, LeftStop + 140
RETURN
Left_Pulse:
PULSOUT RightServo, RightStop + 40
PULSOUT LeftServo, LeftStop + 40
RETURN
Right_Pulse:
PULSOUT RightServo, RightStop - 40
PULSOUT LeftServo, LeftStop - 40
RETURN
Spin_Pulse:
PULSOUT RightServo, RightStop - 140
PULSOUT LeftServo, LeftStop - 140
RETURN
Forward:
FOR pulses = 0 TO 50
PULSOUT RightServo, RightStop - 140
PULSOUT LeftServo, LeftStop + 140
PAUSE 20
NEXT
RETURN
Backward:
FOR pulses = 0 TO 50
PULSOUT RightServo, RightStop + 140
PULSOUT LeftServo, LeftStop - 140
PAUSE 20
NEXT
RETURN
Left:
FOR pulses 0 TO 50
PULSOUT RightServo, RightStop - 140
PULSOUT LeftServo, LeftStop - 140
PAUSE 20
NEXT
RETURN
Right:
FOR pulses 0 TO 50
PULSOUT RightServo, RightStop + 140
PULSOUT LeftServo, LeftStop + 140
PAUSE 20
NEXT
RETURN
Stay:
PULSOUT RightServo, RightStop
PULSOUT LeftServo, LeftStop
PAUSE 20
RETURN
Read_LR_IRs:
FREQOUT L_IR_out, 1, 38500
left_IR = L_IR_in
FREQOUT R_IR_out, 1, 38500
right_IR = R_IR_in
RETURN
Read_Closing_IR:
FREQOUT Closing_IR_out, 1, 38500
closing_IR = ~Closing_in
RETURN
Open:
FOR pulsewidth = CloseGripper TO OpenGripper STEP 10
PULSOUT GripServo, pulsewidth
PAUSE 20
NEXT
RETURN
Close:
FOR pulsewidth = OpenGripper TO CloseGripper STEP 10
PULSOUT GripServo, pulsewidth
PAUSE 10
NEXT
RETURN
MY Modified Program I'm using
'{$STAMP BS2}
'{$PBASIC 2.5}
' -----[noparse][[/noparse] Program Description ]-----------------
' -----[noparse][[/noparse] I/O Definitions ]---------------------
RightServo CON 12
LeftServo CON 13
GripServo CON 14
LinearActuatorServo CON 15
L_IR_out CON 11
Closing_IR_out CON 10
R_IR_out CON 9
L_IR_in VAR IN11
Closing_IR_in VAR IN10
R_IR_in VAR IN9
' -----[noparse][[/noparse] Constants ]--------------------------
CloseGripper CON 1200
OpenGripper CON 100
CloseActuator CON 800
OpenActuator CON 100
LeftStop CON 750
RightStop CON 750
Object CON 0
NoObject CON 1
' -----[noparse][[/noparse] Varibles ]---------------------------
left_IR VAR Bit
right_IR VAR Bit
closing_IR VAR Bit
pulses VAR Word
pulsewidth VAR Word
' -----[noparse][[/noparse] Initialization ]---------------------
DIR9 = %1 ' I changed this part
DIR10 = %1
DIR11 = %1
' -----[noparse][[/noparse] Main Code ]---------------------------
GOSUB Test_Gripper_System
Test_Gripper_System:
GOSUB Close GOSUB Lift GOSUB Drop GOSUB Open GOSUB Lift GOSUB Close GOSUB Open GOSUB Drop
GOTO Look_For_Item
Look_For_Item:
GOSUB Spin_Pulse
GOSUB Read_LR_IRs
IF right_IR AND left_IR = NoObject THEN Look_For_Item
Center_On_Item:
GOSUB Forward_Pulse
GOSUB Zero_In
GOSUB Read_Closing_IR
IF closing_IR = Object THEN Move_Item
'else
GOTO Center_On_Item
Zero_In:
GOSUB Read_LR_IRs
IF left_IR = Object THEN Right_Pulse
IF right_IR = Object THEN Left_Pulse
RETURN
Move_Item:
GOSUB Close GOSUB Lift
GOSUB Backward GOSUB Right GOSUB Forward GOSUB Stay 'I thought it was strange that there was a Stay in the Subroutine
GOSUB Drop 'but not in the Main Code
GOSUB Open GOSUB Backward GOSUB Left GOSUB Left
GOTO Look_For_Item
' -----[noparse][[/noparse] Subroutine ]------------------------
Forward_Pulse:
PULSOUT RightServo, RightStop - 140
PULSOUT LeftServo, LeftStop + 140
RETURN
Left_Pulse:
PULSOUT RightServo, RightStop + 40
PULSOUT LeftServo, LeftStop + 40
RETURN
Right_Pulse:
PULSOUT RightServo, RightStop - 40
PULSOUT LeftServo, LeftStop - 40
RETURN
Spin_Pulse:
PULSOUT RightServo, RightStop - 140
PULSOUT LeftServo, LeftStop - 140
RETURN
Forward:
FOR pulses = 0 TO 50
PULSOUT RightServo, RightStop - 140
PULSOUT LeftServo, LeftStop + 140
PAUSE 20
NEXT
RETURN
Backward:
FOR pulses = 0 TO 50
PULSOUT RightServo, RightStop + 140
PULSOUT LeftServo, LeftStop - 140
PAUSE 20
NEXT
RETURN
Left:
FOR pulses 0 TO 50
PULSOUT RightServo, RightStop - 140
PULSOUT LeftServo, LeftStop - 140
PAUSE 20
NEXT
RETURN
Right:
FOR pulses 0 TO 50
PULSOUT RightServo, RightStop + 140
PULSOUT LeftServo, LeftStop + 140
PAUSE 20
NEXT
RETURN
Stay:
PULSOUT RightServo, RightStop
PULSOUT LeftServo, LeftStop
PAUSE 20
RETURN
Read_LR_IRs:
FREQOUT L_IR_out, 1, 38500
left_IR = L_IR_in
FREQOUT R_IR_out, 1, 38500
right_IR = R_IR_in
RETURN
Read_Closing_IR:
FREQOUT Closing_IR_out, 1, 38500
closing_IR = ~Closing_in
RETURN
Open:
FOR pulsewidth = CloseGripper TO OpenGripper STEP 10
PULSOUT GripServo, pulsewidth
PAUSE 20
NEXT
RETURN
Close:
FOR pulsewidth = OpenGripper TO CloseGripper STEP 10
PULSOUT GripServo, pulsewidth
PAUSE 10
NEXT
RETURN
Lift:
FOR pulsewidth = CloseActuator TO OpenActuator STEP 1
PULSOUT LinearActuatorServo, pulsewidth
PAUSE 10
NEXT
RETURN
Drop:
FOR pulsewidth = OpenAcuator TO CloseActuator STEP 10
PULSOUT LinearActuatorServo, pulswidth
PAUSE 10
NEXT
RETURN
my sensors arent reading right
·the left IR tells the rightside to slow down instead of speed up and my right IR isnt reading at all

Comments
Try calling the Main code "Main:" I'm not sure if this will help but I see no way to get back to Your Main code with out calling it Main:.
I assume the code compiled OK, I really don't see anything Else wrong on a quick read through.
______$WMc%____________
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Have you made any of the changes suggested? If so, what were those results?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
its as an attachment..... i still have issues with my programming....i no longer have access to a computer with the stamp software.. is there an online version of this software??? if not is its possible to bring my robot to your company??
btw thanks for the help its much appreciated... however my robot is a combination of Vex, Gears, and the BoeBot kits
im entering this robot into the California State Fair....
·so i need to get everything done before Saturday...
my only computer i had access to that had the software·was at my High School
Unfortunately we do not have an online version of the software; so it will be difficult to change any programs.
We don’t have any labs for you to program the robot with either, do you have any friends that you can use their PC? The software is a free download, or you can use a CD to get the software to run so it wouldn’t be hard to install. Just need to have a PC.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
Add debug as suggested to see your error.
FOR pulses 0 TO 50
· DEBUG ? pulse
· PULSOUT RightServo, RightStop - 140
· PULSOUT LeftServo,· LeftStop··- 140
· PAUSE 20
·NEXT
As suggested by forum members - simplify and divide your program to find coding errors.
DEBUG is your friend.
Cheers Vaclav
when i debuged my the pulses i found out that CON 12 turned out to be Malfuntioning... so i rewired everything and debuged my sensors.. AND GUESS WHAT?!?!?!
My Robot Is Fulling Functioning NOW!!!!!
everything is working and thats all thanks to you the parallax members!!!
i dont think i would've got this done in time especiaally the fact i wrote this code practically by myself....
Again I would like to thank everyone who helped this 17 year old High School Student out... It was all very helpfull