Go to Post We have put our [robot] on a treadmill. It should shed those excessive pounds and be in shape to compete.:) - Seth Mallory [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-02-2006, 20:36
railerobotics's Avatar
railerobotics railerobotics is offline
Registered User
FRC #0935
 
Join Date: Jan 2006
Location: Newton, KS
Posts: 190
railerobotics will become famous soon enough
Autonomous problem

I have written this for atonomous code but the the robot does not stop when the counter reaches 2000. Anyone know why?

/* Add your own autonomous code here. */
switch (Step)
{
case 1:
{
stop = 2000;
crawl = (stop - 200);
slow = (stop - 100);

Left_Count = Get_Left_Encoder_Count();
Right_Count = Get_Right_Encoder_Count();
if (Left_Count < slow)
pwm03 = 220;
if (Left_Count > slow && Left_Count < crawl)
pwm03 =200;
if (Left_Count > crawl && Left_Count < stop)
pwm03 =150;
if (Left_Count >= stop)
pwm03 =127;
printf("Left Counter %ld\r", Left_Count);

if (Right_Count < slow)
pwm04 =220;
if (Right_Count > slow && Right_Count < crawl)
pwm04 =200;
if (Left_Count > crawl && Right_Count < stop)
pwm04 =150;
if (Right_Count >= stop)
pwm04 =127;
printf("Right Counter %ld\r", Right_Count);
  #2   Spotlight this post!  
Unread 06-02-2006, 20:44
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,080
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Autonomous problem

Make sure that your encoders are counting the direction that you expect them to.

Are you changing the values of pwm03 or pwm04 anywhere else?
  #3   Spotlight this post!  
Unread 06-02-2006, 20:54
railerobotics's Avatar
railerobotics railerobotics is offline
Registered User
FRC #0935
 
Join Date: Jan 2006
Location: Newton, KS
Posts: 190
railerobotics will become famous soon enough
Re: Autonomous problem

I am not changing the pwm's anywhere else and the encoders are counting in the correct direction. Actually i am using hall effect sensors with encoder code.
  #4   Spotlight this post!  
Unread 06-02-2006, 21:32
Chriszuma's Avatar
Chriszuma Chriszuma is offline
Jack of all trades
AKA: Chris Hammond
FRC #0068 (Truck Town Thunder)
Team Role: Alumni
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Clarkston, MI
Posts: 290
Chriszuma is just really niceChriszuma is just really niceChriszuma is just really niceChriszuma is just really nice
Send a message via AIM to Chriszuma
Re: Autonomous problem

Where did the "step" variable come from? I don't see it being used anywhere in that code block.

EDIT: It would help if you posted the rest of that part of the code so we could tell more about the problem (don't worry, we aren't going to steal your code for our own use)
__________________
2006 T3 World Tour: Great Lakes - Waterloo - Palmetto - IRI
2006 Awards: Motorola Quality - RadioShack Innovation in Control

My website: http://zuma.phire.org/
Truck Town Thunder's website: http://trucktownthunder.com/

Last edited by Chriszuma : 06-02-2006 at 22:40.
  #5   Spotlight this post!  
Unread 06-02-2006, 21:58
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Autonomous problem

Step needs to be set to 1 somewhere, but I don't see it being done in the code fragment you posted.
  #6   Spotlight this post!  
Unread 07-02-2006, 00:35
Dillon Compton Dillon Compton is offline
Jack-Of-All-Trades
FRC #1391 (Metal Moose)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Malvern, PA
Posts: 186
Dillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud ofDillon Compton has much to be proud of
Send a message via AIM to Dillon Compton
Re: Autonomous problem

Quote:
Originally Posted by railerobotics
Actually i am using hall effect sensors with encoder code.
Will that work?

I dont know, I'm just asking...if the count isnt updating due to code not interfacing properly with your sensors, that could be the issue.
__________________
www.metalmoose.com
  #7   Spotlight this post!  
Unread 07-02-2006, 01:03
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Autonomous problem

Let's look at your algorithm first. I have changed your mode variables to hard coded numbers which makes the code more obvious.
Code:
 /* Add your own autonomous code here. */
        switch (Step)
            {
            case 1:
                {
                stop = 2000;
                crawl = 1800;  // are you sure these
                slow = 1900;   // are in the correct order?

            Left_Count = Get_Left_Encoder_Count();
            Right_Count = Get_Right_Encoder_Count();
            if (Left_Count < 1900)
                    pwm03 = 220;
            if (Left_Count > 1900 && Left_Count < 1800)
                    pwm03 =200;
            if (Left_Count > 1800 && Left_Count < 2000)
                             pwm03 =150;
            if (Left_Count >= 2000)
                    pwm03 =127;
            printf("Left Counter %ld\r", Left_Count);

            if (Right_Count < 1900)
                    pwm04 =220;
            if (Right_Count > 1900 && Right_Count < 1800)
                             pwm04 =200;
            if (Left_Count > 1800 && Right_Count < 2000)
                    pwm04 =150;
            if (Right_Count >= 2000)
                    pwm04 =127;
            printf("Right Counter %ld\r", Right_Count);
Notice that this shows problems with initialization of the crawl and slow values. Some lines are unreachable and some condition statements are executed twice. A simpler and more manageable way to use multiple if statements on the same variables is this form:
Code:
    if (count < slow) {
        // fast
    }
    else if (count < crawl) {
        // slow
    }
    else if (count < stop) {
        // crawl
    }
    else {
        // stop
    }
There is nothing in your algorithm preventing a pwm of 127 being set if the count is actually incrementing. If your printf statements are being reached and show the counts go over 2000 then the next thing to check is if setting those pwm's to 127 really does stop the motors.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #8   Spotlight this post!  
Unread 07-02-2006, 08:36
railerobotics's Avatar
railerobotics railerobotics is offline
Registered User
FRC #0935
 
Join Date: Jan 2006
Location: Newton, KS
Posts: 190
railerobotics will become famous soon enough
Re: Autonomous problem

thanks for your help and step is defined at the top of user routines fast.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Autonomous Problem... JoeFryman Programming 2 19-02-2005 14:56
Future of Autonomous Mode FadyS. Programming 41 24-05-2004 19:45
problem with autonomous that has stumped all programmers so far bd02 Programming 32 10-03-2004 22:22
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11
The problem with scouting... archiver 2001 10 23-06-2002 23:49


All times are GMT -5. The time now is 13:43.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi