Author |
Message |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Doesn't Equal Command
Here is the code that I am using currently. My question is that I want to be able to set the encoders to be 'not equal to' rather than 'less than' or 'greater than'. Is this possible (I was thinking that != would work) but I wanted to check...
|
Mon Jan 03, 2011 10:57 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Doesn't Equal Command
Your assumption is correct. != means not equal to.
- Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Jan 04, 2011 12:32 am |
|
 |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Re: Doesn't Equal Command
My next question:
How likely is that to work how I want it to... i.e. once it gets to that point it stops. I believe the motors should be on a break, but considering that the robot will be moving, I believe that it is most likely that it could just get to it, momentum rolls it past the point and then it continues.
*I will be testing it for sure tonight* But any insights or tips are appreciated.
|
Tue Jan 04, 2011 10:08 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Doesn't Equal Command
Well, I think a range is a much better thing to use  If you miss it by a fraction, the robot will continue as if it never happened. Have you considered using nMotorEncoderTarget[]? - Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Jan 04, 2011 10:55 am |
|
 |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Re: Doesn't Equal Command
I'm not too familiar with how the nMotorEncoderTarger[] works, and since im at work I can't exactly play with the code. If I use this target, what would the code need to look like? Would I just set the target and and motor power? Would this be the code?
|
Tue Jan 04, 2011 12:01 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Doesn't Equal Command
More like this: Target is always relative and positive. A negative value means that it will "float" the motor when the target is reached. The speed determines the direction. If you do insist on resetting the tachos, be sure to add a 100ms wait between the reset and the setting of a new target. - Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Jan 04, 2011 12:10 pm |
|
 |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Re: Doesn't Equal Command
So since the target is relative, it doesn't matter the direction that I am going, it takes the absolute value of the rotations?
I didn't know this, this surely makes life a touch easier for me.
|
Tue Jan 04, 2011 12:23 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Doesn't Equal Command
Why do all the work when you can have the FW do it for you  - Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Jan 04, 2011 12:24 pm |
|
 |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Re: Doesn't Equal Command
Ok... so both of these codes should do the exact same thing... or do they? If the encoder target goes past what the target actually is (as was my concern earlier), will it reverse direction to bring it back in line with the target? (this is more for finding a spot on the field and staying where I want to)... or would this need to be done with an if statement, etc.
|
Tue Jan 04, 2011 1:32 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Doesn't Equal Command
No, it will actually make sure that the motors get to the exact position you instructed them to. It will stop them at the correct spot.
- Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Jan 04, 2011 2:07 pm |
|
 |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Re: Doesn't Equal Command
OK! Thanks! Sorry for so many posts this morning.  Time to change this up on my lunch break and test it tonight. Thanks!
|
Tue Jan 04, 2011 2:13 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Doesn't Equal Command
Why be sorry? If you have questions, ask them and if I think I have an answer, I'll give it to you  - Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Jan 04, 2011 2:16 pm |
|
 |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Re: Doesn't Equal Command
Xander,
I've made the necessary changes. I will test them tonight and let you know how everything goes!
Thanks for the help.
|
Tue Jan 04, 2011 4:12 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Doesn't Equal Command
No worries, let me know how it goes.
- Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Jan 04, 2011 4:15 pm |
|
|