I've done a little research, but could use some guidance on which direction I should take in order to achieve what I'm trying to do. I want to create an application where the user can control the rotation of a 360 degree turning platform. I was able to create a 180 degree rotation with Processing 2 for the inputs to send to the Arduino board using a Micro Servo FS90.
Something like this in Processing:
if (keyPressed) {
if (keyCode == 'RIGHT') {
if (spos > 180) {
spos = spos;
update(spos);
}
else {
spos = spos + 1;
update(spos);
}
}
else if (keyCode == 'LEFT') {
if (spos < 0) {
spos = spos;
update(spos);
}
else {
spos = spos - 1;
update(spos);
}
}
}
else {
spos = spos;
}
}
void update(int x)
{
if (spos > 0 && spos < 180) {
spos= x;
}
else {
spos = spos; }
//Output the servo position ( from 0 to 180)
port.write("t"+spos);
Arduino code loop section that takes Processing info
void loop() {
static int v = 0;
if ( Serial.available()) {
char ch = Serial.read();
switch(ch) {
case '0'...'9':
v = v * 10 + ch - '0' ;
break;
case 't':
servo1.write(v);
v = 0;
break;
}
}
}
It worked well for the 180 degree turning; now I want to do it with 360 degree turning. If I bought a 360 degree rotation servo, will it do what I need it to do or will it just be continuous? Should I get a stepper motor instead?
If I bought a 360 degree rotation servo, will it do what I need it to do or will it just be continuous?
Not actually knowing what you bought, the best answer is maybe or maybe not. Below is some servo test cod you can use to see what the servo does.
// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.
String readString;
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
Serial.begin(9600);
myservo.writeMicroseconds(1500); //set initial servo position if desired
myservo.attach(7, 500, 2500); //the pin for the servo control, and range if desired
Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
Serial.println(readString); //so you can see the captured string
int n = readString.toInt(); //convert readString into a number
// auto select appropriate value, copied from someone elses code.
if(n >= 500)
{
Serial.print("writing Microseconds: ");
Serial.println(n);
myservo.writeMicroseconds(n);
}
else
{
Serial.print("writing Angle: ");
Serial.println(n);
myservo.write(n);
}
readString=""; //empty for next input
}
}
If you can find a servo that actually has 360 degrees of travel, it'll work under the same principle as the 180. The issue, as you surmise, is that it can be hard to tell from a vendor's web site whether it's what you want or a continuous servo. Sail winch servos could be a good choice in this case to make sure of what you're getting.
Even then, will you be ok if going from 359 to 1 means traversing 358 degrees? If not, perhaps a stepper would be better.
A stepper would, I think, be better for that. I know of no servos that will travel 360°. With a continuous servo the rate of turning is controlled, not the angle. With a stepper you can control rate and angle easily.
groundfungus:
A stepper would, I think, be better for that. I know of no servos that will travel 360°. With a continuous servo the rate of turning is controlled, not the angle. With a stepper you can control rate and angle easily.
Sail winch servos like below have some extra features. Higher end programmable digital servos also have extra features.
My current servo will only go 180 degrees. Basically it increases / decreases the degree by 1 as the user holds RIGHT or LEFT. I'd change the max degree to 359 and the min degree to 1. So once it hit 1 degree, it wouldn't move left (or decrease) anymore. If the degree is at 359, it wont turn right anymore (or increase).
Does anyone have any recommendations on servos and / or a stepper for this type of project?
Sail Winch servo?
Thank you all so much for your help! Great community.
See reply #9. Look at the stepper library that comes with the IDE. I shows drivers for both bipolar and unipolar drivers. Just one chip and maybe a couple transistors and resistors for either.