quick Q. on servos

rob nash

Senior Member
hello,,
can anyone tell me if tech sup..servo gbx011 is already modified for
continous rotation,,,and does it come wth wheels i,m a little confused???
(it does,nt take alot guys)... and has anyone any feed back usin them for continus rotation,,


also would programme line like this produce full rotation

SERVOPOS 0,257 'MOVE FORWARD
PAUSE 200
 

hippy

Ex-Staff (retired)
GBX011 is not modified for continuous rotation, nor provided with wheels. GBX012 is what you want but currently out of stock at tech-supplies.
 

rob nash

Senior Member
THANKS for clearing that up,, does your crystal ball see when they may have the other gbx12,,
thanks hippy
 

Technical

Technical Support
Staff member
GBX012 are expected back into stock later this week.

A value of 150ish (experiment) gives off - 75 forward max and 225 reverse max.

These numbers do vary with different motors and different PICAXE chips so a bit of experimentation is required.
 

westaust55

Moderator
also would programme line like this produce full rotation

SERVOPOS 0,257 'MOVE FORWARD
PAUSE 200
believe the position value cannot exceed 255, so if accepted by the PE, the 257 may end up rolling over as a value like 1.

Some servo's will not operate at all, if the value sent is outside the range accepted by the Servo electronics. Better to satrt with a value closer to the mid value (150 ish) and gradually try greater values form there. the greater the difference from the mid value, the faster the motor with turn.
 

BeanieBots

Moderator
Just to add a little more.
Servo position demands are 'typically' limited to 75 either side of the nominal center which is typically 150. That is, limited to the range 75 to 225.

The servopos command alone will not make a servo (modified or not) move.
The servo pulses must first be initated with a "servo" command.
Servopos is then used to update the demand value without causing a reset (and hence glitches) of the counter used to generate those pulses which would happen if new "servo" commands were sent too frequently.
 

rob nash

Senior Member
thanks all for the feed back,, this is my first servo project,, hving lots of fun
three servos sanwa 102
picaxe 28*2
three 100k pots
3 AA for pic
4.8v 600mah recharge for servo work better than 4 AA,,

programme so far,,
#picaxe 28x2

' Converted by X2 Conversion Wizard Version 1.0.2

let dirsB = %11111111
let adcsetup = 3 ' change to %00000111 on 3V parts


servo b.0,150
servo b.1,150 'initiate servo on OP 1 to neutral position
servo b.2,150

main: if pinC.0=1 then moe
low b.4
goto main

moe:

high B.4
readadc 2,b2
readadc 1,b1
readADC 0,b0 'read stick position on IP 0.
b1=b1*10/17+75
b0=b0*10/17+75 'scale 0 to 255 to be 75 to 225
b2=b2*10/17+75
servopos b.0,b2
servopos B.1,b0
servopos b.2,b1 'send new value to servo on OP 1
pause 10 'small delay to prevent excessive updates.
goto main


it work well,, but must confess i still don,t under stand the maths
i found the example b1= b1*10/17=75 and added to that (i,m sure it was
bb from an early threadso thank u bb)

would someone please explain the maths thx,
my Q. how do i make the servo sweep from 75 to 210
 

Attachments

hippy

Ex-Staff (retired)
b1= b1*10/17=75

First convert b1 so it's a value 0 to 1, ignoring the fact a PICAXE cannot do decimals. The range you are reading is 0 to 255, so so far ...

result = b1 / 255

Then we need to convert 0 to 1 to 75 to 225. If we subtract 75 from that we need to convert 0 to 1 to 0 to 150, so we have ...

result = b1 / 255 * 150

Then we add the 75 on, so result is 75 to 150+75 (225) ..

result = b1 / 255 * 150 + 75

Unfortunately because the PICAXE cannot do decimals 'b1/255*150' doesn't work, but that's the same as ...

result = b1 * 150 / 255 + 75

The "150/255" is 0.58, divide both by 5 gives 30/51, also 0.58, divide both by 3 gives 10/17, and voila ...

result = b1 * 10 / 17 + 75
 

BeanieBots

Moderator
First off, Hippy is spot on but I find his explanation a little confusing myself so I'll offer my explanation as well.

The servo needs a 'number' between 75 and 225, the ADC returns a number between 0 and 255.

The difference between 75 and 225 is 150.
To convert 255 to 150 we need to divide by 1.7
PICAXE can't do decimals so we need to mulliply by 10 then divide by 17.
Finally, add in the 75 offset.
Hence, 0 to 255 gets converted to 75 to 225 by b0=b0*10/17+75.

You mention that your POTs are 100k.
This is out of spec for the ADC inputs and may give you problems.
(in particular, a different reading with/without programming cable plugged in)
It would be much better to use 10k POTs.
 

mickm2au

Member
Also, if you don't have the full pot rotation to work with to generate full servo range then you can use this code to set up the amount of pot rotation to give full servo travel, just need to add a push button switch to earth on a pin (pin3 in my case). It can be recalibrated at any time with a series of button presses without having to reprogram the chip. The full code and circuit using an 08M are in my rudder indicator project in the finished project forum.

Cheers,
Mick


Code:
IF pin3 = 0 Then Setup		'If push button closed at power up, goto Setup

Main:  
        Read 2, B0				'Get the minimum adc reading from memory
 	Read 3, B1				'Get the adc range to servo range multiplier from memory
 	Readadc 4, B4			'Read the present pot position
 	Pause 20
 	
 	IF B4 < B0 Then Let B4 = B0	'Prevents rollover below zero in next line if for some reason
 						'the pot moves past the original calibrated range
 		End IF			
 		
 	B3 = B4 - B0			'Remove the min value from the adc value 
 	W6 = B3 * B1 / 100 + 75		'Convert the adc value to the equivalent servo value
 	
 	
  						
 	IF W6 > 225 Then let W6 = 225	'Limits max servo value to 225 if for some reason the pot moves
 	 					'past the original calibrated range
 		End If			
 	
 					
 	Servopos 1, W6			'Send the servo value
 	
 	
 	
 	Goto Main

Setup:
                Gosub Delay1		'Wait for switch to be released
		Gosub Wait_Loop		'Wait for switch to be repressed after pot moved to low end
 	 	
 	Readadc 4, B0			'Read adc for pot at lowest end
 	Write 2, B0 			'Write this value to fixed memory
 	Servo 1, 75				'Move servo to full low position
 	Servopos 1, 75
 	
 		Gosub Delay1		'Wait for switch to be released
 	
 		Gosub Wait_Loop		'Wait for switch to be repressed after pot moved to high end			
 	
 	Readadc 4, B1			'Read adc for pot at high end
 	Servo 1, 225			'Move servo to full high position
 	Servopos 1, 225
 	
 	
 	B2 = B1 - B0			'Remove lowest adc value  from the actual adc value
 	B3 = 15000 / B2			'Calculate a multiplier to 2 decimal places for the actual adc range 
 						'to cover the servo range of 150 micro secs (180 deg) times by 100 to make a 
 						'whole number  
 	Write 3 , B3			'Write this value to fixed memory
 	
 		Gosub Delay1		'Wait for switch to be released
 	
 	Goto Main			'Start main loop
 	 	 	
  	
  	
  	'Gosubs
 	'******
 	
Delay1:

	IF pin3 = 0 Then Delay1		'Switch closed
 	Pause 500
 	
 	Return 
 	
 	
Wait_Loop:
 	
 	
 	IF pin3 = 1 Then Wait_Loop	'Switch open
 	Pause 500
 	
 	Return
 
Last edited:
Top