|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
I have this and i know it works but i have 3 digital ins that are set as inputs
rc_dig_in01 rc_dig_in02 rc_dig_in03 they are all optical sensors, i know the optical sensors are working properly becuase i get on and off lights on the operator interface. I just cant seem to "word" the way to get all 3 sensors to work together. roughly i want tit to work like this if dig in 1 is on then it should turn left if dig in 2 is on both motors should dturn equally if dig in 3 is on then it should turn right PWM01= left side drive PWM02= right side drive ... but how do i get the sesors to all work together. I cant seem to think on how to get them to all work together i tried a switch statement and stacking else if 's i just cant think of how to get it to work. Code:
if (rc_dig_in02 == 1) {
pwm01= 200;
pwm02= 200;
}
else {
pwm01= 127;
pwm02= 127;
}
|
|
#2
|
||||
|
||||
|
Re: line seeking help needed
Quote:
Code:
if (rc_dig_in01 == 1) || (rc_dig_in02 == 1) {
pwm01= 200;
}
else {
pwm01= 127;
}
if (rc_dig_in02 == 1) || (rc_dig_in03 == 1) {
pwm02= 200;
}
else {
pwm02= 127;
}
|
|
#3
|
|||||
|
|||||
|
Re: line seeking help needed
Our head programmer suggested:
Code:
if (rc_dig_in02) {
pwm01 = 200;
pwm02 = 200;
} else if (rc_dig_in01) {
pwm02 = 200;
pwm01 = 127;
} else if (rc_dig_in03) {
pwm02 = 127;
pwm01 = 200;
}else {
/* No line found.... */
}
|
|
#4
|
|||||
|
|||||
|
Re: line seeking help needed
Thank you both for your fast reply I will test both of those now and let you know when I get my results. THANK YOU SOOOOOOOO MUCH!!!! and best of luck to both of your teams.
Heres the code i ended up using: Code:
if (rc_dig_in02) {
pwm01 = 200;
pwm02 = 200;
} else if (rc_dig_in01) {
pwm02 = 200;
pwm01 = 127;
} else if (rc_dig_in03) {
pwm02 = 127;
pwm01 = 200;
} else {
pwm01= 127;
pwm02= 127;
}
Last edited by MisterX : 19-02-2004 at 18:28. |
|
#5
|
|||
|
|||
|
Re: line seeking help needed
Hey Mister, just a suggestion, the more sensors you have on your robot for line following, the more accurate, and the faster you can run it. We're using 9 sensors and we can run at almost full speed with about a 95% of the time staying on the line.
|
|
#6
|
|||||
|
|||||
|
Re: line seeking help needed
Wowser, and to think originally some of my team wanted to only do two and we had to convince them three was better. Thanks for the information Catastrophy I'll probably try and work somethign like that during the offseason but right now with the little time we have left we will probably stick with three unless a miracle happens. Thanks for the info though, I would love to try something like that.
P.S. if you are at Nats do you think me and one of my other programmers could swing by your booth to check it out? P.M. me |
|
#7
|
|||||
|
|||||
|
Re: line seeking help needed
I don't think 9 is necesary, but trim the positions of the sensors based on the width of the line. I think 5 would be good:
Code:
| |
1 2| 3 |4 5
| |
2,4- if these hit the line, turn that way. _ 3- Keep this on the line. ps-the code was just to get a fixed-width font. |
|
#8
|
|||
|
|||
|
Re: line seeking help needed
Heres a tip if your having problems staying on the line, make it go in reverse if no line is being read. Heres a picture of the temp configuration (gonna have a metal plate for final all neatly up under the hood. and holes in chasse for beam to get out.)) and a video of this year's sensors on last year's bot. The video is kinda bad example of how the code's working, the video is 15 sec, but it usually only take 7-11 seconds to get to the ball stand
http://home.comcast.net/~Catastrophy/picture.jpg http://home.comcast.net/~Catastrophy/movie.avi Here's the code tweaked for our bot if anyones interested. Code:
if (dig12 == 1 && dig18 == 1){
pwm14=76;
pwm16=76;
}
if (dig18 == 1 && dig1 == 1 &! dig12 == 1 &! dig6 == 1){
pwm16=96;
pwm14=115;
}
if (dig18 == 1 &! dig1 == 1 &! dig12 == 1){
pwm16=86;
pwm14=115;
}
if (dig1 == 1 &! dig18 == 1 &! dig6 == 1){
pwm16=76;
pwm14=178;
}
if (dig12 == 1 && dig4 == 1 &! dig18 == 1 &! dig10 == 1){
pwm16=96;
pwm14=115;
}
if (dig4 == 1 &! dig12 == 1 &! dig10 == 1){
pwm16=178;
pwm14=76;
}
if (dig12 == 1 &! dig4 == 1 &! dig18 == 1){
pwm16=115;
pwm14=86;
}
if (dig1 == 0 && dig4 == 0 && dig12 == 0 && dig18 == 0 && dig8 == 0 && dig10 == 0 && dig6 == 0){
pwm14=155;
pwm16=155;
}
if (dig6 == 1 &! dig1 == 1){
pwm14=204;
pwm16=50;
}
if (dig8 == 1){
pwm14=127;
pwm16=127;
}
if (dig10 == 1 &! dig4 == 1){
pwm14=50;
pwm16=204;
}
Last edited by Catastrophy : 20-02-2004 at 20:04. |
|
#9
|
|||
|
|||
|
Re: line seeking help needed
for those that actually have this working on the 2004 bot, what times are you getting to track the complete line?
|
|
#10
|
||||
|
||||
|
Re: line seeking help needed
This looks excellent, after sitting around looking out our programmers figure out nothing last night this is a breath of fresh air. I personally am not a programmer, but I am going to try to implement this tonight after the Suffield Scrimmage. We were using two sensors, and something didn't seem right about it, does anyone have any reccomendations, when using three sensor, on how to make the robot go backwards if its not seeing the line. I have a very limited knowledge of C, and I feel our programmers are uncomfortable with the platform this year. so...
If you guys can help me make this work, there will be Krispy Kreme's at Hartford (or Atlanta) for you, on me. Thanks a Bunch! Jamie |
|
#11
|
||||
|
||||
|
Re: line seeking help needed
Quote:
Code:
if(rc_dig_01 == 0 && rc_dig_02 == 0 && rc_dig_03 == 0)
{
pwm01 = 0;
pwm02 = 0;
}
PS the digital inputs are your sensors and the pwmXXs are the drive motors. PPS Nine banners. Crazy. ![]() |
|
#12
|
||||
|
||||
|
Re: line seeking help needed
Our team is actually going with two custom built analog sensors, we like analog because its not just a 1 or a 0, it brings back a range as it slides on and off the line, so you can actually program for it to follow a line quite fast with only one sensor as opposed to having 3 - ... 9 sensors
Our sensors have a potentiometer on each that allows us to adjust the sensitivity and they each have their own LED light, so they could even follow a line if it were in a dark room. (not that following lines in the dark is useful for the competition, but its something its capable of) |
|
#13
|
|||
|
|||
|
Re: line seeking help needed
If anyone has any questions on line following please feel free to PM me or IM, i'd be happy to help with what I can.
P.S. I extremely recommend using atleast 3 sensors for line following, with 2 the bot will not act right at all, will be very jittery. P.P.S the more banner sensors you have the better it will work. I've learned from personal experience. Last edited by Catastrophy : 21-02-2004 at 12:42. |
|
#14
|
|||||
|
|||||
|
Re: line seeking help needed
The ultimate engineering attitude: "Why? 'cause we can." Why not?
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sprockets and Roller Chain Models | Madison | Inventor | 3 | 04-02-2003 11:51 |
| Q&A Discuss: Does the line continue up the ramp? | CD47-Bot | Extra Discussion | 5 | 18-01-2003 01:01 |
| iParts on firstcadlibrary.com | Ed Sparks | Inventor | 3 | 08-01-2003 23:30 |
| approach to autonomy | Mike375 | Programming | 32 | 08-01-2003 14:04 |
| emulationFIRST v0.04 | Matt Leese | Programming | 7 | 09-07-2002 08:54 |