Go to Post FIRST Robotics Competition could NEVER, EVER, EVER feature aquatic robots. - 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 01-02-2007, 09:15
SoD SoD is offline
Registered User
FRC #2230
 
Join Date: Jan 2007
Location: Israel
Posts: 15
SoD is an unknown quantity at this point
Microswitch problem

We have a problem with our micro switch. It doesn't work. We conncected it to the digital in/out, but it allways gets a '1' from the program no metter what, even when its disconnected. What is the problem?
  #2   Spotlight this post!  
Unread 01-02-2007, 09:21
Andrew Morris's Avatar
Andrew Morris Andrew Morris is offline
Oh hey, it's build season!
FRC #0177 (Bobcat Robotics)
Team Role: Student
 
Join Date: Nov 2006
Rookie Year: 2005
Location: South Windsor
Posts: 16
Andrew Morris will become famous soon enough
Re: Microswitch problem

A few questions:
1. Do you have the digitalIO port you are using configured as an input?
2. What alias are you using to read the port(like rc_dig_in01)?

Basedd on your answers I should be able to tell you what is wrong.

Andrew
__________________
2010 Newton Division & Championship Winner w/ 67 & 294
2009 CMP Champion - Newton Division
2008 CMP Champion - Archimedes Division
2007 Newton Division & Championship Winner
  #3   Spotlight this post!  
Unread 01-02-2007, 09:35
SoD SoD is offline
Registered User
FRC #2230
 
Join Date: Jan 2007
Location: Israel
Posts: 15
SoD is an unknown quantity at this point
Re: Microswitch problem

Quote:
Originally Posted by Andrew Morris View Post
A few questions:
1. Do you have the digitalIO port you are using configured as an input?
2. What alias are you using to read the port(like rc_dig_in01)?

Basedd on your answers I should be able to tell you what is wrong.

Andrew
1. Yes
2. Yes, we are using rc_dig_in01. This is the code we tried.

if (rc_dig_in01 == 1)
{
relay1_fwd = 0;
relay1_rev = 0;
}
  #4   Spotlight this post!  
Unread 01-02-2007, 09:42
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,801
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: Microswitch problem

The digital inputs are designed to return 1 if the switch is open or disconnected. It returns 0 only when closed.

The code you posted never does anything if the switch is closed (rc_dig_in01 is 0).

Try something like:
Quote:
Originally Posted by SoD View Post
if (rc_dig_in01 == 1)
{
relay1_fwd = 0;
relay1_rev = 0;
}
else
{
relay1_fwd = 1;
relay1_rev = 0;
}
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #5   Spotlight this post!  
Unread 01-02-2007, 09:44
SoD SoD is offline
Registered User
FRC #2230
 
Join Date: Jan 2007
Location: Israel
Posts: 15
SoD is an unknown quantity at this point
Re: Microswitch problem

oops I though it should give 1 xD

So if i change it to ==0 it should work?
  #6   Spotlight this post!  
Unread 01-02-2007, 09:53
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,801
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: Microswitch problem

Quote:
Originally Posted by SoD View Post
oops I though it should give 1 xD

So if i change it to ==0 it should work?
Usually we give it something to do when it's equal to 1 and something different to do when it's equal to 0.

Relay1 will only change when we explicitly change it. The last thing we did will always be in effect.
For example, in your original code the relay was set to:
Code:
    relay1_fwd = 0; relay1_rev = 0;
in User_Initialization(), then your code changed to to the same value.
Nothing ever changed it to 1.

If you modify your code to use "==0" instead and change it to set the Relay to 1, then Relay1 will begin as 0 and change to 1 when you flip your switch, but nothing will ever change it back to 0 if the switch is flipped off again.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 01-02-2007 at 09:56.
  #7   Spotlight this post!  
Unread 01-02-2007, 09:59
SoD SoD is offline
Registered User
FRC #2230
 
Join Date: Jan 2007
Location: Israel
Posts: 15
SoD is an unknown quantity at this point
Re: Microswitch problem

Ok i think i understand, tnx alot ;p
  #8   Spotlight this post!  
Unread 01-02-2007, 10:24
SoD SoD is offline
Registered User
FRC #2230
 
Join Date: Jan 2007
Location: Israel
Posts: 15
SoD is an unknown quantity at this point
Re: Microswitch problem

