Servo motor help please :)

Gazar94

New Member
Servo Motor
Hi i have a servo motor with a picaxe 28X (serial mode) and i am using it to rotate a carousel that will dispense items at the correct time. To do this I am using a AEX033 LCD with clock upgrade to provide the timer pulse
(https://www.techsupplies.co.uk/epages/Store.sf/sec2ae0184280/?ObjectPath=/Shops/Store.TechSupplies/Products/AXE033)
I have got it working going forward but cant get the motor to turn back i.e.

Code:
pause 500
serout 7,N2400, (253,9,"00:00:15        ")
pause 1000
for b0 = 40 to 240 step 48
servo 1,b0
pause 500
serout 7,N2400, (253,1,"Harry Gill      ")
pause 1000

main:
serout 7,N2400, (1)
pause 490
serout 7,N2400, (0)
pause 10
if pin0  = 1 then move
goto main

move:
high 0
pause 1000
low 0
pause 5000
goto main

start:
if b0 = 240 then restart
next b0
pause 5000
goto main

restart:
servo 0,40
pause 5000 
goto main

[code]

it wont follow the return code and the servo is not moving the correct amount (seems under powered)

this is my first post so if i missed anything please ask
thanks in advance for your help :)
 

srnet

Senior Member
I think people will have trouble visualising what it is you are trying to do here.

So a circuit diagram, mechanical details, weight of the carousel, and what type of servo you are using are going to help.
 

eclectic

Moderator
Welcome to the Forum.

A couple of points.

1. Just for completeness, can you provide details on your Servo?
2. Please post your circuit diagram.

3.Your limits 40 -240 seem high.
See Manual 2, page 211

There are many servo experts here, (not me)
and I'm sure you'll get good advice soon.

e
 

srnet

Senior Member
Indeed, manual 2 does say;

"Do not use a pulse value less than 75 or greater than 225, as this may cause the servo to malfunction"
 

westaust55

Moderator
As a starting point, you have a loop structure with:
For b0 = 40 to 240 step 48
To check, just prior to the line Next b0 you have
If b0 = 240 Then restart
Which is intended to return the servo to the initial position.
But b0 from 40 in steps of 48 will not exactly equal 240 so does not at any time go to the restart routine.

Once the For...Next loop does itself complete the program returns to the label Main: within the For...Next loop and so again does not function correctly.



Furthermore, I am curious which PICAXE you are using.
You have the label Restart:
but for M2 parts, RESTART is a command and thus the Programming Editor will throw up a syntax error at the line:
If b0 = 240 Then restart

Funnily the PE V5.4.3 also gives a syntax error for that same line for larger M, X, X1 and X2 parts as well (likely it should not as RESTART is only an M2 command but that may be a PE matter).

Your program therefore is in need of some review as to it's structure.

Maybe if you explain in step by step plain English gown the project is to function then folks here can better help.
 
Last edited:

westaust55

Moderator
Okay your program is even more confusing when I have a closer look.
Is the code you have posted your complete code with the servo working ???

As the code posted is:


After working down through some initial commands to the Main: label
It loops around in the looping structure of 7 lines waiting for input 0 to go high.

When input 0 does go high the program jumps to the label Move:
Output 0 is made high then low for a period and then jumps back to Main:

You have a label Start: but the code has no way of getting to that label.
Hence the program line next b0 is never reached.


Please post the full code that you have working but does not allow the servo to return.
 

Gazar94

New Member
Sorry for the lack of info guys
here is the ideal circuit diagram but at the moment I have no switches LED or Piezo sounder as I am just trying to get this part to work
View attachment 9796
I am making a pill dispenser that will dispaense pills at a set time. so to do this i have made a carousel system with lots of compartments that will rotate using the servo motor because it can turn in set intervals this will allow the pills to fall out of each compartment under gravity. The final program should make the servo rotate one compartment (separated by 12 degrees) every time the LCD/Clock module sends a pulse. But for now just to test it i have set the alarm for every 15 seconds, so at the moment the servo should move 12 degrees every 15 seconds, that is what I want. but the servo seems "underpowered" and does not seem to rotate as far as it should, only 2-3 degrees when it should be 12. I also dont know how to make it rotate back to the start once it has got to the end of its cycle.
(this is the basic function pictures are just ideas its still a work in progress)
View attachment 9797

