The Wooden Menace; Robotic Arm

Questions and Comments on All Projects
ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Wed Mar 26, 2008 12:10 am

Hey,

I don't know for sure, I'm just going off what I saw when I skimmed over the datasheet. It's best to always refer to the datasheet in great depth when you need to know specifics with timing. :o

However like I said before, you'll find out quicklyif things are working, if you make a simple blinking circuit. To do that you can just create a program that sets a pin on and off with nop's used as delays in between.

Just a suggestion. :lol:

Engineer41
Newbie Pyro
Posts: 15
Joined: Mon Mar 17, 2008 5:58 am

Postby Engineer41 » Sat Mar 29, 2008 3:35 pm

Hello,


I have been working on it yesterday the whole day, and I am lost. I have 5 days to finish this :( . My PIC does not have large enough timer...I only have 0ne 16 bit timer and one 8 bit timer. The 16 bit timer I use for 20 ms , and the other one I can't make it work well for the servos delays. It is too late to get a better PIC now, I don't know what to do. Any advices? Anyone :(


Thank you

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Sun Mar 30, 2008 5:27 pm

Sure,

What is the project?
How many servos do you need to control?
Is anything else happening besides servo control?

There's other ways to control servos but whether they can be applied to your project depends on what you need the servos to do. The timer method, for example, allows you to time each servo independently. :)

Engineer41
Newbie Pyro
Posts: 15
Joined: Mon Mar 17, 2008 5:58 am

Postby Engineer41 » Sun Mar 30, 2008 7:59 pm

Hello!!

My project is controlling six servo motors. They need to move in sequence. It is a robotic arm that my team and myself designed. It has one servo at the gripper, one at the arm, two at the shoulder, one at the elbow and at the base. This arm sorts objects based on their colors, and read and ADC port. That is not really a problem, its really the movement of the arm that I just can't get. I implemented your code partially (I will reference it:)), and I understand it fully it seems very logical to me. I just realized too late that my timers are not big enough, if I try using a 256 prescaler on timer of 8 bits, my servos don't move at all. I don't know what to do now, cause I am using timer1 for the 20 ms interrupt and the small 8 bit timer for the servos delays :( . Do you have any suggestions? I totally ran out of ideas, I will probably fail on my project :( .....



Thank you!!!!

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Sun Mar 30, 2008 8:10 pm

Well one simple idea that comes to mind right away is to use the 8-bit timer and reset it again and again until you reach the delay you need to create.

Something like...

Code: Select all

int i = 0;

     Set Servo High +5v
Set 8 bit timer...count to FF
~~FF reached~~
     i++;
     reset timer, count to FF~~
~~FF reached~~
     i++;
     reset timer, count to FF~~
~~FF reached~~
     i++;
     reset timer, count to FF~~
~~FF reached~~
     i++;
     reset timer, since i = 4 count to 5A~~
~~5A reached~~
     Set Servo Low +0v

So this counts to FF + FF + FF + FF + 5A = 546

I realize this is not the ideal way of doing things but it could work.

Engineer41
Newbie Pyro
Posts: 15
Joined: Mon Mar 17, 2008 5:58 am

Postby Engineer41 » Sun Mar 30, 2008 8:24 pm

Hello! Thank you so much for answering!

Just to make sure I understand correctly I would do this reset of timer the way that you did WHITHIN the switch statements???

so I would say

case1: PORTD = 0x01;
Set timer to FF;
increment i;
//set to FF amount of times needed
set to final value that is needed?

THANK YOU!!!!!!!!!!! I will try implementing it now!

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Sun Mar 30, 2008 10:34 pm

Hi,

Yes similar to the switch statement. I think you got my method :) .

Don't get me wrong its the long way to do things :? , but I think you can get this method working in the time frame you have.

Engineer41
Newbie Pyro
Posts: 15
Joined: Mon Mar 17, 2008 5:58 am

Postby Engineer41 » Sun Mar 30, 2008 10:47 pm

Hello,


Thank you for the answer.....Could you please look at my code??

Code:

if(INTCON.T0IF == 1 && INTCON.T0IE == 1)
{
count
switch(count){

case 1: PORTD = 0x01; // First Stage
if(i<bacnt)
{
TMR0 = 0xFF;
i++;
}
else if(i==(baCnt))
{
TMR0 = servo; //Set to the remaining count
flag = 0;
i=1;
}
break;
case 2:
if(flag=1)
{
PORTD = 0x00;
}
break;
}



bacnt in my code is the amount of 0xFF's, and then the rest is 'servo'. Am I doing ok by creating a flag that would set the port to true only after all the timer overflows have occured...?


Because I tried it, and the servo reaches the limit and rotates abit back and forth like crazy :(


Thank you!

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Sun Mar 30, 2008 11:20 pm

That looks pretty solid (without having seen the rest of the code). My only thought about it is that you need to make sure you don't increment count until after the first servo's uptime has been created, then you can move to creating the uptime for the next servo.

perhaps increment count when the inside of the:
else if(i==(baCnt))

Instead of using the flag method you have. That won't work if the rest of your code looks like I think it does.

Engineer41
Newbie Pyro
Posts: 15
Joined: Mon Mar 17, 2008 5:58 am

Postby Engineer41 » Mon Mar 31, 2008 4:29 pm

Hello,

I modified the code based on what you told me. This is my interrupt:

case 1: PORTD = 0x01; // First Stage
if(i<baCnt)
{
TMR0 = 0xFF;
i++;
count++;
}
if(i==baCnt)
{
TMR0 = servo0; //Set to the remaining count
PORTD = 0x00;
i=1;
}
break;
case 2:

break;
}


This is my main:


baCnt = 2;
while(1)
{
servo0 = 0x10;
Delay_ms(10000);
}



I have a 1:8 prescaler....It does not seem to work, it turns all the way as if the port never turns off:( I don't see what the problem might be. I didn't put the baCnt because it would reset because u're in the while loop...so I don't know why I can't send the sersvo to a position. the jittering is gone, now my servo only moves 180 :(


Thank you!

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Mon Mar 31, 2008 11:54 pm

I can't be entirely sure because you don't have all the code up there :? however it looks like you are never telling PORTD to go high. Don't you want to create a 50Hz PWM signal? This code just looks like it always tells PORTD to go low.

Draw it out on paper and figure out how many times 0xFF would need to be run to get near the desired 1-2mS range and then redo the code. :o

ahb
Newbie Pyro
Posts: 1
Joined: Mon Apr 07, 2008 4:08 pm

Controller

Postby ahb » Mon Apr 07, 2008 4:09 pm

You mentioned the controller used for this project is a PS1 clone, could I just use a genuine PS 1 controller?

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Mon Apr 07, 2008 4:46 pm

Hey Ahb,

You could use any controller you wanted, if you know how to interface to it. :!:

:idea: If you're interested in learning how to use a PS1 controller in your projects you might find this interesting.

The controller I used in this project works differently than a standard playstation controller, so you couldn't just swap them out.

mike
Newbie Pyro
Posts: 3
Joined: Tue Dec 02, 2008 2:17 pm

Postby mike » Tue Dec 02, 2008 2:30 pm

can you tell me what is the difference between an original ps1 controller and a clone one ?

i can't find a clone ps1 controller and to use an original ps1 is more complicated.

mike
Newbie Pyro
Posts: 3
Joined: Tue Dec 02, 2008 2:17 pm

Postby mike » Tue Dec 02, 2008 2:45 pm

is there another type of controller that i can use, without changing very much the components of this project ?

tnx


Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest