Go to Post Which meant that I was completely unprepared when the congealing large globules suddenly accelerated back towards me at 64 ft/sec/sec. - dlavery [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 02-02-2008, 13:24
RRA4LIFE2 RRA4LIFE2 is offline
Registered User
FRC #2595
 
Join Date: Jan 2008
Location: Los Angeles, California
Posts: 9
RRA4LIFE2 is on a distinguished road
Default code??

We are a rookie team, team 2595. We want to use the default code that we got but don't know if it'll work. We are running a 2 motor drive and the default code is a 4 motor drive???
How do we change the default code to work for teleoperated for a 2 motor drive?
  #2   Spotlight this post!  
Unread 02-02-2008, 13:39
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: Default code??

Alright, are you using MPLAB or EasyC? If you're using EasyC, I really can't help... With MPLAB, you should be able to comment out all lines that refer to pwms that don't exist on your robot and have whatever you're using work fine.
  #3   Spotlight this post!  
Unread 02-02-2008, 14:32
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: Default code??

Quote:
Originally Posted by RRA4LIFE2 View Post
We are a rookie team, team 2595. We want to use the default code that we got but don't know if it'll work. We are running a 2 motor drive and the default code is a 4 motor drive???
How do we change the default code to work for teleoperated for a 2 motor drive?
With MPLAB, the following should work for tank drive:

Code:
pwm01 = pwm02 = p1_y;
pwm03 = pwm04 = p2_y;
This assumes pwms 1 and 2 are the left wheels and port 1 is the left joystick; pwms 3 and 4 are the right wheels, and port 2 is the right joystick.

When both joysticks are forwards, all motors are forward and the robot goes forward. When both are back, the robot goes backwards. When one joystick is forward and one is backwards, the left and right motors move in opposite directions and the robot twists clockwise or counterclockwise.
  #4   Spotlight this post!  
Unread 02-02-2008, 15:38
usbcd36's Avatar
usbcd36 usbcd36 is offline
Registered User
AKA: "DOS"
FRC #2399 (The Fighting Unicorns)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Solon, OH
Posts: 151
usbcd36 is a jewel in the roughusbcd36 is a jewel in the roughusbcd36 is a jewel in the rough
Re: Default code??

Quote:
Originally Posted by jacobhurwitz View Post
With MPLAB, the following should work for tank drive:

Code:
pwm01 = pwm02 = p1_y;
pwm03 = pwm04 = p2_y;
This assumes pwms 1 and 2 are the left wheels and port 1 is the left joystick; pwms 3 and 4 are the right wheels, and port 2 is the right joystick.

When both joysticks are forwards, all motors are forward and the robot goes forward. When both are back, the robot goes backwards. When one joystick is forward and one is backwards, the left and right motors move in opposite directions and the robot twists clockwise or counterclockwise.


This also assumes that forwards is all motors moving in the same direction or that the wires for one side are hooked up backwards. If this is not the case, your robot will spin when you push both joysticks forwards and go straight with one joystick forwards and the other backwards. To correct this, subtract the offending side (i.e., the side that's going in reverse when you push the stick forwards) from 254 to reverse the direction.

Back to your original question…

If you choose to use the default code's "1 Joystick Drive", read on…

If you are using MPLAB and programming in C, you will not actually need to do anything to the code (except what I said above, except you'd be subtracting the Limit_Mix result from 254) unless you want to use the PWM outputs for the second motors for something else. Simply connect the left-hand motor's speed controller to PWM 13 or 14, and the right-hand motor's speed controller to 15 or 16 and leave the other ports unconnected.

If you do want to use those PWM outputs for something else, you need to locate the following lines in user_routines.c:

Quote:
p1_x = 255 - p1_y;
p1_y = 255 - pwm05;

pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
…and modify them so that they only use one PWM output each, like so:

Quote:
p1_x = 255 - p1_y;
p1_y = 255 - pwm05;

pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = Limit_Mix(2000 + p1_y - p1_x + 127);

…which will free up PWM outputs 13 and 16 for other things. Note that you can use any two PWMs you want for driving motor control; it doesn't have to be 13, 14, 15 and 16, or 14 and 15; if you want to use PWMs 1 and 2 for driving, just change the variables from pwm14 and pwm15 to pwm01 and pwm02, respectively.

Last edited by usbcd36 : 02-02-2008 at 15:43. Reason: Durr…boolean error…
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
Problems integrating CMUCAM code and IFI Default Code Windward Programming 2 06-02-2007 16:48
Modified default code gives "code violation" scottmso Programming 8 10-02-2006 23:17
problems using gyro/adc code with camera default code tanstaafl Programming 7 22-01-2006 23:09
user code to default code phoenixomega001 Programming 5 09-01-2005 00:09
Inserting Naviagation code into Default code? actorindp Programming 3 28-01-2004 18:12


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

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