Servos have me Stumped!

AlbertZ

Senior Member
Hi
I am working on a robotics project which employs 4 servos operating sequentially. In order to check the operation of the servos and to set the travel limits I wrote a simple little program to perform these operations. Except things are not as simple as they seem. Originally the program was set up to test all 4 servos. But when that didn't work out I whittled it down to test only the widget servo and the black servo. Here is what is happening:

  1. The only servo that seems to initialize is the widget servo.
  2. The black servo remains completely inert; no output on pin B.3.
  3. The same result is obtained using digital or analog servos.
  4. The activeServo variable was added after the fact when the original configuration didn't work. Same result.
  5. In fact, the ONLY pin that shows an output is B.5 (widget) and it operates exactly like it is supposed to

I am at my wits end and frustrated especially after investing many hours building the model. Am I not seeing the forest for the trees or is servo control more complicated than indicated in the manual? Any suggestions will be greatly appreciated.

Code:
'******************Servo Test Code.bas****************
'Version 1.0
'AJZ/December 27, 2015
'this code is used in conjunction with the widget sorter
'code to test and set limts for the servos

'===Outputs===
symbol stack_servo  = B.6	'pushes widgets from stack onto platform 
symbol widget_servo = B.5	'pushes widgets from platform onto conveyor belt
symbol black_servo  = B.3	'pushes widgets from conveyor belt into black widget box	
symbol white_servo  = B.1	'pushes widgets from conveyor belt into white widget box

'===Variables===
symbol pos0 = b0
symbol pos1 = b1
symbol activeServo = b11
'===Directives===
#com 1				'specify serial port
#picaxe 18M2			'specify processor

init:

gosub initialize			'make sure servos are initialize
pause 2000

main:	

gosub widget
pause 1000	
gosub black
pause 1000
'gosub white
'pause 1000
'gosub stack
'pause 1000	
goto main

initialize:
activeServo = black_servo
servo activeServo,100 		'initialise black push servo
activeServo = widget_servo
servo activeServo,80 		'initialise widget serv

'servo white_servo,100 		'initialise white push servo
'servo stack_servo,100		'initialise stack servo
return

widget:
activeServo = widget_servo
for pos0 = 80 to 180 		; move servo to one end
	servopos activeServo, pos0
	pause 2
	next pos0
for pos0 = 180 to 80 step -1	; move servo to other end
 	servopos activeServo,pos0	
	pause 2
	next pos0
return

black:
activeServo = black_servo
for pos1 = 100 to 200 		; move servo to one end
	servopos activeServo, pos1
	pause 2
	next pos1
for pos1 = 200 to 100 step -1	; move servo to other end
 	servopos activeServo ,pos1	
	pause 2
	next pos1
return
 

erco

Senior Member
Check your wiring to all servos, verify they all get power. They should all twitch a bit on powerup. What's your power source? Seperate power for Picaxe and servos? Are you using two filter/decoupling caps, ~.01 uF and ~10 uF? Show photos/videos of your setup.

Also try this simplified code which slows your servos way down (pause 20 instead of pause 2)

Code:
'******************Servo Test Code.bas****************
'Version 1.0
'AJZ/December 27, 2015
'this code is used in conjunction with the widget sorter
'code to test and set limts for the servos

'===Outputs===
'symbol stack_servo  = B.6	'pushes widgets from stack onto platform 
'symbol widget_servo = B.5	'pushes widgets from platform onto conveyor belt
'symbol black_servo  = B.3	'pushes widgets from conveyor belt into black widget box	
'symbol white_servo  = B.1	'pushes widgets from conveyor belt into white widget box

'===Directives===
#com 1				'specify serial port
#picaxe 18M2			'specify processor

' initialize
pause 500               'always start with a pause to wait out servos' current spike on powerup
servo b.3,100 		'initialise black push servo
servo b.5,80 		'initialise widget servo

main:	
gosub widget
pause 1000	
gosub black
pause 1000
'gosub white
'pause 1000
'gosub stack
'pause 1000	
goto main


widget:
for b0 = 80 to 180 		; move servo to one end
	servopos b.5, b0
	pause 20
	next
for b0 = 180 to 80 step -1	; move servo to other end
 	servopos b.5,b0	
	pause 20
	next
	
return

black:
for b1 = 100 to 200 		; move servo to one end
	servopos b.3, b1
	pause 20
	next
for b1 = 200 to 100 step -1	; move servo to other end
 	servopos b.3,b1	
	pause 20
	next
return
 
Last edited:

AlbertZ

Senior Member
Thanks erco!

I followed your advise, got out the DVM and started checking connections. I found that pins B.3 & B.1 had a solder bridge to ground :mad: in addition the center pin on J12 (connector to black servo) had a cold solder joint to the 6 volt bus :confused:

I fixed these issues and voila! my code is running like I envisioned it would - very smooth, no glitches. I was so locked in on a software solution that I overlooked the obvious. I am a very happy camper! :cool:
 
Top