Hello everyone I’m back again,
First of I would like to thank all who has helped me out on the recent question, and yet I’m here to bug you guys again…
Currently I’m using mplab v7.60 C18 v2.40 I’ve successfully built VexUserCode.mcw right now I would like to run my robot autonomously
I’m under the “user_routines_fast.c” and I was trying to program my robot to go straight for 5 seconds and stop using the Delay10KTCYx function in “delay.h” I tried with the code below, how did I come up with the 5000?
my chip is PIC18f8520 and I check the datasheets the Fosc is 40MHz
so Delay10KTCYx (5000); // should give me a delay of 10000 x 5000 x 4/40M = 5 seconds
and after 5 seconds I want it to stop so I added
pwm02=127;
pwm03=127;
is there something wrong with my code or am I using the Delay10KTCYx wrong? Thank you for your time!
void User_Autonomous_Code(void)
{
/* 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 = 127;
pwm05 = pwm06 = pwm07 = pwm08 = 127;
pwm09 = pwm10 = pwm11 = pwm12 = 127;
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 18.5ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
/* Add your own code here. */
pwm02=100;
pwm03=155;
Delay10KTCYx(5000);
pwm02=127;
pwm03=127;
printf("%2x : %2x %2x %2x %2x %2x %2x
",(int)rxdata.rc_receiver_status_byte.allbits,
(int)PWM_in1,(int)PWM_in2,(int)pwm01,(int)pwm02,(int)pwm03,(int)pwm04);
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
}