Go to Post You know you've made it big when people assume every imperfection is genius! - araniaraniratul [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 15-02-2005, 11:32
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Code problems

I just uploaded my code and ended up with a few problems

1)When I hold the trigger on the right joystick (p1) the robot decideds to turn in a circle (1 wheel forwards and the other backwards)

2)When I go full on with p1 it ends up overlapping and going in reverse

3)There is rhythmic pulsing coming from the pwms (i hooked up a servo and it kept moving without any joystick interaction)

here is my user_routines.c file
Attached Files
File Type: zip user_routines.zip (6.4 KB, 30 views)
__________________
  #2   Spotlight this post!  
Unread 15-02-2005, 12:03
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: Code problems

Quote:
Originally Posted by doyler
2)When I go full on with p1 it ends up overlapping and going in reverse
Joystick maximum is 254. Your code does something with the joystick value to get a number from 0 to 127. Your lookup array only goes to 126, so you're falling off the edge and picking up an undefined result. Make your table bigger by one. You might also consider initializing it as part of its declaration rather than having a whole bunch of code in a function to do it.
Code:
static char lookup[128] = (0,0,0,0,0,0,1,1,2,2,2,3,4,4...);
Quote:
3)There is rhythmic pulsing coming from the pwms (i hooked up a servo and it kept moving without any joystick interaction)
You're using pwms 13-16. They are generated by the RC user processor. When other interrupts are being used in the system, the pwm outputs jitter. Change to other pwm outputs, which are generated by the master processor and are not subject to the same interference.
  #3   Spotlight this post!  
Unread 15-02-2005, 12:14
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Code problems

1) Are your motors wired correctly? If you uncomment the code at lines 401-2 does it behave as you would expect? If so, there's a software problem that needs looking into...If not, and it turns in circles, tip it up on end and note which motor(s) are driving the wrong direction. Reverse the motor wires at the M+ M- terminals of the speed controller.

2) One problem that I see is that what happens if p1_y == 254 (i.e. full forward)? Following your code, dist would equal 1, making dist = 254-127...which is 127. You then use dist in your lookup table, however, you don't have an entry for 127...you when you go full reverse (p1_y == 0).

3) Not sure about this one...It may be an issue with using pwm13-16...Is there a reason that you are using pwm13-16 other than the fact that you're electrically connected there? If not, I would suggest that you relocate that functionality to any unused pwm1-12 that you have. The reasoning is described in this thread. I can't guarantee that that's your problem there, but it may help.


<EDIT> Looks like Alan responded while I was typing...</EDIT>
  #4   Spotlight this post!  
Unread 15-02-2005, 12:17
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Code problems

So could I just add this at the end?

lookup[127]=127;

and how would your array work, and why does it go to 128

-------

But the motors are doing the thing that the servos are

[edit]

The trigger is not supposed to make it do anything other then track

[/edit]
__________________

Last edited by doyler : 15-02-2005 at 12:19.
  #5   Spotlight this post!  
Unread 15-02-2005, 14:46
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Code problems

Quote:
Originally Posted by doyler
So could I just add this at the end?
lookup[127]=127;
Sure
Quote:
and how would your array work
Not sure what you mean by that one...
Quote:
and why does it go to 128
The reason that you need to declare the array to size 128 is that array indecies C is zero-based. You want an index range of 0-127 (128 elements), therefore the size should be 128.

Quote:
The trigger is not supposed to make it do anything other then track
I just reread your original question...If the trigger is pressed you set p1_y = speed_control at line 384...but you never initialize speed_control. you go on to use p1_y in the Limit_Mix call on line 396 to set your outputs. So at that point, who knows what the y component of your output is going to be. If it happens to be in the speed controller deadbane (117-137 I think), you will get no forward motion. This could be why it spins.
I see a const int called speed_setting at line 46...did you mean to use this instead?

On a programming side note, the const ints steering_comp and speed_setting would be better written as
Code:
#define STEERING_COMP 30
#define SPEED_SETTING 150
You can put this in user_routines.h. Doing so will save you the size of two ints as well as a few program cycles of having to retrieve the values out of memory. Doesn't seem like a whole lot, but over time things like this add up and pretty soon you're out of space. Its better to get in the habit now so that you don't have to go back later and re-do it if you run into problems.
  #6   Spotlight this post!  
Unread 15-02-2005, 15:42
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Code problems

When i tried to put
#define STEERING_COMP 30 //steering compenstation (0 to 127)
#define SPEED_SETTING 150 //forward speed setting (127 to 254)

in user_routines.h I was getting compiler errors that steering_comp wasn't defined
__________________
  #7   Spotlight this post!  
Unread 15-02-2005, 15:47
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Code problems

Quote:
Originally Posted by doyler
When i tried to put
#define STEERING_COMP 30 //steering compenstation (0 to 127)
#define SPEED_SETTING 150 //forward speed setting (127 to 254)

in user_routines.h I was getting compiler errors that steering_comp wasn't defined
You also need to update your user_routines.c to replace all instances steering_comp with STEERING_COMP. C is case sensitive so they are not the same. By most conventions, constants are in all capitals so that they stand out.
  #8   Spotlight this post!  
Unread 15-02-2005, 15:52
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Code problems

why would this give me a syntax error?

(this is in user_routines_fast)

Code:
if (SPEED_SETTING < 128 || speed_control > 254) 	//Check speed_setting for valid forward speed
	SPEED_SETTING = 150; 						//If not valid number set to default
__________________

Last edited by doyler : 15-02-2005 at 15:54.
  #9   Spotlight this post!  
Unread 15-02-2005, 15:56
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Code problems

Quote:
Originally Posted by doyler
why would this give me a syntax error?

Code:
if (SPEED_SETTING < 128 || speed_control > 254) 	//Check speed_setting for valid forward speed
	SPEED_SETTING = 150; 						//If not valid number set to default
Don't you mean SPEED_SETTING > 254 instead of speed_control?

<EDIT>Disregard this post...don't know what I was thinking, but this won't help at all </EDIT>

Last edited by Dave Scheck : 15-02-2005 at 16:12.
  #10   Spotlight this post!  
Unread 15-02-2005, 15:58
AIBob's Avatar
AIBob AIBob is offline
AI Programmer
AKA: Bob Frank DOT org
FRC #0358 (Hauppauge Robotic Eagles)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Long Island, NY (in Binghamton now)
Posts: 297
AIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to behold
Send a message via ICQ to AIBob Send a message via AIM to AIBob Send a message via MSN to AIBob Send a message via Yahoo to AIBob
Re: Code problems

Code:
#define SPEED_SETTING 150 //forward speed setting (127 to 254)
Code:
if (SPEED_SETTING < 128 || speed_control > 254) //Check speed_setting for valid forward speed
SPEED_SETTING = 150; //If not valid number set to default
You defined SPEED_SETTING as a constant, I believe you can not set a defined constant after you are running the code, also as noted by someone else before, C is case sensative.

Errors in your code I marked in red.
__________________
- from B B frank


Last edited by AIBob : 15-02-2005 at 16:04.
  #11   Spotlight this post!  
Unread 15-02-2005, 16:02
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Code problems

I don't think it should be a constant

This is my user_routines*
Attached Files
File Type: zip userroutines.zip (11.0 KB, 29 views)
__________________
  #12   Spotlight this post!  
Unread 15-02-2005, 16:02
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Code problems

Quote:
Originally Posted by AIBob
you defined SPEED_SETTING as a constant, I believe you can not set a defined constant after you are running the code
Good catch Bob, I overlooked that.
  #13   Spotlight this post!  
Unread 15-02-2005, 16:07
AIBob's Avatar
AIBob AIBob is offline
AI Programmer
AKA: Bob Frank DOT org
FRC #0358 (Hauppauge Robotic Eagles)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Long Island, NY (in Binghamton now)
Posts: 297
AIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to behold
Send a message via ICQ to AIBob Send a message via AIM to AIBob Send a message via MSN to AIBob Send a message via Yahoo to AIBob
Re: Code problems

Quote:
Originally Posted by doyler
I don't think it should be a constant
It shouldn't, but this is in your code:
user_routines.h:
Code:
#define SPEED_SETTING 150 //forward speed setting (127 to 254)
Which defines them as constants in C.

Quote:
Originally Posted by Dave Scheck
Good catch Bob, I overlooked that.
That's alright, we all make mistakes, even I do occasionally.
__________________
- from B B frank


Last edited by AIBob : 15-02-2005 at 16:16.
  #14   Spotlight this post!  
Unread 15-02-2005, 16:10
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Code problems

I think this is what you are trying to do in user_routines_fast_DDT.c.

Code:
if(speed_control < 128 || speed_control > 254)
    speed_control = SPEED_SETTING ;
  #15   Spotlight this post!  
Unread 15-02-2005, 16:23
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Code problems

Where would I put compressor code this year, last year it was in relayControl() in user_routines.c?

Also, why would i still be getting the jumps

How would I stop my trigger from doing stuff
__________________

Last edited by doyler : 15-02-2005 at 17:41.
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
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
heres the code. y this not working omega Programming 16 31-03-2004 15:18
Wierd gyro code problems...pls help Salik Syed Programming 4 14-03-2004 01:29
IR reflective (tape) sensor code problems Argoth Programming 8 07-02-2004 21:32
problems assigning unsigned chars in FRC Code LoyolaCubs Programming 6 26-01-2004 23:21


All times are GMT -5. The time now is 19:18.

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