Go to Post Are we really at the point where the only useful thing we can discuss is Dean's choice in timekeeping apparel? The man has a watch. He uses it to tell time. Do we really care how much it is worth, or who made it? I would be much more interested in what he does, not what he wears. - 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 21-02-2004, 18:51
fred's Avatar
fred fred is offline
More Grizzle
None #0341 (Daisy)
Team Role: Programmer
 
Join Date: Jan 2003
Location: Ambler
Posts: 132
fred is on a distinguished road
Using Relays in Code

We ran out of speed controllers (our "genius" mechanics decided that we needed that many motors) and we are using relays and spikes right now. I am trying to use relays in the code and hitting some problems. Here is what I have now.

if(p3_sw_aux1 == 1){
relay1_fwd = 127;
relay1_rev = 0;
}

else if(p3_sw_aux2 == 1){
relay1_fwd = 0;
relay1_rev = 127;
}


else
relay1_fwd = 254;
relay1_rev = 0;

the p3_sw_aux1 part appears to work and the motor doesn't move when nothing is done to it. But we are having some problems with that p3_sw_aux2 part. Any suggestions or comments would be greatly appreciated.
__________________
"The distance between genius and insanity is measured only by success."

-Anonymous
  #2   Spotlight this post!  
Unread 21-02-2004, 19:27
Vladimir Vladimir is offline
the Impaler
#1064 (Wild Beast)
Team Role: Programmer
 
Join Date: Mar 2003
Location: South Milwaukee, WI
Posts: 6
Vladimir is an unknown quantity at this point
Send a message via ICQ to Vladimir Send a message via AIM to Vladimir Send a message via Yahoo to Vladimir
Re: Using Relays in Code

Quote:
Originally Posted by fred
We ran out of speed controllers (our "genius" mechanics decided that we needed that many motors) and we are using relays and spikes right now. I am trying to use relays in the code and hitting some problems. Here is what I have now.

if(p3_sw_aux1 == 1){
relay1_fwd = 127;
relay1_rev = 0;
}

else if(p3_sw_aux2 == 1){
relay1_fwd = 0;
relay1_rev = 127;
}


else
relay1_fwd = 254;
relay1_rev = 0;

the p3_sw_aux1 part appears to work and the motor doesn't move when nothing is done to it. But we are having some problems with that p3_sw_aux2 part. Any suggestions or comments would be greatly appreciated.

Relay outputs are 1 or 0 values, forward is 1 (on) or 0 (off), same for reverse. They have no speed control. This also means you can assign values directly from buttons. I'm not exactly sure what you were going for, but this will make aux1 make relay1 go forward, aux2 make relay1 go backward, neither button and relay outputs no power:

Code:
relay_1_fwd = p3_sw_aux1;
relay_1_rev = p3_sw_aux2;
Hope this helps.
__________________
B.R.E.W. (Better Robots Engineered Wisely)
  #3   Spotlight this post!  
Unread 21-02-2004, 19:28
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Using Relays in Code

the relayX_fwd and relayX_rev variables don't function like pwm outputs - just assign them a value of 1 or 0.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #4   Spotlight this post!  
Unread 21-02-2004, 19:29
fred's Avatar
fred fred is offline
More Grizzle
None #0341 (Daisy)
Team Role: Programmer
 
Join Date: Jan 2003
Location: Ambler
Posts: 132
fred is on a distinguished road
Re: Using Relays in Code

And......................it works.

Thank you to Vladimir and deltacoder.
__________________
"The distance between genius and insanity is measured only by success."

-Anonymous
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
What is your most prefered programming language? Hailfire Programming 156 19-01-2005 21:42
Interrupt timer, executing code asap? SeanCassidy Programming 10 07-03-2004 01:47
Inserting Naviagation code into Default code? actorindp Programming 3 28-01-2004 18:12
Autonomous code PBoss Programming 7 14-01-2003 15:29
Does your team use the Default code. Jeff McCune General Forum 2 09-01-2003 14:46


All times are GMT -5. The time now is 05:18.

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