A few newbie questions about the PICAXE-08 Servo Driver Board

sirdakka

New Member
You seem to have forgotten the advice about using servopos.

Can you tell us what behaviour you expected, and what actually happens instead? 200mS doesn't seem a very long pause between repositions.
Hi Rossko,

I want to set up my servo controller to switch between two configurations, lever unlocked (LEVER_POS_UL) and lever locked (LEVER_POS_L) when the power is cycled.

If the servo controller is in the LEVER_POS_UL configuration, I want the servo controller to be able to react to two different inputs, on pins C.3 and C.4. If a high input on pin C.3 is detected, I want the bottom loop to run (whereby the spout servo goes from OUT to IN and then OUT again, then the lever servo goes from L to UL and back to L), and if an input on pin C.4 is detected I just want the lever servo to go from L to UL and back to L.

I'll play around with the timings if you think 200ms is too short a time between repositionings.

Many thanks for the suggestion
 

sirdakka

New Member
Ok, I've replaced all instances apart from the first with Servopos. I've also extended the pause in If cause dependant on pinC.4 input to 1000. However, I'm still not getting the correct responses. Is my syntax correct?

Code:
#Picaxe 08M2

; Servo Control script in conjunction with Arduino- controlled 
; Cued Lever Behavioural paradigm

;servo1 controls the spout, BRO
;servo2 controls the lever, BGY
;correct as of 29/7/15

Symbol LEVER_SERVO   = C.1
Symbol SPOUT_SERVO   = C.2
Symbol LEVER_POS_UL = 100 	    ;unlocked position
Symbol LEVER_POS_L = 150 	      ;locked position
Symbol SPOUT_POS_IN = 100 	    ;spout in
Symbol SPOUT_POS_OUT = 150 	;spout away
Input C.4				

Eeprom 0,(1)

Servo SPOUT_SERVO, SPOUT_POS_OUT

Read 0, b0		; Power cycle to switch between lever locked positions
If b0 = 1 Then
	Servo LEVER_SERVO, LEVER_POS_L
	Write 0, 2
Else
	Servo LEVER_SERVO, LEVER_POS_UL
	Write 0, 1
End If

Do

	If pinC.4 = 1 Then	; If ServoReset HIGH detected then...
		Read 0, b0
		
		If b0 = 1 Then	;  If LEVER_SERVO in UL position then...
			Servopos LEVER_SERVO, LEVER_POS_L
			Pause 1000
			Servopos LEVER_SERVO, LEVER_POS_UL
		End If
		
	End If
	
	If pinC.3 = 1 Then	; If RewardSignalOut HIGH detected then...
		Read 0, b0
		
		If b0 = 1 Then	; If LEVER_SERVO in UL position then...
			Servopos SPOUT_SERVO, SPOUT_POS_IN
			Pause 2000
			Servopos SPOUT_SERVO, SPOUT_POS_OUT
			Pause 1000
			Servopos LEVER_SERVO, LEVER_POS_L
			Pause 500
			Servopos LEVER_SERVO, LEVER_POS_UL
		End If
		
	End If
	

	
	Pause 500
	
Loop
 

sirdakka

New Member
Ok, again me being silly, remember to have pull-down or pull-up resistors when changing an output pin to an input!
 
Top