NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Sensors, Actuators, and Robotics » Servo Control
May 04, 2009 by Dryak |
I'm looking to create a simple program that loops making the servo turn from left to right, but I don't know what libraries include. I've got a pretty good programming background, but I've never programmed hardware before so I don't know where the resources for servo libraries would be. |
---|---|
May 05, 2009 by DonNYC |
Have a look at the Servo Squirter code. |
May 06, 2009 by Dryak |
Can someone explain the code to me? Its not exactly commented the best so I don't know what its doing. |
July 28, 2009 by BoloBit64 |
the first part of the code void pwm_int is to setup the timing for the servo. All the definintions can be found in the AVR datasheet in Chapter 14. It explains how it changes the milliseconds to get a faster, 1 ms, or slower, 20 ms, reponse time. Next is int main. the first part is to tell the lcd what to display, in this case " Nerdkits ServoSquirter". then it connects the serial port, then it sets DDRB, Chapter 13.4 in AVR datasheet for specifics, pins 2 and 3 to control the direction of the servo. After that, its activates the PWM mode where the Displays the position of the PWM. Then, using the uart, set the bounderies of the servo. When you reach thoughs boundaries it sends the character to the serial port. the Next part checks the boundaries of the servo and makes sure it doesn't go to far. And the last bit of code sends the position to serial port. I hoped this helped anyone still wondering. |
September 09, 2009 by Nerdful_com |
Anyone have a basic sample code (no UART, no LCD, etc) that just moves a hobby servo to say 3 positions (like all the way left, all the right and centered)? Nerdful.com |
October 07, 2009 by lcruz007 |
I wrote a simple program that will work like you want (the servo moves from left to right, in an infinite loop, but a 25 seconds loop is always repeating)... I will post it here in a separate post. Hope you find it helpful. |
October 07, 2009 by lcruz007 |
|
January 13, 2010 by mongo |
I just tried out a few things last night with the servo squirter project. The code was simple enough but boy did I have trouble getting anything out of it... I copied and pasted the makefile from the traffic light project and edited it to the servo squirter filenames. A word to the wise... And the rest too - double check your spelling and typos. Next time, I am just going to use copy and replace globally. At any rate, I did get it working. I had a couple of Futaba servos sitting in a box and once I got the program figured out, changing the variables and adding different parameters went pretty easily. I added more keyboard characters for stepping in smaller increments as well as full sweep and center positions. Now I need to find a use for something like this. I am also looking ino adapting the setup for two servos. More on that when it happens. Mongo |
May 20, 2011 by Rachid |
I have Parallalax Continuous Rotation Servo. I have used it in the past with basic stamp. I tried using in the servosquirter but it just keep spining. The servo was centered with the basic stamp FOR temp = 0 TO 200 PULSOUT servo_pin,750 //center 1.5ms PAUSE 20 NEXT FOR temp = 0 TO 200 PULSOUT servo_pin,900// forward PAUSE 20 NEXT FOR temp = 0 TO 200 PULSOUT servo_pin,600 //reverse PAUSE 20 NEXT |
May 25, 2011 by Ralphxyz |
Rachid, is this the continuous rotation servo you have? I have not played around with any servos much and now I need the continuous rotation. I have the Parallax (Futaba S148). Did you get yours working? I was just going to ask what a pulse is. Can I just pull a pin high on the mcu for a period then off and call that a pulse? I quickly looked at the Basic Stamp code but have not seen what PULSEOUT actually does. So I sure would appreciate any guidance. Ralph |
May 25, 2011 by Rachid |
Ralphxyz, yes I have the Parallax (Futaba S148). I centered it by adjusting the pot with 1.5ms pulse to use it with the basic stamp. basic stamp has a command to send pulses so saying PULSOUT 650 the servo will move backwards and PULSOUT 850 will move it forward. 750 corresponds to 1.5ms pulses. BTW it is PULSOUT and not PULSEOUT. I tried using the same servo with Nerdkit and all it does is spin forward. I tried doing what you said instead by just pulling a pin high and low and use delays but same result. I am going to back to the basic stamp and see if I can make the servo just move a fraction instead having a loop of 200. My guess is this type of servo is not the right one for this experiment |
May 26, 2011 by Ralphxyz |
Is the BASIC Stap using PWM? I see this note "setup your pulse generator to 1.5 ms at 20ms intervals" but I am not sure how to implement that. re: "My guess is this type of servo is not the right one for this experiment". What exactly are you trying to do? I want to use this servo to rotate my compass just for testing and calibration. Ralph |
May 26, 2011 by Rachid |
The PULSOUT command can be used to send a pulse (a very brief high signal) using a BASIC Stamp I/O pin. Here is the command syntax for the PULSOUT command: PULSOUT pin, duration. To setup the pulse gen for 1.5ms divide 1.5ms by 2us and that s equal 750 and then send the following command PULSOUT pin 750 and that would send pulses of 1.5ms every 20ms. so if you want to send 1ms pulses then 1ms/2us and so on. The servo works fine for the basic stamp kit but when I try to use it with the servosquirter all I get is full turns. I should be able to go from rest(1.5ms) and move fraction forward and fraction backwards. I wonder what servos Mongo used for his experiment...I will keep you posted if I learn anything |
Please log in to post a reply.
Did you know that essentially all power supplies' voltages drop when current is drawn from them? Learn more...
|