Go to Post What can you do? The more time you waste here speculating the less time you have to work on the robot. Go! Build Robots! Now! - Jessica Boucher [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 18-01-2008, 22:13
Spartan151's Avatar
Spartan151 Spartan151 is offline
TCU Bound (Class of 2013)
AKA: Sean
FRC #2920
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Holly Springs, MS
Posts: 86
Spartan151 will become famous soon enough
A New Programmer

Hi. I'm Sean, current leader of team 2065. We have no real programming abilities as of yet. However, after printing off a guide I found here, I have a somewhat decent understanding of how to write it....I think.
I wrote a test code based off of what was on the 12-page manual, and I would like someone who has some programming experience to take a look at it and comment on it. I need to know what I'm doing right and wrong.
The program I have written is a code for autonomous mode. The actions encompass the following:

drive forward for 3 seconds
turn left for half a second
drive foward for one and a half seconds
turn left again for half a second
drive forward for three seconds
turn left for half a second
drive forward for one second
stop until the remaining time is up.

Please, comments are greatly appreciated.

Note: I deliberately left it as a .txt file for easy access.
Attached Files
File Type: txt autonomous loop code first version.txt (1,005 Bytes, 249 views)
  #2   Spotlight this post!  
Unread 18-01-2008, 22:17
Laaba 80 Laaba 80 is offline
Registered User
AKA: Joey
FRC #1714 (MORE Robotics)
Team Role: Alumni
 
Join Date: Dec 2007
Rookie Year: 2001
Location: San Jose, CA
Posts: 495
Laaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond repute
Re: A New Programmer

Looks pretty good for the first time. One thing though, once you find out it works, you will want to make it go faster, because right now it is going a little under half speed, and I'm assuming this is code to race around the track, so you will want to go fast. Nice job, if you have other questions, let me know.
Joey
__________________
Driving Record - 75-43-8
Coaching Record - 92-65
  #3   Spotlight this post!  
Unread 18-01-2008, 22:31
Spartan151's Avatar
Spartan151 Spartan151 is offline
TCU Bound (Class of 2013)
AKA: Sean
FRC #2920
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Holly Springs, MS
Posts: 86
Spartan151 will become famous soon enough
Re: A New Programmer

Thank you. I chose small numbers because I just wanted to do a test, and I do intend to increase those numbers once I'm sure that I did it right. I know I'll have to do some checking on the right motor, because for some reason it seems a little laggier than the left motor on our robot.
There'll be a bunch of fine tuning involved, but from your standpoint, what would be a good number for some good speeds? We'll be going for every possible option that we can.
There'll be a lot of testing come Tuesday (That's when our materials for the tower and arm come in) to see whether or not it works.

Okay. Here's a question. Our team's computer both has EasyCPro and the Compiler, but how exactly do I go extracting the default, editing the code, and putting it back in the RC?
  #4   Spotlight this post!  
Unread 18-01-2008, 22:40
Laaba 80 Laaba 80 is offline
Registered User
AKA: Joey
FRC #1714 (MORE Robotics)
Team Role: Alumni
 
Join Date: Dec 2007
Rookie Year: 2001
Location: San Jose, CA
Posts: 495
Laaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond repute
Re: A New Programmer

Im not sure with Easy C, I use MP Lab. I'll tell you how its done in MP Lab, and hopefully you can figure Easy C out. In the Kit, you got some serial cables. plug the red cable into the robot controller and the operator interface with the joysticks. It says TEATHER where you put that in. Take the black cable and plug into the robot controller. I cant remember what the port says, but I'm guessing it says something like PROGRAM. If you are using a newer laptop you may run into some problems connecting to the computer because they dont have serial ports any more, let me know if that is your case. When everything is turned on press and hold the PROG button on the robot controller until some lights turn yellow. Open up the compiler, open up the hex file that you just built and download into the robot. Hopefully that helped. If there is any thing else let me know and I'll do my best to help.
Joey
__________________
Driving Record - 75-43-8
Coaching Record - 92-65
  #5   Spotlight this post!  
Unread 18-01-2008, 22:45
Spartan151's Avatar
Spartan151 Spartan151 is offline
TCU Bound (Class of 2013)
AKA: Sean
FRC #2920
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Holly Springs, MS
Posts: 86
Spartan151 will become famous soon enough
Re: A New Programmer

Thanks very much. I'll keep you updated as to how it progresses.