Im using a picaxe 28X and a 'standard' servo motor (http://www.amazon.co.uk/TOP-LINE-STANDARD-SERVO-RS-JR/dp/B002QS2FHK/ref=sr_1_1?ie=UTF8&qid=1323806486&sr=8-1)
the code in the first post is the whole code. It works fine I know that because I have tasted it with this
Code:
rotate:
pause 2000
servo 0,36
pause 2000
servo 0,47
pause 2000
servo 0,60
pause 2000
servo 0,73
pause 2000
servo 0,86
pause 2000
servo 0,99
pause 2000
servo 0,114	
pause 2000
servo 0,128	
pause 2000
servo 0,143	
pause 2000
servo 0,158	
pause 2000
servo 0,172
pause 2000
servo 0,186	
pause 2000
servo 0,200	
pause 2000
servo 0,213	
pause 2000
servo 0,226	
pause 2000
servo 0,238
pause 2000
servo 0,251	
goto rotate

[code]

it would be similar to this (http://www.youtube.com/watch?v=yUoQOHXkKzM)

hope this helps :)
thanks for you help
if there is anything i have missed please ask I would be happy to tell you :)
 

Attachments

Technical

Technical Support
Staff member
servos will not generally work correctly with values <75 or >225 - does the '26' or '251' values actually really work? Most servos only have 180 degree motion, but your pill dispenser seems to want more than 180 rotation?
 

eclectic

Moderator
servos will not generally work correctly with values <75 or >225 - does the '26' or '251' values actually really work? Most servos only have 180 degree motion, but your pill dispenser seems to want more than 180 rotation?
My Futaba certainly doesn't like those values. :-(

Gazar, I've just tried this using a 28X2,
but you can just change it to 28X

Code:
#picaxe 28X2 ; change to your Picaxe

rotate:

For b0 = 36 to 252 step 12
Servo 0, b0
sertxd ("step = ",#b0, CR,LF)

pause 2000

next

goto rotate
Watch and listen.

e
 

srnet

Senior Member
Not many servos would have 180 degrees of rotation, 90 to 100 degrees is common, some maybe up to 135 degrees.

Assuming you stay within the normal servo limits of a 1-2ms pulse.
 

srnet

Senior Member
Incidently there are servos specially designed for 360 degree rotation, and some will rotate multiple times even, used in RC sailboats and the like.
 

erco

Senior Member
Servos glitch when you power them down and wake them up, which could drop your pills early. A geared stepper motor might be a better choice here, which could go the full 360 degrees.
 

westaust55

Moderator
And if yours doesn't rotate fully you can just use gears external to the servo to produce a full rotation.
Gearing up to achieve greater degree of rotation will also reduce the output torque at the final gear.
This would seemingly not be an ideal situation with the existing Servo if the perceived ability to rotate the carousel is already weak/poor.
 

srnet

Senior Member
The report of the servos apparently not having enough power, i.e. not rotating far enough, would give a specific set of symptoms.

If you change the pulse of a servo such that it wants to rotate 12 degrees, but its not strong enough and only rotates 2 or 3 degrees then the servo will make a noise as its straining to get to its new position (12 degrees). Until it moves 12 degrees its always going to be out of position and will continue to strain to move.

Give it another command to move to 24 degrees and its notgoing to move another 2 or 3 degrees, its already considerably out of position and being a bit more out of position makes no difference.

So a servo only moving 2-3 degrees when its thought it should be moving 12 degrees, is likely behaving that way because its only being told to move 2 or 3 degrees.
 

srnet

Senior Member
The report of the servos apparently not having enough power, i.e. not rotating far enough, would give a specific set of symptoms.

If you change the pulse of a servo such that it wants to rotate 12 degrees, but its not strong enough and only rotates 2 or 3 degrees then the servo will make a noise as its straining to get to its new position (12 degrees). Until it moves 12 degrees its always going to be out of position and will continue to strain to move and make an obvious noise.

Give it another command to move to 24 degrees and its not going to move another 2 or 3 degrees, its already considerably out of position and being a bit more out of position makes no difference.

So a servo only moving 2-3 degrees when its thought it should be moving 12 degrees, is likely behaving that way because its only being told to move 2 or 3 degrees.
 
Top