Go to Post If you don't like getting tipped don't build a robot that tips. - 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 15-02-2005, 13:19
farmer farmer is offline
Tired Mentor
AKA: Matt
#1108 (Panther Robotics)
Team Role: Engineer
 
Join Date: Jan 2005
Location: Kansas
Posts: 8
farmer is an unknown quantity at this point
Help with auton switching code

Late night coding isn't working. We hooked up a binary switch to 4 digital inputs(tied to ground). And added the following code as a test;




void User_Autonomous_Code(void)
{
static unsigned int mode = 0;


/* Initialize all PWMs and Relays when entering Autonomous mode, or else it
will be stuck with the last values mapped from the joysticks. Remember,
even when Disabled it is reading inputs from the Operator Interface.
*/
pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;
relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;
relay3_fwd = relay3_rev = relay4_fwd = relay4_rev = 0;
relay5_fwd = relay5_rev = relay6_fwd = relay6_rev = 0;
relay7_fwd = relay7_rev = relay8_fwd = relay8_rev = 0;



while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */

/* Add your own autonomous code here. */


mode = ((8*!digital_io_04) + (4*!digital_io_03) + (2*!digital_io_02) + (!digital_io_01));


/* mode = 2; */

switch ( mode )
{
case 0: /* Do nothing */
break;

case 1:
time++;
if (time < 114) {
pwm04 = 150;
}
else if (time < 152)
{
pwm04 = 127;
relay4_rev = 0;
}
else if (time < 570)
{
pwm01 = 127;
pwm03 = 127;
}
break;



If we set "mode" equal to 2 or any other number the switch code works fine. But apparently the binary to digital conversion setting "mode" is not because the robot doesn't move. Thanks for any help.
  #2   Spotlight this post!  
Unread 15-02-2005, 13:48
JoshJ JoshJ is offline
Registered User
#0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Salem County
Posts: 44
JoshJ is on a distinguished road
Send a message via AIM to JoshJ
Re: Help with auton switching code

One thing I would do would be to change your digital_io_0X to rc_dig_in0X in the code. (if attached to the RC, I am assuming). Good luck
Josh
  #3   Spotlight this post!  
Unread 15-02-2005, 14:27
Workaphobia Workaphobia is offline
Registered User
AKA: Jon
FRC #1546 (Chaos Inc.)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Long Island
Posts: 26
Workaphobia will become famous soon enough
Re: Help with auton switching code

Right. The digital_io_** is for setting a digital pin to input or output. You have to use rc_dig_in** or rc_dig_out** to actually assign or receive its value.
  #4   Spotlight this post!  
Unread 15-02-2005, 15:30
farmer farmer is offline
Tired Mentor
AKA: Matt
#1108 (Panther Robotics)
Team Role: Engineer
 
Join Date: Jan 2005
Location: Kansas
Posts: 8
farmer is an unknown quantity at this point
Re: Help with auton switching code

Quote:
Originally Posted by JoshJ
One thing I would do would be to change your digital_io_0X to rc_dig_in0X in the code. (if attached to the RC, I am assuming). Good luck
Josh

I knew that! Just testing everyone...yeah right. I'll make that change and give it a try. Thanks a bunch!
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
Example gyro code released. Kevin Watson Programming 60 17-03-2005 18:32
Updated: Serial Port Driver Code Kevin Watson Programming 4 05-02-2005 18:39
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
Sourceforge for Code Repository and other stuff SilverStar Programming 9 15-01-2005 21:16
heres the code. y this not working omega Programming 16 31-03-2004 15:18


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

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