Go to Post I learned... that I need to learn more. - Erin Rapacki [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 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
  #2   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?
  #3   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.
  #4   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
  #5   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.
  #6   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.
  #7   Spotlight this post!  
Unread 21-01-2008, 23:09
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
Relays and IR Board

Quote:
Originally Posted by Spartan151 View Post
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.
This is where the electronics and programming team/person has to work together.

The pneumatic cylinders are piped by solenoids (electronic valves,) which are controlled by a spike (relay.)

Relays don't use the analog 0-254 scale. They are essentially digital outputs that can be either forward, off, or reverse.

You map the relays the same way that you map speed controllers.

Code:
relay1_fwd = p1_sw_trig;
That would set relay1 to be forward every time your joystick 1 trigger is held.

IFI has a list of the joystick inputs here. pdf warning



As far as the IR, you need to read the digital input (1 or 0) and pass it through a conditional (if, else, switch) to execute a command.

Code:
if (rc_dig_in01 == 1) {
     pwm01 = pwm02 = 200;
     }
else {
     pwm01 = pwm02 = 127;
}
change rc_dig_in01 to match up with the digital input that was wired to your bot

the reference docs to wire and train the IR board are here. pdf warning
__________________
"Whether you think you can or think you can’t, you’re right." - Henry Ford
www.vthsrobotics.org
  #8   Spotlight this post!  
Unread 22-01-2008, 19:30
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. Next question: Is it possible to program the joystick trigger to, when squeezed the first time, open the claw, and when pressed a second time, closes the claw?

Also, where do these code lines fit in at?

Last edited by Spartan151 : 22-01-2008 at 19:45.
  #9   Spotlight this post!  
Unread 22-01-2008, 23:21
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

Quote:
Originally Posted by Spartan151 View Post
Okay. Next question: Is it possible to program the joystick trigger to, when squeezed the first time, open the claw, and when pressed a second time, closes the claw?

Also, where do these code lines fit in at?
I've been trying to figure that out too, can anyone else fill in.

I'm pretty sure you would have to write a toggle function, but I'm not exactly sure how it should work.
__________________
"Whether you think you can or think you can’t, you’re right." - Henry Ford
www.vthsrobotics.org
  #10   Spotlight this post!  
Unread 22-01-2008, 23:41
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,112
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

Examples of toggle functions are common on the Chief Delphi forums. Here's another:
Code:
  :
  :
  static char prev_trig = 0;
  static char toggle = 0;
  :
  if (p1_trig && !prev_trig)
  {
    toggle = !toggle;
  }
  prev_trig = p1_trig;
  :
This will switch toggle from 0 to 1, or vice versa, each time the port 1 joystick trigger is depressed. You can test its value to decide what to do next.
  #11   Spotlight this post!  
Unread 23-01-2008, 09:12
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 Alan Anderson View Post
Examples of toggle functions are common on the Chief Delphi forums. Here's another:
Code:
  :
  :
  static char prev_trig = 0;
  static char toggle = 0;
  :
  if (p1_trig && !prev_trig)
  {
    toggle = !toggle;
  }
  prev_trig = p1_trig;
  :
This will switch toggle from 0 to 1, or vice versa, each time the port 1 joystick trigger is depressed. You can test its value to decide what to do next.
Okay. Taking this code, where do I write in the relay values, if they need to be written in? Or is that done with the previous code for the relay values?
  #12   Spotlight this post!  
Unread 23-01-2008, 17:50
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. Here's another problem. I have the code written, but I keep getting a syntax error every time I try to build. How exactly do I run MPLAB? Also, where do those codes involving the toggling and pneumatics fit in?
  #13   Spotlight this post!  
Unread 23-01-2008, 18:34
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

A syntax error means that typed something in your code wrong, forgot a semicolon, mistyped a variable, etc.

in MPLAB where it says syntax error
Code:
user_routines_fast.c:27:Error: syntax error
The number 27 after the file matches the line that the error is on.

Can you compile the default code?
__________________
"Whether you think you can or think you can’t, you’re right." - Henry Ford
www.vthsrobotics.org
  #14   Spotlight this post!  
Unread 23-01-2008, 00:06
Jim E Jim E is offline
Registered User
FRC #1523 (M.A.R.S.)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Lantana, FL
Posts: 188
Jim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond repute
Re: A New Programmer

Hi,

You can try this, but I don't make any guarantee.

Toggle_gripper(current state)
{
int temp_state;
If ((p3_sw_trig==TRUE)&&( current _state== CLOSED)
temp_state=current_state;

else if (p3_sw_trig==TRUE)
temp_state=OPEN;

else if ((p3_sw_trig==FALSE)&&(current_state==OPEN))
temp_state=current_state;

else if ((p3_sw_trig==FALSE)
temp_state=CLOSED;

} return (temp_state);

In you Default _Routine, simply call the function:


pwm_state=Toggle_Gripper(current_pwm);
if (current_pwm<>pwm_state)
pwm=pwm_state;

I'm writing this off the cuff, you will need to correct the syntax and apply your own values for the pwm assignments, but it looks plausable. Good luck.
__________________
Team MARS = 1.523 AU from the SUN!

Jim E.
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 09:08.

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