| View previous topic :: View next topic |
| Author |
Message |
mcad
Joined: 25 Nov 2007 Posts: 48
|
|
Posted: Sun Nov 25, 2007 4:56 pm |
|
|
Ok, sir.
I am going to try what you suggested in lab tomorrow.
Thanks again for your helps...
regards, and best wishes |
|
 |
mcad
Joined: 25 Nov 2007 Posts: 48
|
|
Posted: Sun Nov 25, 2007 5:08 pm |
|
|
Upps,
Sir, I noticed something that's why I have decided to increment and decrement 1.
The reason is that we do not know the value of the duty if the value is taken from the ADC channel.
So, suppose that it is always less than 10. So, does not this create a problem, sir ?
thanks |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
 |
mcad
Joined: 25 Nov 2007 Posts: 48
|
|
Posted: Sun Nov 25, 2007 5:21 pm |
|
|
Sir, thanks for your link but I have already known it.
I just ask that if suppose that the value taken from the ADC as a digital is smaller than ten regularly, so and the user want to slow down the motor by pressing the button which decrement is 10 times, what will happen ?
Thanks |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 25, 2007 5:25 pm |
|
|
I don't understand what you want. You have ADC input and you have
button input. Which method is used to get the pwm duty cycle ? |
|
 |
mcad
Joined: 25 Nov 2007 Posts: 48
|
|
Posted: Sun Nov 25, 2007 5:30 pm |
|
|
Sir,
I am trying to perform that the user can change the speed of the DC motor via the user buttons (speed up and slow down buttons).
So, when the user press the related button, the operation affects the value of the duty cycle, does not it ? So, I mean if the dtuy cycle is smaller than the value which is requested by the user as a decrement, what does happen ? |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 25, 2007 6:07 pm |
|
|
This is a coding problem. You need to learn how to do this.
Here's an example. You only decrement by 10 if the current pwm
value is 10 or greater. If it's less than 10, then just set the pwm to 0.
| Code: |
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#define DECREMENT_VALUE 10
//======================================
void main()
{
int8 duty_cycle;
if(duty_cycle >= DECREMENT_VALUE)
duty_cycle -= DECREMENT_VALUE;
else
duty_cycle = 0;
set_pwm1_duty(duty_cycle);
while(1);
}
|
|
|
 |
Guest
|
|
Posted: Mon Nov 26, 2007 2:40 am |
|
|
Hi Sir,
Thank you for your reply and all clarifications. By the way, sorry for my late reply as I fell asleep.
I am going to apply your suggestions with my own thoughts today.
Again thanks,
regards |
|
 |
mcad
Joined: 25 Nov 2007 Posts: 48
|
|
Posted: Mon Nov 26, 2007 2:42 am |
|
|
Upps,
Sorry, it seems that I am continuing to sleep.
I wrongly sent the reply as a Guest wiothut logging in.
Again sorry. |
|
 |
|