|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Delay10KTCYx in C18
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! Code:
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\n",(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! */
}
}
}
|
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trig functions in C18 3.10 | dmlawrence | Programming | 9 | 08-02-2008 09:33 |
| MPLab 7.20/C18 2.40 | Andy L | Programming | 2 | 07-04-2007 20:11 |
| C18 v. 2.4 | wingnut1705 | Programming | 2 | 05-02-2007 15:52 |
| C18 v2.4 | CircularLogic | FIRST Tech Challenge | 2 | 16-07-2006 15:20 |
| Linux C18 compiler? | Servo888 | Robotics Education and Curriculum | 1 | 13-12-2003 01:27 |