$@#$@#$@#$@# it still doesn't work X_X

The rc_dig_in01 is allways 1 even when we press on the microswitch X_X what is wrong here?
  #9   Spotlight this post!  
Unread 01-02-2007, 10:31
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,801
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: Microswitch problem

If you are using the micro switch that came in the kit, then there are different ways of wiring it.
Choose the wrong way and it will never be 0.


Let me see if I can find a picture....
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #10   Spotlight this post!  
Unread 01-02-2007, 10:32
Andrew Morris's Avatar
Andrew Morris Andrew Morris is offline
Oh hey, it's build season!
FRC #0177 (Bobcat Robotics)
Team Role: Student
 
Join Date: Nov 2006
Rookie Year: 2005
Location: South Windsor
Posts: 16
Andrew Morris will become famous soon enough
Re: Microswitch problem

You may have the switch plugged in wrong(white where black sould be). Otherwise I would need to know how you are checking the value(LED or printf statement) and see the code you are using.

Andrew
__________________
2010 Newton Division & Championship Winner w/ 67 & 294
2009 CMP Champion - Newton Division
2008 CMP Champion - Archimedes Division
2007 Newton Division & Championship Winner
  #11   Spotlight this post!  
Unread 01-02-2007, 10:40
SoD SoD is offline
Registered User
FRC #2230
 
Join Date: Jan 2007
Location: Israel
Posts: 15
SoD is an unknown quantity at this point
Re: Microswitch problem

Printf. And there are 3 plugins in the microswitch right? We connected the yellow one to the upper one, nothing to the middle one, and the red one to the lowest one
  #12   Spotlight this post!  
Unread 01-02-2007, 10:45
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,801
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: Microswitch problem

Quote:
Originally Posted by SoD View Post
Printf. And there are 3 plugins in the microswitch right? We connected the yellow one to the upper one, nothing to the middle one, and the red one to the lowest one
Should be black and yellow, no red at all.
Use only the outer wires at the RC digital input side.

The red is power and used only by devices that need power to work. A switch doesn't need power. It simply connects the signal wire (yellow) to the ground (black) or not to close or open the circuit.

If you have a multimeter you can use it to test that the switch is wired correctly.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 01-02-2007 at 10:50.
  #13   Spotlight this post!  
Unread 01-02-2007, 10:55
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: Microswitch problem

Thanks! We've got it working!
  #14   Spotlight this post!  
Unread 01-02-2007, 11:28
SoD SoD is offline
Registered User
FRC #2230
 
Join Date: Jan 2007
Location: Israel
Posts: 15
SoD is an unknown quantity at this point
Re: Microswitch problem

Darn we now have a new problem

if (rc_dig_in01 == 0)
{
relay1_fwd = 0;
relay1_rev = 0;
}

else
{
relay1_fwd = 1;
relay1_rev = 1 ;
}

This is the code we are trying to use atm, but we have a problem. When the motor works foward, and i press the microswitch, it changes from 1 to 0 and the motor stops working. But when the motor is working backwards, and I press the microswitch, the microswitch turns to 0 but the relay1_rev remains 1 ;s

Whats wrong?
  #15   Spotlight this post!  
Unread 01-02-2007, 11:34
Andrew Morris's Avatar
Andrew Morris Andrew Morris is offline
Oh hey, it's build season!
FRC #0177 (Bobcat Robotics)
Team Role: Student
 
Join Date: Nov 2006
Rookie Year: 2005
Location: South Windsor
Posts: 16
Andrew Morris will become famous soon enough
Re: Microswitch problem

What motor? You haven't mentioned a motor before.

Andrew
__________________
2010 Newton Division & Championship Winner w/ 67 & 294
2009 CMP Champion - Newton Division
2008 CMP Champion - Archimedes Division
2007 Newton Division & Championship Winner
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
G.T.S ..... (problem) Ami Schwartz Programming 3 28-01-2006 17:01
A linking problem T Shap Programming 6 15-01-2006 00:23
Problem Hailfire CD Forum Support 7 06-10-2002 15:02
PROBLEM!!!!!!?????? Clark Gilbert CD Forum Support 9 02-12-2001 12:43


All times are GMT -5. The time now is 03:59.

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