Go to Post I think the only way I'd die from posting on CD is from my wife killing me. - Koko Ed [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 10-02-2009, 15:16
Straberrie's Avatar
Straberrie Straberrie is offline
The Plague
AKA: Rebecca
FRC #0375 (Robotic Plague)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2007
Location: New York
Posts: 59
Straberrie will become famous soon enough
Digital Inputs + Auton?

Hey,

I was trying to get different autons based on switches, and the code is as follows (example):

Quote:
void Autonomous(void)
{
if (s1->Get())
{
myRobot->Drive(-0.6, 0.5);
Wait(1.0);
myRobot->Drive(0.0,0.0);
}
else
{
myRobot->Drive(0.0,0.0);
}
}
and i defined the s1:

Quote:
DigitalInput *s1;
s1 = new DigitalInput(1);
However, when when i ran the auton, it went according to the code inside the if statement even when the switch was off. I was hoping that when the switch was off, it would refer to the "else" part of the code, but the code did not change despite the switch being off or on. What did i do wrong??

THANK YOU!!!
__________________
Team 375: The Robotic Plague
Current Robot: I-Chihuahua
Last Event: Big Apple Breakaway
  #2   Spotlight this post!  
Unread 10-02-2009, 15: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,113
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: Digital Inputs + Auton?

It might be a physical connection issue. How exactly is your switch wired?
  #3   Spotlight this post!  
Unread 10-02-2009, 15:38
Straberrie's Avatar
Straberrie Straberrie is offline
The Plague
AKA: Rebecca
FRC #0375 (Robotic Plague)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2007
Location: New York
Posts: 59
Straberrie will become famous soon enough
Re: Digital Inputs + Auton?

Switch 1 is getting plugged in to positive-negative end signal; the other six are only getting signal because all switches are grounded together. However, the only switch used in the code is switch1


(Thank you by the way!)
__________________
Team 375: The Robotic Plague
Current Robot: I-Chihuahua
Last Event: Big Apple Breakaway

Last edited by Straberrie : 10-02-2009 at 15:40.
  #4   Spotlight this post!  
Unread 10-02-2009, 15:46
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,113
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: Digital Inputs + Auton?

Quote:
Originally Posted by Straberrie View Post
Switch 1 is getting plugged in to positive-negative end signal;...
I don't understand that description. Can you give specific details about where each of the Digital Input's pins is connected, and what kind of switch you are using?
  #5   Spotlight this post!  
Unread 10-02-2009, 15:49
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: Digital Inputs + Auton?

Are you using the KoP switch? Print the status of the digital input to see what is coming from the switch. We had some problems with the KoP switch going between on and off really fast when it was off. To fix the problem we connected a resistor to pull the signal down to zero.
__________________
  #6   Spotlight this post!  
Unread 10-02-2009, 16:11
Straberrie's Avatar
Straberrie Straberrie is offline
The Plague
AKA: Rebecca
FRC #0375 (Robotic Plague)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2007
Location: New York
Posts: 59
Straberrie will become famous soon enough
Re: Digital Inputs + Auton?

To Alan Anderson: I attached pictures of the switches. (Thanks)

To BoyDean: I am not aware of that (sorry), but I will try it with prints. (Thanks)

Attached Files
File Type: zip Photos.zip (1.01 MB, 67 views)
__________________
Team 375: The Robotic Plague
Current Robot: I-Chihuahua
Last Event: Big Apple Breakaway
  #7   Spotlight this post!  
Unread 10-02-2009, 21:31
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Digital Inputs + Auton?

looks like you wired it sideways on the DSC
you have it like this
********
********
*****000

when it should be like this
*****0
*****0
*****0
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
  #8   Spotlight this post!  
Unread 10-02-2009, 22:20
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Digital Inputs + Auton?

Rebecca,

For the most part, your switches look good. I assume (the connection is slightly off picture) that the commons on the switches are tied to ground (to the black wire on the PWM cable in the SW1 position).

Byteit101's comment is not appropriate and your wiring should work.

The resistors referenced by Brandon are 10K pull-ups and are internal to the sidecar (schematic). You do not need to add more.

Other than something very weird such as a bad DS or the DS not getting power, I would concentrate on software.

Unfortunately, my team is using Labview and I have not played with this year's C++ at all...

Good Luck,

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...

Last edited by Mike Betts : 10-02-2009 at 22:23.
  #9   Spotlight this post!  
Unread 10-02-2009, 22:41
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Digital Inputs + Auton?

Quote:
Originally Posted by byteit101 View Post
looks like you wired it sideways on the DSC
Nope. It's hard to decode, but it looks as though those horizontal cables are all signal wires. There's one cable that connects to the ground and 5v like we are used to seeing, and then the rest of the cables are the signal wires for the rest of the switches. There is a unified ground; this is a conservative design.

