Go to Post I'm not overdosed, I'm not even addicted. I just choose to never, ever, ever leave FIRST. - SL8 [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-2008, 16:22
team877's Avatar
team877 team877 is offline
Registered User
FRC #0877 (Cub Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2001
Location: North Dakota
Posts: 52
team877 is an unknown quantity at this point
Relay program?

I need help trying to figure out a program. I want to engage a relay when my right and left drive motors are between 125 and 129. I thought it would be something along the lines of 125 < x < 129 but i cant seem to get this to function can anyone help me out?
  #2   Spotlight this post!  
Unread 29-01-2008, 16:31
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: Relay program?

Comparisons don't "chain" like that in C. Do it this way:
Code:
if ( (125 < x) && (x < 129) )
The inner parentheses aren't strictly necessary, but I think they make it much more readable.
  #3   Spotlight this post!  
Unread 29-01-2008, 16:40
Code Monkey Code Monkey is offline
Registered User
FRC #1622
 
Join Date: Dec 2007
Location: San Diego
Posts: 10
Code Monkey is an unknown quantity at this point
Re: Relay program?

do a printf of x. You may not be getting the PWM value you think you are.
We have had problems with pwmXX values not being available in all of our subroutines. If that is working, try a nested if-not as elegant, but it works.
Lastly try increasing the band you are allowing on 127-your offset may be off or you go through it too fast.

Check that your value to the relay routine call is a logical 0 or 1 (try forcing it)
  #4   Spotlight this post!  
Unread 30-01-2008, 19:40
team877's Avatar
team877 team877 is offline
Registered User
FRC #0877 (Cub Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2001
Location: North Dakota
Posts: 52
team877 is an unknown quantity at this point
Re: Relay program?

i was thinking i needed to set my x value to say (pwm 1) if i wanted it to work with my pwm. But i tried using pwm control with the x variable inside it and it just makes my pwm continually run is there something i'm missing
  #5   Spotlight this post!  
Unread 30-01-2008, 22:40
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: Relay program?

Show us the code you're trying to make work. Tell us exactly what you want it to do, and we can tell you what to change to make it do that.
  #6   Spotlight this post!  
Unread 02-02-2008, 12:03
team877's Avatar
team877 team877 is offline
Registered User
FRC #0877 (Cub Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2001
Location: North Dakota
Posts: 52
team877 is an unknown quantity at this point
Smile Re: Relay program?

here is our code you asked for....
Attached Files
File Type: doc Break program.doc (115.5 KB, 99 views)
  #7   Spotlight this post!  
Unread 02-02-2008, 12:39
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: Relay program?

where are you setting the value of x?
__________________
"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."
  #8   Spotlight this post!  
Unread 02-02-2008, 13:26
xrabohrok's Avatar
xrabohrok xrabohrok is offline
hunter of errors
FRC #1208 (The Metool Brigade)
Team Role: Programmer
 
Join Date: Jan 2006
Location: O'Fallon
Posts: 62
xrabohrok is an unknown quantity at this point
Re: Relay program?

Where is this file in the overall scheme of the robot? I don't know how to look at easy C to intuitively know what is going on, but it could be you are calling the function in the wrong place. Is the function called in user_routines.c? It should probably called somewhere from within Default_Routines(). I am assuming the easy C version of the code is organized the same way as just regular code.
__________________
"It's programming's fault" may be a viable excuse for just about everything, except the robot falling apart.

It will 'cause it can!

constants aren't. variables won't.
  #9   Spotlight this post!  
Unread 02-02-2008, 20:13
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: Relay program?

Quote:
Originally Posted by team877 View Post
here is our code you asked for....
Code:
void operatorControl ( void )
{
	unsigned char x;

	while ( 1 )
	{
		SetPwm ( 2 , x ) ; //  We’re setting are variable to the motor we want it to measure
		if ( 125 < x && x < 129 ) 
		{ // We want this relay to engage between these speeds
			SetRelay ( 1 , 1 , 0 ) ;
		}
		else
		{ // And if not turn the relay off
			SetRelay ( 1 , 0 , 0 ) ;
		}
	}
}
I don't see anything that sets the value of x. Did you forget the line that reads the joystick value?

(Is there a reason you posted it as a Word document containing a picture, instead of just copying the text? I don't use Word, and it was inconvenient to convert your file to a readable form.)
  #10   Spotlight this post!  
Unread 04-02-2008, 00:53
team877's Avatar
team877 team877 is offline
Registered User
FRC #0877 (Cub Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2001
Location: North Dakota
Posts: 52
team877 is an unknown quantity at this point
Re: Relay program?

the Setpwm (1, x) is a window that you put your variable in so "x" is set to the value of pwm 1
  #11   Spotlight this post!  
Unread 04-02-2008, 07:10
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: Relay program?

Quote:
Originally Posted by team877 View Post
the Setpwm (1, x) is a window that you put your variable in so "x" is set to the value of pwm 1
Isn't it the other way around? As an output function, SetPwm( 1, x ) sets pwm 1 to the value of x. I'm not aware of a built-in way to read the present value of a pwm output using easyC.

So where in your program do you actually control the pwm output that you want to use as the trigger for your relay?
  #12   Spotlight this post!  
Unread 04-02-2008, 11:11
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,795
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Relay program?

Normal operation would be to:

1) Get the desired drive value from the driver--GetOIAInput()

2) Do your tests on when you want your relay to be active--if () else

3) Output your relay command--SetRelay()

4) Set your PWM Output--SetPWM()
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
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
Instance relay Team_486 Programming 0 28-03-2007 09:56
Relay Commands Matt Krass Programming 6 18-02-2006 23:03
Relay Assignments MulletFish Programming 9 27-01-2005 14:15
Relay fault archiver 2000 2 23-06-2002 23:36
Relay Outputs OddOne Technical Discussion 3 01-02-2002 19:52


All times are GMT -5. The time now is 08:44.

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