Go to Post Don't let the teams here be so much of an intimidation to you, but instead, an inspiration. They all had to start from the beginning, too. - Amanda Morrison [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 07-02-2005, 00:24
Grizzlie's Avatar
Grizzlie Grizzlie is offline
Registered User
#1214
 
Join Date: Jan 2004
Location: Houston,TX
Posts: 4
Grizzlie is an unknown quantity at this point
Post Solenoid control

I am trying to program the solenoids this year to wherewhen i hold the trigger it activates and when i let go it deactivates. Same as the reverse motion. I wrote this code to do this but it wont work. When i press the trigger the solonoid activates but when i let go it doesnt stop. And it WILL NOT go back when i press the rev button. heres the code i wrote :
Code:
 if (p3_sw_trig);

{              
      relay3_fwd = 1;
}

if (!p3_sw_trig);

{
      relay3_fwd = 0;
}

if (p3_sw_top);

{
      relay3_rev = 1;
}

if (!p3_sw_trig);

{
      relay3_rev = 0;
}
It would be great if someone could explain to me what i did wrong here because i'm fairly new to the C language. But it would be even better if someone could post the exact code to make this work. Thank You for even taking your time to read this post. And also good luck this year!
__________________
"Act Quickly , Think Slowly" - Greek Proverb
  #2   Spotlight this post!  
Unread 07-02-2005, 00:35
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: Solenoid control

Quote:
Originally Posted by Grizzlie
I am trying to program the solenoids this year to wherewhen i hold the trigger it activates and when i let go it deactivates. Same as the reverse motion. I wrote this code to do this but it wont work. When i press the trigger the solonoid activates but when i let go it doesnt stop. And it WILL NOT go back when i press the rev button. heres the code i wrote :
Code:
 if (p3_sw_trig);

{              
      relay3_fwd = 1;
}

if (!p3_sw_trig);

{
      relay3_fwd = 0;
}

if (p3_sw_top);

{
      relay3_rev = 1;
}

if (!p3_sw_trig);

{
      relay3_rev = 0;
}
It would be great if someone could explain to me what i did wrong here because i'm fairly new to the C language. But it would be even better if someone could post the exact code to make this work. Thank You for even taking your time to read this post. And also good luck this year!
Well, I see three immediate problems. One, all of your if statements end in semicolons. That is bad. Two, your last if statement checks !p3_sw_trig instead of !p3_sw_top. Three, I would suggest using else statements, rather than the structure of if statements that you've chosen. Try this:
Code:
if (p3_sw_trig)             
      relay3_fwd = 1;
else
      relay3_fwd = 0;
if (p3_sw_top)
      relay3_rev = 1;
else
      relay3_rev = 0;
If you wanted, you could simplify this even further:
Code:
relay3_fwd=p3_sw_trig?1:0;
relay3_rev=p3_sw_top?1:0;
Simpler, though not quite as easy to read.

<edit>
Hm... now that I think about it, you might even be able to do:
Code:
relay3_fwd=p3_sw_trig;
relay3_rev=p3_sw_top;
I don't have an RC with which to test that, but I know the other two methods will work just fine.
</edit>
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_

Last edited by jgannon : 07-02-2005 at 00:41.
  #3   Spotlight this post!  
Unread 07-02-2005, 00:44
reilly reilly is offline
Registered User
#0771
 
Join Date: Jan 2005
Location: Brooklyn New York
Posts: 23
reilly is an unknown quantity at this point
Re: Solenoid control

Here is the way to do this:

if (p3_sw_trig) //no semi colons for functions

{
relay3_fwd = 1;
}

else (!p3_sw_trig)

{
relay3_fwd = 0;
}

else if (p3_sw_top) //or if is fine here also

{
relay3_rev = 1;
}

else

{
relay3_rev = 0;
}

Last edited by reilly : 07-02-2005 at 00:47.
  #4   Spotlight this post!  
Unread 07-02-2005, 17:41
Grizzlie's Avatar
Grizzlie Grizzlie is offline
Registered User
#1214
 
Join Date: Jan 2004
Location: Houston,TX
Posts: 4
Grizzlie is an unknown quantity at this point
Re: Solenoid control

[quote] Two, your last if statement checks !p3_sw_trig instead of !p3_sw_topQUOTE]

o yea that isnt the problem because i didnt put that there i kinda just that laswt bit of code from memory. but the semicolon would explainthe syntax errors . Ok im gonna try your code and hope it works. Thanks!
__________________
"Act Quickly , Think Slowly" - Greek Proverb
  #5   Spotlight this post!  
Unread 16-02-2005, 17:35
Grizzlie's Avatar
Grizzlie Grizzlie is offline
Registered User
#1214
 
Join Date: Jan 2004
Location: Houston,TX
Posts: 4
Grizzlie is an unknown quantity at this point
Re: Solenoid control

where in the user_routines.c would i put this code? or is there a diiferent file where this code would belong?
__________________
"Act Quickly , Think Slowly" - Greek Proverb
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
2005 RadioShack® Innovation in Control Award! dez250 General Forum 10 10-03-2005 21:29
Single vs double solenoid valve operation Scott358 Pneumatics 0 29-01-2005 11:47
What do you wish you knew about the new control system? Joe Ross Control System 2 09-01-2004 21:47
Ok, how much is the control system worth? archiver 2001 6 23-06-2002 22:05
more control options smokescreen Technical Discussion 17 05-03-2002 15:41


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

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