Assuming everything is wired properly, when the switch is CLOSED, you will get a ZERO from the digital input, and when it is OPEN, you will get a ONE. I emphasize because it is backwards from common sense.

Now, you did mention that the else is never executed, regardless of the state of the switch.
  • Stupid question: does anything else on that sidecar work? If the PWM outputs on it work OK, then something else is the matter.
  • You should check that the switches are operating as you expect. Put a multimeter in the mode to measure ohms. Put one probe on the center terminal and the other on the terminal you have wired to the signal pin. With the switch one way, it should read either 0 ohms, or something close. The other way, it should read infinite--on my meter, it reads "0 F" when it is infinite (this should be the same display it has with the probes in the air, not touching each other).
  • You can measure (in the volts mode) what the voltage is between the signal pin and the ground. It should read 5v when the switch is open, and 0v when closed.
  • You can repeatedly print the state of the input, but I don't quite know how to do this yet. If you need help, I will figure it out.

If all else fails, post back here and somebody will help.

Jacob

edit: AND SEE ALAN'S POST. I neglected to realize this situation; as he says, if you aren't wiring the common wire to ground, you will always see a 1 coming in that input. Thanks, Alan.
__________________
Aren't signatures a bit outdated?

Last edited by JBotAlan : 11-02-2009 at 01:26.
  #10   Spotlight this post!  
Unread 11-02-2009, 00:08
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,113
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: Digital Inputs + Auton?

Quote:
Originally Posted by Straberrie View Post
I attached pictures of the switches.
Heh. The one wire that I really want to know about isn't visible, being just off the right side of the picture of the back of the switches. It should be connected to the ground (black) wire of DIO 1. If you have it going instead to +5 (red), you'll never see any change on the signal input.
  #11   Spotlight this post!  
Unread 13-02-2009, 06:11
Straberrie's Avatar
Straberrie Straberrie is offline
The Plague
AKA: Rebecca
FRC #0375 (Robotic Plague)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2007
Location: New York
Posts: 59
Straberrie will become famous soon enough
Re: Digital Inputs + Auton?

Thank you everyone!!!!!

One of our mentors found the problem! Apparently it was a loose wire! Which is y switch 1 always had a value of 1!

and again, Thank u all very much!!!!!!!
__________________
Team 375: The Robotic Plague
Current Robot: I-Chihuahua
Last Event: Big Apple Breakaway
  #12   Spotlight this post!  
Unread 13-02-2009, 10:23
Doug Leppard's Avatar
Doug Leppard Doug Leppard is offline
Registered User
FRC #1902 (Exploding Bacon)
Team Role: Engineer
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Orlando
Posts: 435
Doug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond repute
Send a message via AIM to Doug Leppard
Re: Digital Inputs + Auton?

Quote:
Originally Posted by Mike Betts View Post
Rebecca,

For the most part, your switches look good. I assume (the connection is slightly off picture) that the commons on the switches are tied to ground (to the black wire on the PWM cable in the SW1 position).

Byteit101's comment is not appropriate and your wiring should work.

The resistors referenced by Brandon are 10K pull-ups and are internal to the sidecar (schematic). You do not need to add more.

Other than something very weird such as a bad DS or the DS not getting power, I would concentrate on software.

Unfortunately, my team is using Labview and I have not played with this year's C++ at all...

Good Luck,

Mike
For the digital inputs on the driver station does it have internal 10k pull ups?

We were getting bad data at times.
__________________
Doug Leppard
  #13   Spotlight this post!  
Unread 13-02-2009, 11:07
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,113
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: Digital Inputs + Auton?

Quote:
Originally Posted by Doug Leppard View Post
For the digital inputs on the driver station does it have internal 10k pull ups?
No. The Driver Station digital inputs are floating, and any required pullup (or pulldown) must be supplied externally.
  #14   Spotlight this post!  
Unread 13-02-2009, 11:28
Doug Leppard's Avatar
Doug Leppard Doug Leppard is offline
Registered User
FRC #1902 (Exploding Bacon)
Team Role: Engineer
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Orlando
Posts: 435
Doug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond reputeDoug Leppard has a reputation beyond repute
Send a message via AIM to Doug Leppard
Re: Digital Inputs + Auton?

Quote:
Originally Posted by Alan Anderson View Post
No. The Driver Station digital inputs are floating, and any required pullup (or pulldown) must be supplied externally.
I assume we would use 10k resistors.
__________________
Doug Leppard
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
Digital Inputs? Straberrie Programming 4 15-02-2009 01:47
Using Interrupts on Digital Inputs Analog C/C++ 6 03-02-2009 23:05
Digital Inputs KRibordy C/C++ 5 25-01-2009 00:35
Auton digital input ten3brousone Programming 7 20-03-2005 22:23
Analog vs Digital inputs? f22flyboy Programming 8 08-11-2002 22:18


All times are GMT -5. The time now is 21:53.

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