Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PWM question

Status
Not open for further replies.
If I remember right...every time you use the HPWM command it resets the control register's, so the signal will drop out before the dutycycle changes.Use the HPWM command to initially setup the signal and alter the control registers directly to alter the duty cycle.Also it usually a good idea to do something with unused pins, and not leave them floating.
 
can explain to me in more detail.i need to get it done a.s.a.p.
ADCON1=6 stands for %0000011x? some sources telling me that ADCON1=7.that's why i use '7'.
 
Is your input floating or is it always 5V or 0V. Have you checked that your program actually goes to any of the If statements. Try:
Code:
ADCON1=7 

TRISA=31 
TRISC=0 

LOOP: 
HPWM 1,0,0 'DUTYCYLE 0% 

IF PORTA.0=1 Then 'CHECK PIN 0 STATE 
   HPWM 1,191,20000 'OUPUT 75% DUTYCYLE 20KHZ 
else
   HPWM 1,127,20000 'OUTPUT 50% DUTYCYLE 20KHZ 
EndIF 
GOTO LOOP 

END

I could not see anything wrong with the code. ADCON1=7 is right. What crystal are you using?

Ivancho
 
i am using 4MHz crystal,two 15pF caps,and a 4.7K pull up resistor.

i have connected pull up resistor to those inputs but left other pins unconnected. may b this is a problem.

i will try to hook it up again.

the output is quite ugly when i check with the oscilloscope.
 
You have pullup's on porta.0 and porta.1? If you do then your pic is constantly jumping between %75 and %50 duty cycles.Not sure what the rest of your circuit is but, if you can remove the pull ups or pull them pins to ground.And like I said ,each time you use the HPWM command it will reset the CCP module before it starts the new duty cycle.This probably why your signal is so ugly, change the duty cycle directly in the pwm control registers.
 
It's a very long time.... I'm coming back... :D...

Well, why don't you use L298 or L293D for more ease? don't care how mosfet or transitor work... Some kinds of motor drivers should be cheap IC: TA7288P or TA72xxP, TB62xxP ... For beginners, I things you shouldn't explain so many things. Sometimes, you will make them crazy..

You may use those driver to work with DC motors, DC servo or stepping motors.

PWM is just only a method to drive a motor, you may drive it upto 5KHz - 6KHz.

Note that we need protect diodes, you may see it in datasheet of those chips.

The only problem is that, you use a pin of PIC, then set HIGH and LOW alternatively, to get your frequencies.

If you get problems on driving, it's not because PWM method or the circuit boards. You should open a new topic then ask about programming for PIC.

I used to be a newcomers of this forum a year ago, and thanks to admins, they help me muchie... Now, I think I have to come back to help other newcomers.

By the way, I need your help to send me a programmer kits of 16F877, I lost mine. I remember, somewhere in the forum, one show his own simple programmer kit, but I cannot find it.

Thanks muchie...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top