Go to Post FIRST is inspiration. No matter how you do it, you learn something. Stop being silly. Stop making accusations. Go build robots. Now. - Aignam [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-03-2009, 16:27
dboisvert dboisvert is offline
Registered User
AKA: Dan Boisvert
FRC #2405 (Divided by Zero)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Michigan
Posts: 57
dboisvert is an unknown quantity at this point
DS Digital Input/Output

Recently my team went to a competition and I asked for help with out driver station. We had purchased a few Light Switches from the local hardware store and I had no idea how to wire them properly.

So he helped me wire them properly and connect them to DS 1 and 2 on the Driver Station and now I need to figure out how to code them.

My current code looks like this

Code:
bool switch1;
switch1 = m_ds->GetDigitalIn(1);
printf("Switch Value is: %d  ", switch1);
I never got to look at the code extensively during the competition but as far as I know it printed out all 0's when the switch was in either position.


My next problem is we want to wire in a few LED's to the DS so we know what is going on with the robot

Code:
m_ds->SetDigitalOut( 1,true);
I know how to wire the led's but I need to know if this is the proper syntax to turn them on.
Reply With Quote
  #2   Spotlight this post!  
Unread 01-03-2009, 16:55
excel2474's Avatar
excel2474 excel2474 is offline
Registered User
AKA: Aaron Stewart
FRC #2474 (Excel)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2008
Location: Niles, Michigan
Posts: 177
excel2474 is a jewel in the roughexcel2474 is a jewel in the roughexcel2474 is a jewel in the roughexcel2474 is a jewel in the rough
Re: DS Digital Input/Output

I'm not sure about the switch problem, cuz i was experiencing the same thing. However the if m_ds is a pointer refering to digital out on the ds, then that code should work. I didn't have any problems with the LEDS.
__________________
"Find some thing you like to do and EXCEL at it with dilligence."

University of Notre Dame- Mechanical Engineering.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-03-2009, 17:33
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Re: DS Digital Input/Output

A couple of suggestions:

1.Your printf is set to print an int, not a boolean. I don't think there's a flag for boolean, so you might want to change it to use two different printfs depending on the state of the variable

2.Check your switches with a multimeter and make sure current is actually getting through.

3.Check your digital outputs and see if you're actually turning it on. If you are, chances are that you have reversed the polarity to the LED(LEDs are diodes, so they only work one direction)
__________________
Get yer robot source code here!
Reply With Quote
  #4   Spotlight this post!  
Unread 01-03-2009, 18:59
dboisvert dboisvert is offline
Registered User
AKA: Dan Boisvert
FRC #2405 (Divided by Zero)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Michigan
Posts: 57
dboisvert is an unknown quantity at this point
Re: DS Digital Input/Output

My next best guess for C++ would be a "c" character flag? If im not mistaken it would print a t or a f then correct?
Reply With Quote
  #5   Spotlight this post!  
Unread 01-03-2009, 22:32
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,112
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: DS Digital Input/Output

Quote:
Originally Posted by dboisvert View Post
So he helped me wire them properly and connect them to DS 1 and 2 on the Driver Station...I never got to look at the code extensively during the competition but as far as I know it printed out all 0's when the switch was in either position.
There seems to be a lot of confusion about what "wire them properly" really is. I think the software looks right, so maybe the hardware isn't. What sort of light switches are you using? How are they wired?
Reply With Quote
  #6   Spotlight this post!  
Unread 01-03-2009, 23:41
dboisvert dboisvert is offline
Registered User
AKA: Dan Boisvert
FRC #2405 (Divided by Zero)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Michigan
Posts: 57
dboisvert is an unknown quantity at this point
Re: DS Digital Input/Output

I cant get my hands on the light switches right now but I know they have 3 wire leads. I remember him telling me something about "Getting around having to use a resistor" and Double Pole Double Throw

Thanks for all of the help so far!
Reply With Quote
  #7   Spotlight this post!  
Unread 02-03-2009, 21:03
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: DS Digital Input/Output

printf("%i", true); will print 1
and printf("%i",false); will print0
you dont need a bool printf flag, or a if statement
just use the int flag (%i or %d)
__________________
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
Reply With Quote
  #8   Spotlight this post!  
Unread 02-03-2009, 22:09
dboisvert dboisvert is offline
Registered User
AKA: Dan Boisvert
FRC #2405 (Divided by Zero)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Michigan
Posts: 57
dboisvert is an unknown quantity at this point
Re: DS Digital Input/Output

It must be in the wiring in the switch then because I have tried that.
Reply With Quote
  #9   Spotlight this post!  
Unread 02-03-2009, 22:42
Alexa Stott's Avatar
Alexa Stott Alexa Stott is offline
All I do is twin.
AKA: elixir
FRC #0025 (Raider Robotix)
Team Role: College Student
 
Join Date: Oct 2005
Rookie Year: 2006
Location: No. Bruns., NJ/College Park, MD
Posts: 781
Alexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond repute
Send a message via AIM to Alexa Stott
Re: DS Digital Input/Output

We experinced similar trouble. Wire a 1kOhm resistor between the power and signal wires on the switch. That should solve your problem.
__________________
|Email:alexastott[at]gmail.com|Facebook|@zelixir|Google+|
[University of Maryland Computer Science, Psychology]
[Brunswick Eruption]
Reply With Quote
  #10   Spotlight this post!  
Unread 07-03-2009, 03:32
ExarKun666's Avatar
ExarKun666 ExarKun666 is offline
Ben Error/MC Ben/NC Ben
AKA: Ben Kellogg
FRC #2429 (LCEC)
Team Role: Programmer
 
Join Date: Dec 2007
Rookie Year: 2008
Location: La Caņada, CA
Posts: 208
ExarKun666 is an unknown quantity at this point
Send a message via AIM to ExarKun666 Send a message via MSN to ExarKun666 Send a message via Yahoo to ExarKun666
Re: DS Digital Input/Output

I have a question on the jumpers also, my code looks like this:

Code:
enum{
   ARCADE_MODE = 1,
   ENABLE_AUTONOMOUS = 2,
   DRIVE = 3,
}jumpers;
....
....
void OperatorControl(void)
{
   while(1)
   {
      if(ds->GetDigtalIn(DRIVE)==1)
      {
         myRobot->TankDrive(-rightstick->GetY(), -leftstick->GetY());
      }
      else
      {
         myRobot->Drive(-leftstick->GetY(), -rightstick->GetX());
      }
   }
}
This isn't really for competition reasons, except for merely trying to get the jumpers to work. When I don't plug in the jumper it drives like how the else statement is written, but when I put a jumper on jumper pin#3 on the driver station it doesn't go at all, and I've tried restarting the driver station and robot, and still same results, what is going on here? (I have counted the jumpers many times to make sure it was on the right one)
__________________
Ben Kellogg




Team Sites: [LCEC Site] [FRC/FLL Site] [LCEC Blog]
Reply With Quote
  #11   Spotlight this post!  
Unread 07-03-2009, 11:56
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,979
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: DS Digital Input/Output

Quote:
Originally Posted by ExarKun666 View Post
when I put a jumper on jumper pin#3 on the driver station it doesn't go at all,
Explain which pin 3, there are a few of them, and the jumper goes from where to where exactly?
__________________

I am N2IRZ - What's your callsign?
Reply With Quote
  #12   Spotlight this post!  
Unread 08-03-2009, 17:50
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,039
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: DS Digital Input/Output

I've been using a really simple program to display my driver station inputs to the driver station LCD panel. C++ sources/project included:

http://www.virtualroadside.com/blog/...-test-program/
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
Reply


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 Input? boris C/C++ 1 30-01-2009 14:51
Switch digital input to output during operation? Parallax Ultrasonic wt200999 C/C++ 2 28-01-2009 19:30
live input/output to/from application MarkH Programming 3 06-04-2006 01:43
digital output frequency Barth Programming 8 06-03-2005 21:58
Dynamic Input/Output Changing Paolo Control System 6 23-09-2004 19:09


All times are GMT -5. The time now is 02: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