What its supposed to do is, if it finds an object it opens the claw, goes towards it for two seconds, then closes the claw. What it does is, it opens the claw fine and goes towards it ok. When it closes the claw it acts like the encoder is set too high and lifts the robot up. I dont know why it does this, because the encoder targets are the same numbers, just that the motor A is reversed in one and not the other. Anyone have any ideas as to why this is occurring? Ill attach my full code. Maybe the problem stems from some other area of my code.

Attachments:

File comment: full code from which the snippet was pulled fromCompetitionCode.c [3.54 KiB]
Downloaded 319 times

Tue Feb 26, 2013 1:04 am

Coder A

Moderator

Joined: Thu Jan 03, 2013 5:10 pmPosts: 207Location: The plateau north of the Ohio River Valley, also known as Cave Country.

Re: Encoder Help

You can only set positive values with the encoder target variable. you will nedd to reverse the A motor in the gap in the two blocks of code and again after that code has executed, at the end of the if statement. I forget how to reverse a motor, it is like bmotorreversed = true or something like that.

_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robot

Tue Feb 26, 2013 11:45 am

heinst

Rookie

Joined: Tue Feb 26, 2013 12:54 amPosts: 5

Re: Encoder Help

Coder A wrote:

You can only set positive values with the encoder target variable. you will nedd to reverse the A motor in the gap in the two blocks of code and again after that code has executed, at the end of the if statement. I forget how to reverse a motor, it is like bmotorreversed = true or something like that.

To my understanding, the motor power is set to negative 40 power, but the encoder is still positive. Is that true?

Tue Feb 26, 2013 2:06 pm

Coder A

Moderator

Joined: Thu Jan 03, 2013 5:10 pmPosts: 207Location: The plateau north of the Ohio River Valley, also known as Cave Country.

Re: Encoder Help

If you flip the motor, to our eyes it will go backwards but the encoder and power will be positive.

*EDIT*

I misunderstood you. In your first commands, you set the target to 50 and than go backwards, never reaching the target. Flip the motor, set the target to 50 still, and set the speed to +40. Afterwards, reflip the motor. I think that should help.

The encoder can be positive or negative, but the target's sign does not mean the same thing. look at the motor section of the wiki to see what I mean.

_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robot

I tried that and the same thing happened...any other ideas? Do you think it will stem from somewhere else?

Wed Feb 27, 2013 1:38 pm

Coder A

Moderator

Joined: Thu Jan 03, 2013 5:10 pmPosts: 207Location: The plateau north of the Ohio River Valley, also known as Cave Country.

Re: Encoder Help

heinst wrote:

I tried that and the same thing happened...any other ideas?

By the same thing do you mean claw close sudden sorry have to go

_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robot

Wed Feb 27, 2013 6:07 pm

Coder A

Moderator

Joined: Thu Jan 03, 2013 5:10 pmPosts: 207Location: The plateau north of the Ohio River Valley, also known as Cave Country.

Re: Encoder Help

Sorry, I had to leave, and I had no time to check my grammar. What I meant is this: what is the " same thing" that happened? Also, what is the robot like? Could you send a picture of it? I think we are close to finding the answer.

I noticed a problem with a different area of your code. The code inside the if(time1[T2] > 1500) statement does not really do anything because the motor B is constantly being set from -75 to 75. Try changing that as well.

_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robot

Joined: Thu Jan 03, 2013 5:10 pmPosts: 207Location: The plateau north of the Ohio River Valley, also known as Cave Country.

Re: Encoder Help

I'm glad you got it working. As for what I thought is wrong with the if statement, it's because once time1[T2] > 1500, the statement works as it should. It's just the loop it's in causes motor B to be set back to -75, so I thougt that that line should only run when time is less than 1500, like this:

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum