Why does this simple code skips sub routines?

All,

I can’t figure out why this code works great while I have it connected to the Maestro control center and flat out doesn’t work except for the 1st subroutine when it is disconnected from control center.
The servo motor will “jerk” for a quick second while my had is over the IR sensor and the program will return to the main loop. All sensors, switches and servos function properly when manually toggled in the control center. I’m using the 6 channel micro Maestro with the following code:

#0 Servo	:Door Servo 
#1 Input 	:Lower Micro Switch
#2 Input	:Upper Micro Switch
#3 Input	:Inside IR Sensor
#4 Input	:Outside IR Sensor

### Main Sequence ###
6000 0 servo
Main:
Begin
3 get_position		#Monitor inside IR sensor for activity
	360 greater_than		#Open door if IR sensor is made
		If	
		Open_Door
		Stop_Motor
		2000 delay
		Close_Door
		Stop_Motor
		Endif

	
4 get_position		#Monitor outside IR sensor for activity
	360 greater_than		#Open door if IR sensor is made
		If
		Open_Door
		Stop_Motor
		2000 delay
		Close_Door
		Stop_Motor
		Endif
Repeat
Quit


#----------------Subroutines-----------------#

# Open Door
sub Open_Door
8000 0 servo			#Rotates motor Clock Wise (opens door)
	50 delay
	begin
		2 get_position	#Check if upper switch is made
		100 delay
		40 less_than
			If
			return
			Endif
	repeat
return

# Close Door
sub Close_Door
5000 0 servo			#Rotates motor Counter Clock Wise (lowers door)
50 delay
begin
		1 get_position	#Check if lower switch is made
		100 delay
		40 less_than
			If	
			return
			Endif
repeat
	return

# Stop Motor
sub Stop_Motor
50 delay
6000 0 servo			#Stops motor
return

Settings Advanced pulse control:
servos avaliable: 6
Period (ms): 32

UART fixed baud rate = 9600

Please any help would be much appreciated! Thanks!

-Jp-

Never mind… I think I figured out my issue… I was using a 12V 1A power supply branching off and stepping it down to 5V to power all sensors and soldered a jumper wire to power the Maestro . It seems that there is not enough power (amps) to power all devices at once. When I triggered the IR sensor the servo motor(12V windshield wiper motor hooked to Vantec Speed controller) would shutter/jump while the Maestro would blink red 4 times. The LED on the board would then reset itself back to green until the IR sensor was triggered again and the process would repeat. Once I unsoldered the jumper wire and added a seperate 5V power supply to the Vin pin on the Maestro everything started to work. I know this is a rookie mistake but hope it might help someone in the future diagnosing a similar issue.

Thanks,

-Jp-

Hello.

I am glad you got everything working; thanks for explaining what the issue was.

-Jon