CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

16F690 pulse steering, 4 pin PWM
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 24, 2007 2:43 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 25, 2007 9:50 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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