|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
Re: Help with auton switching code
Quote:
I knew that! Just testing everyone...yeah right. I'll make that change and give it a try. Thanks a bunch! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |