Hi, I am using PIC18F4455 chip to control two PWM and let the robot to move around using C Compiler. PWM1 for moving left or right and PWM2 for forward or backward.
If i run my PWM code one by one it is working but now when i put them together the robot will stop after PWM2 changes. PWM1 is working fine
What it is happening now is turn right + move forward, delay 2s, turn left + move forward, delay 2s, turn right but it doesnt go back(PWM2 stop), delay 2s, turn left and PWM2 stop.
Do i got some problems with the PWM2 coding?
Thanks for the helping
Ivan
void main (void){
TRISC=0x00;
OpenTimer2(TIMER_INT_OFF &
T2_PS_1_16 &
T2_POST_1_8);
OpenPWM1(255);
SetOutputPWM1(SINGLE_OUT,PWM_MODE_1);
OpenPWM2(255);
SetDCPWM1(122);
SetDCPWM2(75);
Delay10KTCYx(60);
SetDCPWM1(55);
SetDCPWM2(75);
Delay10KTCYx(60);
SetDCPWM1(122);
SetDCPWM2(98);
Delay10KTCYx(60);
SetDCPWM1(55);
SetDCPWM2(98);
Delay10KTCYx(60);
}
If i run my PWM code one by one it is working but now when i put them together the robot will stop after PWM2 changes. PWM1 is working fine
What it is happening now is turn right + move forward, delay 2s, turn left + move forward, delay 2s, turn right but it doesnt go back(PWM2 stop), delay 2s, turn left and PWM2 stop.
Do i got some problems with the PWM2 coding?
Thanks for the helping
Ivan
void main (void){
TRISC=0x00;
OpenTimer2(TIMER_INT_OFF &
T2_PS_1_16 &
T2_POST_1_8);
OpenPWM1(255);
SetOutputPWM1(SINGLE_OUT,PWM_MODE_1);
OpenPWM2(255);
SetDCPWM1(122);
SetDCPWM2(75);
Delay10KTCYx(60);
SetDCPWM1(55);
SetDCPWM2(75);
Delay10KTCYx(60);
SetDCPWM1(122);
SetDCPWM2(98);
Delay10KTCYx(60);
SetDCPWM1(55);
SetDCPWM2(98);
Delay10KTCYx(60);
}
Last edited: