Go to Post [on the 2007 field control software] its crazy -- not only did they sound like the same old sound effects we know and love, but it seemed like they actually occured at the time they were supposed to! :) - Aidan F. Browne [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 29-01-2007, 22:51
DavidGitz's Avatar
DavidGitz DavidGitz is offline
Lead Technical Advisor
FRC #1208 (MeTool Brigade)
Team Role: Coach
 
Join Date: Dec 2006
Rookie Year: 1996
Location: O'Fallon, IL
Posts: 341
DavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud of
Send a message via AIM to DavidGitz Send a message via MSN to DavidGitz Send a message via Yahoo to DavidGitz
Drive Code

Okay stupid question. I'm on a rookie team and we have been having problems for a WEEK now on the basic driving code. We have a standard drive system, using 2 cim motors that go to 2 wheels each and want to use one joystick to control both motors, that go to pwm13 and pwm15. We have been having a lot of issues with the default code, since we want to have full proportional control wherever the joystick is. Could someone please post their drive code if they have a similar configuration? Thank you.
  #2   Spotlight this post!  
Unread 29-01-2007, 22:55
chris31 chris31 is offline
Team 2021 Captain
AKA: Chris Davidson
FRC #2021 (FA Robotics)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2006
Location: Atlanta, GA/ Fredericksburg,VA
Posts: 949
chris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond repute
Send a message via AIM to chris31
Re: Drive Code

The default code has code for a 1 joystick drive? Can you explain what is wrong with this or what you want that is different from that?
  #3   Spotlight this post!  
Unread 29-01-2007, 23:04
DavidGitz's Avatar
DavidGitz DavidGitz is offline
Lead Technical Advisor
FRC #1208 (MeTool Brigade)
Team Role: Coach
 
Join Date: Dec 2006
Rookie Year: 1996
Location: O'Fallon, IL
Posts: 341
DavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud of
Send a message via AIM to DavidGitz Send a message via MSN to DavidGitz Send a message via Yahoo to DavidGitz
Re: Drive Code

Well my team wants to have straightforward code, not have the limiting function involved. I know why it is there, to make sure the bounds never fall outside of the unsigned int datatype, but is it possible to not have to use this (limit_mix) function?
  #4   Spotlight this post!  
Unread 29-01-2007, 23:39
ace123's Avatar
ace123 ace123 is offline
Registered User
AKA: Patrick Horn
FRC #0008 (Paly Robotics - http://robotics.paly.net/)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Palo Alto, CA
Posts: 50
ace123 has a spectacular aura aboutace123 has a spectacular aura about
Send a message via AIM to ace123
Re: Drive Code

One problem is that pwm's 13-16 are generated in a special way, using the Generate_PWM function.

I would suggest trying pwm's 10 and 11 for example (change the code)

In my opinion, the best way to debug PWM problems is to look at the light on the Victor itself:

Quote:
(FYI: The Victor light is the most accurate source if you are stuck with a PWM value problem... that one light tells you a lot of info. If it is flashing orange, it's a 3-pin PWM cable problem, or it's set to a special value that disables it (like if your robot is detached). If it's completely off once you run the code, the motors are running slowly or half-speed. If it's solid orange, they are inside the deadband or completely stopped. If it's bright red or green, it's running full power in forward or reverse.)
Flashing orange could also mean a problem with the Generate_Pwm() or PWM() function calls if you are on 13-16... best to try switching to a different port if you aren't sure.

Here's a thread with a similar problem to the one you are having:
http://chiefdelphi.com/forums/showthread.php?t=52869
__________________
-Patrick Horn, Paly Robotics

Check out the space simulator called Vega Strike, modelled after the space simulator games Elite and Wing Commander. It's Open Source too!
If you have ever played Wing Commander, or especially Privateer, and had a feeling of nostalga derived from the you will enjoy these two Vega Strike mods: Privateer Gemini Gold and Privateer Remake!
I'm working on adding multiplayer support this year...
  #5   Spotlight this post!  
Unread 29-01-2007, 23:39
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: Drive Code

Alright..

Say, you have two cims on each side
each cim is connected to its own speed controller
CIM 1 and CIM 2 are on the left side and the speed controllers are connected to PWM 01 and PWM 02. CIM 3 and CIM 4 are on the right side and the speed controller are connected to PWM 03 and PWM 04

You will use two joysticks. One joystick will controll the left side and the other, the right side. Connect the joysticks to port 1 and port 2 on the OI.

In the code the joysticks return 0 to 255, the motors also work on 0 to 255 values. If you set the motor to 127 it is neutral, likewise the joystick is at 127 when it is at center. Since both the joystick and the motors work on the same range you can do a direct joystick to PWM... heres an example

Code:
PWM01 = p1_y;
PWM02 = p1_y;

PWM03 = 255 - p2_y;
PWM04 = 255 - p2_y;
Now, the joystick connected to port one (p1_y) (port 1 y axis) will control speed controller connected to PWM 01 and PWM 02.. this will controll the left side.. the same goes for the p2_y, however you must reverse it (255 - p2_y) since the motors are spinning the oppisite way...

Hope thats enough to get you started...

remember joysticks give values 0-255 and motors take values 0 - 255 and neutral is 127...

Good luck
  #6   Spotlight this post!  
Unread 29-01-2007, 23:43
whytheheckme's Avatar
whytheheckme whytheheckme is offline
Registered User
AKA: Jacob Komar
no team
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Providence, RI
Posts: 1,320
whytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond repute
Send a message via ICQ to whytheheckme Send a message via AIM to whytheheckme Send a message via MSN to whytheheckme Send a message via Yahoo to whytheheckme
Re: Drive Code

You could try easyC and just use the Arcade 2-Motor drive block... One single drag and drop will do it.

I'm not sure if you want to go this route, but for an 'easy' solution, this is probably it.

Jacob
  #7   Spotlight this post!  
Unread 30-01-2007, 09:39
DavidGitz's Avatar
DavidGitz DavidGitz is offline
Lead Technical Advisor
FRC #1208 (MeTool Brigade)
Team Role: Coach
 
Join Date: Dec 2006
Rookie Year: 1996
Location: O'Fallon, IL
Posts: 341
DavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud ofDavidGitz has much to be proud of
Send a message via AIM to DavidGitz Send a message via MSN to DavidGitz Send a message via Yahoo to DavidGitz
Re: Drive Code

Thanks for the help, but coding 2 joysticks for 2 or 4 motors is about as simple as anything. And I understand how the victor's work completely, I read the manual. I just wanted to see the code for someone's drive system that uses 2 motors w/ 1 joystick that doesn't use another function to limit the range of values to keep it within the bounds of the datatype unsigned int.
  #8   Spotlight this post!  
Unread 30-01-2007, 10:53
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: Drive Code

We don't use the Limit_Mix function, but we do a similar operation. We do all of our math (for this functionality) in 16 bit integers, make sure that it's in range (using a custom MIN_MAX macro), then store it into an output (conveniently aliased).
Code:
#define MAX(variable, max_val)  if (variable > (max_val)) variable = (max_val)
#define MIN(variable, min_val)  if (variable < (min_val)) variable = (min_val)
#define MIN_MAX(variable,min_val,max_val)  MIN((variable),(min_val)); MAX((variable),(max_val))

.....

#define Oi_drive_x                    p1_x
#define Oi_drive_y                    p1_y

#define Rc_analog_out_drive_left       pwm01
#define Rc_analog_out_drive_right      pwm02

....

/* INT16 is typedef'd as int */
INT16  right_drive_speed, left_drive_speed;

/* single stick drive calculation */
left_drive_speed = ((INT16)Oi_drive_y - (INT16)Oi_drive_x + 127);
right_drive_speed = ((INT16)Oi_drive_y + (INT16)Oi_drive_x - 127);

MIN_MAX(left_drive_speed, 0, 254);
MIN_MAX(right_drive_speed, 0, 254);

.....

Rc_analog_out_drive_left = left_drive_speed;
Rc_analog_out_drive_right = right_drive_speed;
  #9   Spotlight this post!  
Unread 30-01-2007, 11:46
65_Xero_Huskie's Avatar
65_Xero_Huskie 65_Xero_Huskie is offline
One T
AKA: Mat
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Michigan
Posts: 697
65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute
Re: Drive Code

^^^^^

That looks like a long version of what we use. Try that out and see if it works, i was just about to post our long version of it
__________________
Min-Max to the Max!
  #10   Spotlight this post!  
Unread 03-02-2007, 22:02
Tureyhall Tureyhall is offline
Registered User
AKA: Thomas Hall
FRC #0668 (Apes Of Wrath)
Team Role: Programmer
 
Join Date: Feb 2006
Rookie Year: 2004
Location: San Jose
Posts: 40
Tureyhall will become famous soon enoughTureyhall will become famous soon enough
Re: Drive Code

We use this code:

Code:
#define DEADZONE 10

  signed int xturn = p1_x - 193;
  signed int yspeed = p2_y - 127;
  signed int turnspeed;
  int percent;
   
  pwm01 = pwm02 = p2_y;

  printf("p1_x=%d\r\n", p1_x);
  printf("xturn=%d\r\n", xturn);
  
  if (!p1_sw_trig) {
	if (xturn < -DEADZONE) { //turning right
	  	percent = 100 * (-xturn - DEADZONE) / (41 - DEADZONE);
	  	percent = (percent > 100) ? 100 : percent;
  	  	turnspeed = p2_y - yspeed * percent / 50;
		printf("turning right=%d\r\n", (int)turnspeed);
		printf("Percent=%d\r\n", (int) percent);
  	  	pwm02 = turnspeed;
      	} else if (xturn > DEADZONE){ //turning left
	 	  	percent = 100 * (xturn - DEADZONE) / (41 - DEADZONE);
		  	percent = (percent > 100) ? 100 : percent;
	  	  	turnspeed = p2_y - yspeed * percent / 50;
       	  	pwm01 = turnspeed;
       	  	printf("turning left=%d\r\n", (int)turnspeed);
		  	printf("Percent=%d\r\n", (int) percent);
	      	}
  }

Technically, this uses two joysticks, one that goes left-right and one that goes forward back.

It should be easy to modify this to work with your system. There are some considerations. The left-right joystick, because of how it's set up, has a range from 127-255 instead of 0-255. This caused some odd calculations, such as the subtracting 193, the dividing by 41 - DEADZONE instead of 117 - DEADZONE, and the dividing by 50 instead of 100.

I'm sure you can make this work.
__________________
/*Nerd Camouflage*/

2005 SVR - 668+1072+840 - Semifinalists.
2006 SVR - 668+1280+1693 - Finalists.
2007 SVR - 668+604+624 - Quarter-finalists, Xerox Creativity Award, two highest scores (290-2, 128-0) at SVR.
2007 Nat's - TBA.
  #11   Spotlight this post!  
Unread 04-02-2007, 01:20
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Drive Code

Well, our code converts joystick 0-255 to signed values in range -127 to +127.

The mixing function is then:

left speed = rotationaxis + directionaxis
right speed = rotationaxis - directionaxis

We add the 127 to the speeds only at the point where the speed values are output to the Victors.


(Basically - take the direction axis value and add the rotation to one wheel, and subtract the rotation from the other)
  #12   Spotlight this post!  
Unread 04-02-2007, 02:03
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: Drive Code

One of the problems I've noticed with trying to skid steer the typical 4 wheel drive robot is that simply backing off on the power on one side isn't enough to get good steering control. The higher powered side can drag the robot along nearly straight. You have to drastically cut back on the power, stop, or even reverse the motor on the inside of the turn.
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
easyC Mechanum Drive Code Kingofl337 Programming 0 12-01-2007 23:48
Where is tank drive in 2005 code? scottmso Programming 7 08-02-2006 22:03
looking for 1 joystick Pbasic drive code Greg Needel Programming 8 02-09-2005 20:35
Translational Drive Code Adam Collet Programming 7 20-01-2003 15:58
TechnoKats Automated Test Drive Code Greg McCoy Programming 1 16-01-2003 17:45


All times are GMT -5. The time now is 16:34.

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