Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

motor' pwm control according to switch value

Status
Not open for further replies.

nudrat

Junior Member level 1
Joined
Dec 9, 2010
Messages
19
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,396
hi everyone!

I want to start and stop pwm(which drives a motor) according to the value of switch.
Motor is on portc(RC2) and switch is on RB0.
I am using pic16f877a and software is mikroc.
Can anybody help me in writing c code?
 

did you check HELP of mikroc?(search PWM)
 

Hi,
Take a look at the help section in mikroC and the PWM library functions. Are you clear regarding how to check the state of an input pin?
After taking a look at the library, please come here and I'll help with the coding.

Tahmid.
 

@tahmid thanks.
I generated PWM on portc and motor rotates well.
My problem is that i am using an NPN transistor as a switch on PORTB.0. and want that if value of NPN switch is 1 the motor starts and if its value is 0, motor stops.
I tried so much but once motor starts it dont stop weather i change the value of switch.
 

Hi,

Can you show schematic; your problem may be there (transistor doesn't bias ?,Check V at input pin of uC).
May be your code has a bug. It doesn't response to input.

Thanks,
 

Hi,
In the code, to stop PWM, use
Code:
PWM_Stop()
or
Code:
PWM1_Stop()
, whichever is necessary.

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top