Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Help with auton switching code (http://www.chiefdelphi.com/forums/showthread.php?t=34691)

farmer 15-02-2005 13:19

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.

JoshJ 15-02-2005 13:48

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

Workaphobia 15-02-2005 14:27

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.

farmer 15-02-2005 15:30

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!


All times are GMT -5. The time now is 23:56.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi