|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
We are currently using mplab and we having trouble with the pulses of the remote. Here is an example of our coding:
Code Code:
if (rc_dig_in10 == 1)
{
cmd0; //Call the cmd0(forward) subroutine
}
Code:
unsigned char cmd0()
{
pwm01 = pwm02 = 190; //Forward Half Speed
return 0;
}
But this makes it so the pulses just pulse the motors forward and do not hold them at constant forward movement. What are other teams doing to rectify/compensate for this? |
|
#2
|
||||
|
||||
|
Re: IR Issues in Mplab
There doesn't seem to be anything wrong with the code you posted; the error may lie elsewhere.
In the autonomous loop, are you setting the PWMs to 127 every time? |
|
#3
|
|||
|
|||
|
Re: IR Issues in Mplab
Quote:
if (rc_dig_in10 == 1) { ButtonPressed = TRUE; } [/code] Subroutine[code] if (ButtonPressed == TRUE) { //You could also call your subroutine here if you wanted to pwm01 = pwm02 = 190; //Forward Half Speed return 0; } This will work because the way you had it written, as soon as the button lets go, it equals 0. Since the processor runs every 27 milliseconds or so, it will start, and then quickly stop if pressed once. Doing it the way I showed sets another variable that once it sees the button gets set, and if it gets let go it is still going. If you have anymore questions, let me know. Joey PS I'm not sure if the syntax is perfect, I just wanted to show you the concept. |
|
#4
|
||||
|
||||
|
Re: IR Issues in Mplab
We were able to figure it out. The issue was with an else branch that we had that was setting the pwm01 and pwm02 equal to 127.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MpLab issues! | AdmiralAllen | Programming | 3 | 15-01-2007 22:47 |
| MPLAB Issues | jcatt | Programming | 3 | 02-02-2006 17:49 |
| Issues with MPLAB 7.30 | gnirts | Programming | 4 | 25-01-2006 22:57 |
| using the MPLAB IDE MPLAB SIM simulator | WizardOfAz | Programming | 1 | 03-11-2003 01:24 |