So, I can use MPLab to extract the default code and edit it, correct?

Last edited by Spartan151 : 18-01-2008 at 22:47. Reason: Needed to ask an additional question.
  #6   Spotlight this post!  
Unread 18-01-2008, 22:46
Laaba 80 Laaba 80 is offline
Registered User
AKA: Joey
FRC #1714 (MORE Robotics)
Team Role: Alumni
 
Join Date: Dec 2007
Rookie Year: 2001
Location: San Jose, CA
Posts: 495
Laaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond repute
Re: A New Programmer

Ok, Good Luck
Joey
__________________
Driving Record - 75-43-8
Coaching Record - 92-65
  #7   Spotlight this post!  
Unread 20-01-2008, 05:56
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: A New Programmer

Quote:
Originally Posted by Spartan151 View Post
So, I can use MPLab to extract the default code and edit it, correct?
You'll need to get the default code from the IFI website here.

- Once you've extracted all the files, open the FrcCode.mcw file. It should load MPLAB.
- You should see two windows, the Project Browser and the Output window. In the Project Browser, double click on user_routines_fast.c
- Scroll down to the User_Autonomous_Code function. Insert the autonomous code you written after the line that reads
Code:
/* Add your own autonomous code here. */
- Follow the directions here on how to download your code to your robot.

Good luck
--Ryan

P.S.: Remember to check your semicolons!
  #8   Spotlight this post!  
Unread 20-01-2008, 11:26
paulcd2000's Avatar
paulcd2000 paulcd2000 is offline
Accidentally speaks in C
AKA: Paul Dagnelie
FRC #1719 (The Umbrella Corp.)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore
Posts: 368
paulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the rough
Send a message via AIM to paulcd2000
Re: A New Programmer

Quote:
Originally Posted by Spartan151 View Post
I know I'll have to do some checking on the right motor, because for some reason it seems a little laggier than the left motor on our robot.
THat's usually the case. It happens (to us anyway) because the motor on the right wheel is turned around. The motors don't run the same speeds forwards an backwards, so when the left is running full fwd and the right full bwd, they're in the same direction, but the speeds are off slightly. It doesn't change a lot if ur moving slowly, since the system has a lot of friction, but when you gear up the speeds, the robot doesn't go anywhere near straight (speaking from personal experience in a narrow hallway)
__________________
"People don't say 'It's just a game' when their team is winning!" -- Scott Adams

