Go to Post If there's one thing I've learned, it's that the robot is never truly finished. - Joseph Smith [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 02-02-2008, 11:54
personfromhell's Avatar
personfromhell personfromhell is offline
Shaman Me
FRC #1389 (Suck Nuts)
Team Role: Programmer
 
Join Date: Dec 2006
Rookie Year: 2006
Location: Maryland
Posts: 5
personfromhell is an unknown quantity at this point
p1_sw_aux data type

Hi, my team wants to use the two buttons next to the hat on the controllers FIRST gave us. I used dashboard and got that they are aux1 and aux2 and I found p1_sw_aux1 and p1_sw_aux2. However, I haven't been able to figure out what data type they are. I tried using them as a conditional hoping they would be non-zero if depressed (if(p1_sw_aux1) {}), but that didn't work. I tried searching but I only found a single thread and it simply said you could use them (http://www.chiefdelphi.com/forums/sh...ght=p1_sw_aux). Any help would be greatly appreciated.
__________________

  #2   Spotlight this post!  
Unread 02-02-2008, 12:03
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: p1_sw_aux data type

p1_sw_aux1 is really a macro

#define p1_sw_aux1 rxdata.oi_swA_byte.bitselect.bit2 // Aux input

bitselect is a member of a union and is of defined type 'bitid'

typedef struct
{
unsigned int bit0:1;
unsigned int bit1:1;
unsigned int bit2:1;
unsigned int bit3:1;
unsigned int bit4:1;
unsigned int bit5:1;
unsigned int bit6:1;
unsigned int bit7:1;
} bitid;

Thus, the 'type' of bit2 is a single bit, the value is always 0 or 1.

HTH
  #3   Spotlight this post!  
Unread 02-02-2008, 12:16
personfromhell's Avatar
personfromhell personfromhell is offline
Shaman Me
FRC #1389 (Suck Nuts)
Team Role: Programmer
 
Join Date: Dec 2006
Rookie Year: 2006
Location: Maryland
Posts: 5
personfromhell is an unknown quantity at this point
Re: p1_sw_aux data type

Thank you, I figured it would be essentially a Boolean value but wasn't sure because my code wasn't working. My next question is then why doesn't this code work:
Code:
  if(p2_sw_aux1) {
	pwm01 = 187;
  } else if(p2_sw_aux2) {
	pwm01 = 67;
  } else {
	pwm01 = 127;
  }
pwm01 goes to a motor that is meant to pivot two casters. I know that the victor its wired to works as well as the controller and cables and such. I know that in C++ the if statements should work but I haven't used C in a while and I forgot the differences in the two standards. Again, any help is greatly appreciated.
__________________

  #4   Spotlight this post!  
Unread 02-02-2008, 12:37
paulcd2000's Avatar
paulcd2000 paulcd2000 is offline
Accidentally speaks in C
AKA: Paul Dagnelie
FRC #1719 (The Umbrella Corp.)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore
Posts: 368
paulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the rough
Send a message via AIM to paulcd2000
Re: p1_sw_aux data type

that code should work fine. Just to be certain, you do know that that's referencing the joystick in port 2?
if that's not it, try moving the else if and the else onto a second line from the ending brackets. DOn't think that's it, but it might be a problem...
__________________
"People don't say 'It's just a game' when their team is winning!" -- Scott Adams

5.5 students (on average)* $7/h *210 hours/student= $8085 of labor, all volunteered (not counting mentors', who are each that much)

We have blades on our robot?! ***sweeeeeet***

There are 11 types of people in the world. Those who can read binary, those who can't, and those who say this joke is supposed to be, "There are 10 types of people in the world. Those who can read binary and those who have a life."
  #5   Spotlight this post!  
Unread 02-02-2008, 12:54
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: p1_sw_aux data type

"pwm01 goes to a motor that is meant to pivot two casters. I know that the victor its wired to works as well as the controller and cables and such. I know that in C++ the if statements should work but I haven't used C in a while and I forgot the differences in the two standards. Again, any help is greatly appreciated."

C++ is a superset of C thus everything that works in C will work in C++. Your code looks OK. You know p2_sw_aux1 is on the second joystick, correct? Print the value of p2_sw_aux1 to make sure it is changing.


HTH
  #6   Spotlight this post!  
Unread 02-02-2008, 13:15
xrabohrok's Avatar
xrabohrok xrabohrok is offline
hunter of errors
FRC #1208 (The Metool Brigade)
Team Role: Programmer
 
Join Date: Jan 2006
Location: O'Fallon
Posts: 62
xrabohrok is an unknown quantity at this point
Re: p1_sw_aux data type

Quote:
Originally Posted by wireties View Post
"C++ is a superset of C thus everything that works in C will work in C++. Your code looks OK."

This isn't entirely true. C++ is a modified version of C that incorporates true object oriented programming into it. There are also a few fundamental syntax changes (cout<<""; instead of printf(""), as one example) that may play havoc with direct conversions of code. If you are coming from C++ to C, the differences are easy and trivial enough to learn C.
__________________
"It's programming's fault" may be a viable excuse for just about everything, except the robot falling apart.

It will 'cause it can!

constants aren't. variables won't.
  #7   Spotlight this post!  
Unread 02-02-2008, 16:27
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: p1_sw_aux data type

"This isn't entirely true."

This is a common mis-perception. Its entirely true, C++ is a superset of C that expands the syntax to include object-oriented concepts, streaming I/O and other constructs. Though it is not the recommended practice, I can use printf in C++. It makes no difference in this thread I reckon but C preceded C++, not the other way around.

HTH
  #8   Spotlight this post!  
Unread 02-02-2008, 16:46
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,586
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: p1_sw_aux data type

Quote:
Originally Posted by personfromhell View Post
Thank you, I figured it would be essentially a Boolean value but wasn't sure because my code wasn't working. My next question is then why doesn't this code work:
Code:
  if(p2_sw_aux1) {
	pwm01 = 187;
  } else if(p2_sw_aux2) {
	pwm01 = 67;
  } else {
	pwm01 = 127;
  }
pwm01 goes to a motor that is meant to pivot two casters. I know that the victor its wired to works as well as the controller and cables and such. I know that in C++ the if statements should work but I haven't used C in a while and I forgot the differences in the two standards. Again, any help is greatly appreciated.
The code looks fine. Are you sure pwm01 isn't set to something else later in the code (for example, in the default code)?
  #9   Spotlight this post!  
Unread 02-02-2008, 18:40
personfromhell's Avatar
personfromhell personfromhell is offline
Shaman Me
FRC #1389 (Suck Nuts)
Team Role: Programmer
 
Join Date: Dec 2006
Rookie Year: 2006
Location: Maryland
Posts: 5
personfromhell is an unknown quantity at this point
Re: p1_sw_aux data type

Not sure what I did (I rewrote all the code for unrelated reasons) but now it works. Thanks for all the help.
__________________

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
Robot Type Betty_Krocker General Forum 0 08-01-2008 22:17
printing FLOAT data type on the terminal window razer Programming 14 05-02-2007 08:55
Field Location of Type-0 and Type-1 IR Signals Travis Hoffman General Forum 3 27-02-2004 07:58


All times are GMT -5. The time now is 19:13.

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