|
|
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 24, 2007 2:43 pm |
|
|
I was able to fix it by adding the line shown in bold below.
Also, it's best to define a symbolic name for the PWM pins.
If you use "PIN_C4", etc., as the pin name in your code, it doesn't
really tell you anything. You have to remember that it's the P1B
pin of the PWM module. You could also make a mistake and type
in the wrong pin. But if you see "P1B" as the pin, you know its the
"B" output of the PWM module. "PIN_C4" is basically a "magic number"
when you use it in your code. In C, the concept of "magic number"
means a number that has a special meaning, but it's known only to
the original programmer, and he might forget it someday. Then it
bites him (as well as some future maintenance programmer).
Add the line shown in bold below:
Quote: |
#define P1A PIN_C5
#define P1B PIN_C4
#define P1C PIN_C3
#define P1D PIN_C2
while(1){
// left wheel forward, right wheels not moving
setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_A );
output_low(P1B);
set_pwm1_duty(31); // 25% duty cycle
output_high( led );
delay_ms(1000);
// left wheels backward, right wheels not moving
setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_B );
set_pwm1_duty(31); // 25% duty cycle
output_low( led );
delay_ms(1000);
} |
|
|
|
ymoona
Joined: 20 Mar 2005 Posts: 32 Location: Heiloo, the Netherlands
|
|
Posted: Mon Jun 25, 2007 9:50 am |
|
|
PCM programmer wrote: | I was able to fix it by adding the line shown in bold below.
Also, it's best to define a symbolic name for the PWM pins.
If you use "PIN_C4", etc., as the pin name in your code, it doesn't
really tell you anything. You have to remember that it's the P1B
pin of the PWM module. You could also make a mistake and type
in the wrong pin. But if you see "P1B" as the pin, you know its the
"B" output of the PWM module. "PIN_C4" is basically a "magic number"
when you use it in your code. In C, the concept of "magic number"
means a number that has a special meaning, but it's known only to
the original programmer, and he might forget it someday. Then it
bites him (as well as some future maintenance programmer).
Add the line shown in bold below:
Quote: |
#define P1A PIN_C5
#define P1B PIN_C4
#define P1C PIN_C3
#define P1D PIN_C2
while(1){
// left wheel forward, right wheels not moving
setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_A );
output_low(P1B);
set_pwm1_duty(31); // 25% duty cycle
output_high( led );
delay_ms(1000);
// left wheels backward, right wheels not moving
setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_B );
set_pwm1_duty(31); // 25% duty cycle
output_low( led );
delay_ms(1000);
} |
|
thanks now it work well! _________________ checkout my site: www.ymoona.com/wiki |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|