PIC18F452 PWM problem

General discussion on mikroC.
Post Reply
Author
Message
fyp
Posts: 7
Joined: 24 Jun 2010 13:56

PIC18F452 PWM problem

#1 Post by fyp » 23 Sep 2010 15:22

Hi, I'm currently doing my final year project. I'm using a PIC18F452 Microcontroller. I'm also using MikroC to compile the program.
Currently, I want to regulate the speed of my robot vehicle. I succeeded in regulating the robot vehicle speed. But,
I want to make it stop when it receive input: '0'. The problem now is that the robot vehicle doesn't stop and I'm not so sure about
the codes.

This is part of the program that generates the PWM signal:

for(i=0;i<500;i++){
Delay_us(500);
PORTD = 0x3A;
Delay_us(1000);
PORTD = 0x00;
}

Basically, this loop reduce the speed of the DC motor of my robot vehicle. The robot vehicle moves forward when it detect
'1'. But I don't know how to make it stop when it detect '0'. What code do i put inside the for loop?
Some kind soul please help me :)

Post Reply

Return to “mikroC General”