Saying "Hi!" with my current project

Just wanted to say "Hi" and am eager to get going with some real projects for my Uno.
My first project is a mini turret...more of a hobby project than anything really useful, but it will make a fun little desktop toy, and give me an excuse to experiment with some PIR sensors.

Regards!

I will post some pics later

So here is a link to the rendered turret.

If I'm lucky, I will have parts to bolt together this weekend :slight_smile:

The turret looks pretty cool. Did you design it and order it online somewhere or are you going to make these parts per your design??

Thanks! I just sketched it up in inventor. I guessed at what it should look like. Mostly, the driving factor is mounting 2 futaba S3003 servos.
I don't know what will be mounted in the end, but the first thing will be a PIR array for testing.

So, here is a photo of my super cheap/simple Ir sensor. I am going to make 4 and then have an single independent transmitter IR source.

*Not sure if I am going to need an Op Amp...but don't care right now!

I finally got my lasercut parts :smiley:

Here is a peek

I couldn't wait, so I formed the parts up, and sprayed them.
Looks just like the rendering :smiley:

Looks great! What materials did you use and where did you get them fabbed?

Thx! It's gauge steel, and I know somebody who does laser cutting and they can sneak small parts every now and then :wink:

Looks impressive so far Mr_Manny.

Can I ask you a thing about the futaba s3003? With a bit of try and error I ended that they go, in microseconds, from 500 to 2400. Have you ever tried?

QUOTE; Can I ask you a thing about the futaba s3003? With a bit of try and error I ended that they go, in microseconds, from 500 to 2400. Have you ever tried?

I thought of using the pwm method, but the Arduino library makes it easier to just define the angle.

I guess I am going to need to make a sensor with an amplifier afterall.
My serial output reads 1023 with no light source, and with the brightest light, I can only get it down to the low 900s. I will definitely need to make it more sensitive for it to be functional.

Ha! I guess nobody noticed, but I had my IR phototransistor backwards!
Now that I fixed it, I get serial readings ranging from 1023 to 27 using a simple light source which should make it usable for my project without adding a transistor to the circuit. cross fingers

Ok, so now I made a pair of IR sensors to test with the servo, and so far seems like it all works fine! I breadboarded everything together, but couldn't mount the sensors on the servo yet, however, the servo responds to variance in light shining on the IR phototransistors.

a pic is in the link:

Looking good. Puts my first Arduino project to shame :slight_smile:

Looks pretty cool. Nice work on the base - looks 'manufactured'. The IR thing will do what - scan around? Detect motion?

I'm very interested in your driver strategy. I've found that the 1-degree steps are pretty coarse. So I'm trying microseconds from about 650 to 2400 (seems to concur with Federico - but I'm not sure I understand it yet).
This is a couple bits from my code: 1st is servo 1, second is servo 2, third is time interval in ms:

{650, 1000, 2000}, //650 is about the limit for ccw rotation

{2600, 1290, 1000}, //2600 is around the limit for cw rotation

The basic idea is to make a very primitive "motion tracker" using simple IR phototransistors.
Of course, it will basically just rotate until both sensors have relatively equal readings. What will keep it from being jittery, is defining a deadband in the code. Other than that, it basically does a +1 or -1 left or right..
I am not using PWM, just calling out, or calculating out the angle of the servo 0-180 degrees using the Arduino library.
I will share code here after I do a test with the sensors mounted on the 1st servo.

I got it wired up for a full test with the IR sensors mounted on the turret, but the results were less than encouraging.
Possibly my sensors need amplification, or my wiring is just shorting.
The axis is not responsive unless I shine bright light on it, and sometimes jittery.

EDIT: I think it is a fault phototransistor. Only one sensor activates the slew.

Here is the code I adapted:

/*
Base Coding For Arduino Motion Tracker Using IR Sensors
Adapted by Mr_Manny from code by Dave Auld
Original Url: http://www.codeproject.com/KB/system/ArduinoLightTrack.aspx
*/

#include <Servo.h>

// Define Pins To Be used
int pin_L = 5; //Left Sensor Pin
int pin_R = 4; //Right Sensor Pin
int servoX = 11; //Pin For The Horizontal Servo

int leftValue = 0; //The left Sensor Value
int rightValue = 0; //The right Sensor Value
int error =0; //The Deviation between the 2 sensors
int errorAVG = 0; //Error Average - Rolling 2 Point

int deadband = 10; //Range for which to do nothing with output 10 = -10 to +10

//Servo Declarations
Servo ServoHorz; //Make a Servo object
int Position = 45; //Position to write out

int minPos = 10; //Min Position
int maxPos = 170; //Max Position

float output = (maxPos - minPos) /2; //Start Position, Try 90deg Later

void setup()
{
ServoHorz.attach(servoX);
}

void loop()
{
//Read Sensors And Calculate
leftValue = analogRead(pin_L);
rightValue = analogRead(pin_R);

//Calculate
error = leftValue - rightValue;
errorAVG = (errorAVG + error) / 2;

float newOutput = output + getTravel();

if (newOutput > maxPos)
{
newOutput = maxPos;
}
else
{
if (newOutput < minPos)
{
newOutput = minPos;
}
}
//Output Writing
ServoHorz.write(newOutput);
output = newOutput;
}

int getTravel()
{
// -1 = Left; +1 = Right

if (errorAVG < (deadband * -1))
{
return 1;
}
else
{
if (errorAVG > deadband)
{
return -1;
}
else
{
//Do not move within deadband
return 0;
}
}
}

So, I tried a different sketch, and it works more predictably.
I need to go over my adapted code, and find the problem.
When I run this sketch, the tracker seems to have exagerated jitter/oscillation randomly.

Maybe somebody can spot the problem ? :wink: :-?

EDIT: Ok, maybe it needs a center position to start:

void setup()
{
ServoHorz.attach(servoX);
ServoHorz.write(minPos); //Quick Initialization before start
ServoHorz.write(maxPos);
ServoHorz.write(output);
delay(2000);
}

I just received my Sensor Shield V4.0, and it is going to make my testing easier.
Pretty neat, just what I needed. I also bought a new pair of IR phototransistors to change the wiring setup a little, and now I can solder a standard servo cable to the sensor.