5.5 students (on average)* $7/h *210 hours/student= $8085 of labor, all volunteered (not counting mentors', who are each that much)

We have blades on our robot?! ***sweeeeeet***

There are 11 types of people in the world. Those who can read binary, those who can't, and those who say this joke is supposed to be, "There are 10 types of people in the world. Those who can read binary and those who have a life."
  #9   Spotlight this post!  
Unread 20-01-2008, 16: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: A New Programmer

Quote:
Originally Posted by paulcd2000 View Post
It happens (to us anyway) because the motor on the right wheel is turned around. The motors don't run the same speeds forwards an backwards, so when the left is running full fwd and the right full bwd, they're in the same direction, but the speeds are off slightly.
The CIM motors don't have significant bias. They'll run the same speed in both directions. If you're reversing the motor direction for the other side of the robot by swapping the wires, the speeds should match well.

However, the Victor speed controllers do appear to have an asymmetric response around the defined neutral value of 127. If you're accounting for the need to reverse the motor direction in code, you'll probably notice this. When we tested things last year, true neutral seemed to be closer to 132.
  #10   Spotlight this post!  
Unread 20-01-2008, 20:10
marccenter's Avatar
marccenter marccenter is offline
Registered User
FRC #3548 (RoboRavens2)
Team Role: Coach
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Royal Oak
Posts: 406
marccenter has a spectacular aura aboutmarccenter has a spectacular aura about
Re: A New Programmer

Looking at your code, I would recommend that you replace some of your absolute numbers with Calibration
values for future ease of Use. That way,you can change one Calibration value at the top of your program and it
changes all the values in your program saving you valuable editing time and the possibility of an editing bo-bo. For Example, if Fwd is > 127 for pwm outputs, try something Like Fwd_Low = 150 ; Fwd_Med = 170 ;Fwd_High = 190 , Similiarly, if
Rwd is < 127 how about Rev_Low = 104, Rev_Med = 84, and Rev_High = 64.
__________________
Marc Center
FIRST FRC Mentor/Coach - Team 3548 Royal Oak RoboRavens#2 - on Sabbatical 2017 season
marc.center@gmail.com
Mobile: 248-255-7377

Last edited by marccenter : 20-01-2008 at 20:12. Reason: Improve response
  #11   Spotlight this post!  
Unread 20-01-2008, 22:03
Spartan151's Avatar
Spartan151 Spartan151 is offline
TCU Bound (Class of 2013)
AKA: Sean
FRC #2920
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Holly Springs, MS
Posts: 86
Spartan151 will become famous soon enough
Re: A New Programmer

Thanks for all the help guys. You've all been great. I'll be testing those things ASAP. Now, there are some other things I need help with, also. Our robot's claw is run by pneumatics. On our arm control, I need to program two buttons on the joystick (Or one to do both functions) to open and close the claw. How would I go about porgramming the buttons?
  #12   Spotlight this post!  
Unread 20-01-2008, 22:08
Spartan151's Avatar
Spartan151 Spartan151 is offline
TCU Bound (Class of 2013)
AKA: Sean
FRC #2920
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Holly Springs, MS
Posts: 86
Spartan151 will become famous soon enough
Re: A New Programmer

Quote:
Originally Posted by marccenter View Post
Looking at your code, I would recommend that you replace some of your absolute numbers with Calibration
values for future ease of Use. That way,you can change one Calibration value at the top of your program and it
changes all the values in your program saving you valuable editing time and the possibility of an editing bo-bo. For Example, if Fwd is > 127 for pwm outputs, try something Like Fwd_Low = 150 ; Fwd_Med = 170 ;Fwd_High = 190 , Similiarly, if
Rwd is < 127 how about Rev_Low = 104, Rev_Med = 84, and Rev_High = 64.
Could you explain exactly what you mean? I'm having difficulty understanding, partly because the computer I'm using now doesn't have MPLAB and partly because I only understand autonomous programming to a degree.
  #13   Spotlight this post!  
Unread 20-01-2008, 22:35
blaxbb blaxbb is offline
Ohio State Engineering Scholar
AKA: Brian Barrett
FRC #2331
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Vernon, New Jersey
Posts: 131
blaxbb is just really niceblaxbb is just really niceblaxbb is just really niceblaxbb is just really niceblaxbb is just really nice
Re: A New Programmer

under ///*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/ or at the top of any .c file

to make it easier you should define your speeds so that you can update all of your speed values without changing every single one.

you can define your speeds once and call them multiple times
Code:
#define stop 127
#define forward 200
#define reverse 50
then instead of saying
Code:
pwm01 = 200;
pwm02 = 50;
you can say
Code:
pwm01 = forward;
pwm02 = reverse;
this makes it so much easier if you need to change a value quickly (at a competition)
__________________
"Whether you think you can or think you can’t, you’re right." - Henry Ford
www.vthsrobotics.org
  #14   Spotlight this post!  
Unread 21-01-2008, 10:06
Spartan151's Avatar
Spartan151 Spartan151 is offline
TCU Bound (Class of 2013)
AKA: Sean
FRC #2920
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Holly Springs, MS
Posts: 86
Spartan151 will become famous soon enough
Re: A New Programmer

Okay. It's beginning to make sense now. I'll give it a shot.
  #15   Spotlight this post!  
Unread 21-01-2008, 22:15
Spartan151's Avatar
Spartan151 Spartan151 is offline
TCU Bound (Class of 2013)
AKA: Sean
FRC #2920
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Holly Springs, MS
Posts: 86
Spartan151 will become famous soon enough
Re: A New Programmer

Okay. Once I get the basics done, I will need help programming the IR board functions, and programming the pneumatics for our claw to the arm joystick. I'll let you know when we get to that stage, but please, feel free to explain ahead of time. It'll help our team get a better understanding so there's no head-scratching later.
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
NEW PROGRAMMER!!!!! NEED HELP!!!! delphi demon Programming 5 19-04-2007 13:22
pic: Team 1249's new programmer roborat Extra Discussion 4 23-06-2006 22:02
Senior Programmer: advice on training new recruits Jeff_Rice Programming 9 04-01-2005 16:59
Help for New Programmer Mike375 Programming 3 27-09-2001 09:04


All times are GMT -5. The time now is 20:27.

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