2-Axis bot with laser pointers - servo driven

This is a project to have a little pointer in a diorama beam laser spots around. I just got my new UNO yesterday, it's astonishing to see it slewing a servo back and forth on my fifth or sixth program - wow, that was easy! Now to slow it down by dividing the 1-degree angle increments with delays...

Let's see if this thing will allow me to post a picture:

The model looks like this so far:

Nice hardware!

video video !!

You may be new to Arduino, but if I had to guess, I would say you probably have prior experience building electromechanical devices. :wink: I was interested in your post because I also have incorporated lasers pointers into Arduino projects. If your going to slow the motion down with delays, you may want to consider taking it a step further. If the device is intended to move to and stop at discrete points as opposed to having a continuous motion, perhaps you could add acceleration and deceleration periods. I have seen many projects that involve servo controlled motion that simply jump from motionless states to full speed movement followed by an abrupt instantaneous stop. Its not likely to be an issue in your project because of the very sturdy looking construction, but in others the lack of consideration for the laws of physics causes excessive wobbling and stress on parts. If you are projecting a laser point, small amounts of wobble at the source will result in exaggerated wobble of the dot. Just like a slightly shaky hand can cause a laser dot at a distance to wonder within a radius of feet of the target. Just something to consider. I look forward to seeing more updates.

Thanks for the encouragement. After playing with it a while, I see how out of my depth I am about programming C++. I need some school!

Lasers might be a jitter amplifier, yes. I thought maybe I could turn them on when the thing is at a stop, or during smooth transitions. Testing needed.

But here's a vid on utube with just the transmitter driving.

Hi, nice work I like it a lot, I never used such a good structure to drive my motors :slight_smile: During the last test with my accelerometer I shot this video

so you can see how cool your is :slight_smile:
I am planning to shoot another video of the same work but working with writeMicroseconds because I can have a smoother movement. I have a couple of futaba s3003 servo. With a bit of trial and error I have decided that those motors start from 500ms till 2400ms, centered in 1450, but I could be wrong. The only method I know is to try, verify and try again.

When moving in degrees or microseconds you can slow the servos by putting a delay between every step. I think that you can use up to 15milliseconds if you move in degrees or up to 2 in microseconds, but those values depens from motor to motor.

Fede

ps: wich motors / servos do you use?

@ Federico

That is pretty cool! I need to do some experimentation with an accelerometer later. :slight_smile:

Servos are Futaba BLS451 and S9254. Brushless and coreless - similar size to S3003 I think but with the coreless motor they will last much longer (and they cost a lot more!) At same size I'll replace the S9254 with a BLS type to get brushless.

Federico, your accelerometer program is great!

I started to experiment because I have seen that there are not so many howto's about accelerometers and I have found that somethimes they are wrong too ::slight_smile: Right now I am working on the same thing but with less error in reading, hopefully less jitter and so on. Code is starting to be huge :o
But I like that turret and could be cool on my project too. In truth I don't have any final usage, I'd wish to go into robotics but for the projects I like servos are way expensive so I was using this as a training...

Damn your motos are COOL. Mine are http://www.servocity.com/html/s3003_servo_standard.html, way more economical! I was reading this post with my brother that helps me with C code and he said "now i understand why his movements are so smooth and ours are not!" :slight_smile:

by the way, I am noticing that those s3003 servos have some jitter by thefault, this is driving me crazy because sometimes I don't understand if it's our code or it's the servo. They are ok only for testing or for limited applications...

Nice! Well, how did you make the animated sketch? AutoCAD?

The "solid model" was made in the program SolidWorks. You can drag things around pivots within the program. http://www.youtube.com/watch?v=rToTqHKBxC8

This is the current code I'm working with. It has comments, but I'm still trying to really understand what's going on. (I got this from someone who helps me with programming.) And the video link below that of first the code running an HS56 servo, then one axis (Elevation) connected on my hardware - you can see it needs some mechanical damping, but I know how to do that.

#include <Servo.h>
#define NUMPOINTS 10 //Number of points to navigate to
#define AZ 0 //Where in the point the azimuth is stored
#define EL 1 //Where in the point the elevation is stored
#define TIME 2 //Where in the point the time is stored

Servo azServo; //Create a class instance to hold the azimuth servo
Servo elServo; //Create a class instance to hold the elevation servo

const int points[NUMPOINTS][3] = { //put the data into the points array
{800, 1850, 500}, //declared as const int so it is stored in program memory as opposed to ram
{840, 1600, 500},
{860, 1350, 500},
{900, 1321, 500},
{1000, 1290, 400},
{1100, 1330, 400},
{1150, 1400, 400},
{1150, 1350, 400},
{1250, 1321, 400},
{1300, 1290, 400},
};

void updateServos();
void printMillis();

//runs once at the begining of the program
void setup()
{
azServo.attach(9); //attach the servo on pin 9 to the azimuth instance.
elServo.attach(10); //attach the servo on pin 10 to the elevation instance.
Serial.begin(9600); //open the serial port at 9600 bps:
}

//main program loop
void loop()
{
updateServos();
printMillis();
}

//Updates both servos to the current point
void updateServos()
{
static unsigned long timer = 0; //timer variable
static int currentPoint = 0; //The point that the servos will be set to
if(millis() > timer) //Check if its time to update the servos
{
azServo.writeMicroseconds(points[currentPoint][AZ]); //set the asimuth servo. the writeMicroseconds function lets you control the pulse instead of setting the degrees
elServo.writeMicroseconds(points[currentPoint][EL]); //set the elevation servo.
timer = millis() + points[currentPoint][TIME]; //set the timer to however long the point specifies
currentPoint++; //increments to the next point in the list
if(currentPoint >= NUMPOINTS) //if points have run out rest to the first one
{
currentPoint = 0;
}
}
}

void printMillis()
{
static unsigned long timer =0;
if(millis()>timer)
{
Serial.print(millis());
Serial.print("\n");
timer = millis()+500;
}
}

Dale Emery,
I'm not an e-stalker or anything ;D, but I noticed in your recent activity box on YouTube you commented on "200mw red laser gun with flash paper" (- YouTube). Are you considering using a >5mW laser pointer for your project? I recently started experimenting with DVD burner drive laser diodes. Have not had the best of luck. I discovered that two of the cheap drives I purchased for the purpose of laser diode extraction have an open can IR/Red combo diode which is smaller than the more standard 12x30mm size. Consequently, they don't fit inside the Aixiz laser housings I purchased. In addition to that, I have had some laser diode "casualties." Two of which I suspect may have been caused by instabilities in my LM317 current regulation driver circuit. >:( The others, I will admit, were lost due to pure carelessness. :-[ I just thought I should bring this topic up in case you also where going to be playing around with laser diodes.

Hum, normally I would worry that my use of smilies makes my look immature, but I notice that they are used quite often on this forum so I'm not going to worry about it.

Qbikal, heh heh no, I have three 3mW laser diodes (Digi-Key VLM-650-01-LPA-ND) that I'll be using. That'll be plenty. The lasers in the youtube vid are a lot more powerful. Not something one should be careless with, although I'm still surprised they ignite flash paper.