Go to Post Finally!!! I love hugs. - Eugenia Gabrielov [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 12-02-2008, 17:35
captainking's Avatar
captainking captainking is offline
Level 85 Programmer
FRC #0168 (MIB)
Team Role: Programmer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: North Miami Beach
Posts: 41
captainking is an unknown quantity at this point
pwm controlled by relay

in our code we want to be able to control pwms through buttons on the controller, but the only place we can find button commands are on relay blocks, and IF statements haven't worked for us so far, any ideas? Thanks in advance.
  #2   Spotlight this post!  
Unread 12-02-2008, 17:41
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: pwm controlled by relay

You can use relays to control motors, but you wont have the speed control that using a PWM value would give you.

When you program it assign a button to forward and reverse

Code:
relay1_fwd = p1_sw_aux1;
relay1_rev = p1_sw_aux2;
__________________
"Whether you think you can or think you can’t, you’re right." - Henry Ford
www.vthsrobotics.org
  #3   Spotlight this post!  
Unread 12-02-2008, 17:56
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,384
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: pwm controlled by relay

Quote:
Originally Posted by captainking View Post
in our code we want to be able to control pwms through buttons on the controller, but the only place we can find button commands are on relay blocks, and IF statements haven't worked for us so far, any ideas? Thanks in advance.
We have done exactly this in the past.

Code:
if (p1_sw_top && !p1_sw_trig)
{
pwm04 = 225;
}
else if (!p1_sw_top && p1_sw_trig)
{
pwm04 = 50;
}
else
{
pwm04 = 127;
}
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #4   Spotlight this post!  
Unread 12-02-2008, 18:03
Boydean's Avatar
Boydean Boydean is offline
The Blue Alliance
no team
Team Role: Alumni
 
Join Date: Apr 2007
Rookie Year: 2003
Location: SC
Posts: 319
Boydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant future
Send a message via AIM to Boydean
Re: pwm controlled by relay

We have to do the same thing, but we have to have the motor turn one direction all the time and the other only when the button is pressed.

Code:
if(p2_sw_aux1 == 1)
	{
		relay1_fwd = 1;
		relay1_rev = 0;
	}
else
	{
		relay1_fwd = 0;
		relay1_rev = 1;
	}
__________________
  #5   Spotlight this post!  
Unread 12-02-2008, 18:38
captainking's Avatar
captainking captainking is offline
Level 85 Programmer
FRC #0168 (MIB)
Team Role: Programmer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: North Miami Beach
Posts: 41
captainking is an unknown quantity at this point
Re: pwm controlled by relay

I think I should be a little more specific, we want to be able to switch from one set up to another by the push of a button, but we can't find a way to switch pwms through that. All of our if statements haven't worked, is there a way to assign for example, tank drive to trigger and arcade mode to aux?
  #6   Spotlight this post!  
Unread 12-02-2008, 21:27
usbcd36's Avatar
usbcd36 usbcd36 is offline
Registered User
AKA: "DOS"
FRC #2399 (The Fighting Unicorns)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Solon, OH
Posts: 151
usbcd36 is a jewel in the roughusbcd36 is a jewel in the roughusbcd36 is a jewel in the rough
Re: pwm controlled by relay

You could use static variables to achieve these means.

Code:
static unsigned char Tank_Drive = 1; //default is tank drive

if (p1_sw_trig) Tank_Drive = 1; // enable tank drive
else if (p1_sw_aux1) Tank_Drive = 0; // enable other drive system

if(Tank_Drive)
{
     // code for tank drive here
}
else
{
     // code for other drive system here
}
What this will do is switch to tank drive when you press the trigger and switch to another drive system when you press the aux button. Not when you hold them down, but when you press them.

Last edited by usbcd36 : 12-02-2008 at 21:30.
  #7   Spotlight this post!  
Unread 13-02-2008, 01:29
neutrino15's Avatar
neutrino15 neutrino15 is offline
plɹoʍ ollǝɥ
AKA: Jordan Perr
FRC #0694 (Stuypulse)
 
Join Date: Feb 2007
Rookie Year: 2007
Location: New York City
Posts: 162
neutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really nice
Re: pwm controlled by relay

Quote:
Originally Posted by usbcd36 View Post
You could use static variables to achieve these means.
Yep. That is exactly what we do to produce an "on/off" button effect. It has to be modified slightly to use 1 button for "toggle" instead of 2 distinct "tank" and "other" buttons. I don't know why you want to drag a relay into this, and I am almost sure I don't understand what you are asking. Could you explain better?

Quote:
but the only place we can find button commands are on relay blocks
What about buttons on the joysitck? Digital inputs on the OI? (Or even resistors in parallel?)
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
Silicon Controlled Rectifier teh_pwnerer795 Electrical 37 26-11-2007 07:09
Guage of PWM/Relay Cables Jake M Electrical 2 07-02-2007 00:49
PC Controlled Robot EHaskins Programming 6 05-11-2006 06:45
Servos controlled by RC? Obi Programming 5 01-02-2005 14:43
relay and pwm outputs nick_champ_2 Electrical 1 31-01-2003 13:08


All times are GMT -5. The time now is 01:47.

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