Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 17th May 2006, 07:26 PM   (permalink)
Default PIC 18F4431 Power PWM , i am lost!

i am playing around with these 40pin pics .
i am trying to control three 12v DC motors (not steppers , not servo) over h-bridge, with no feedback.
the 18F4431 has power pwm module that comes build in to provide up to 8 channels in complemntry mode
however i read the datasheet on the power pwm module and cant understand how to work with this module easly.
i downloaded several application notes, but most of them are reffering to ccp pwm .
i will appricate any help or any step by step instruction on how to do that

thank you
max_imum2000 is offline   Reply With Quote
Old 18th May 2006, 12:57 PM   (permalink)
Default

Here is a code snippet to initialize the PWM module. It is not yet been tested since I had set that project aside for now. I hope it helps you get started.

You define the value of PTPER_VAL to set the PWM frequency. See table 17-2 of the PIC18F4431 datasheet for the suggested values.

Code:
;-----------------------------------------------------------
;   Init PWM module
;
         MOVLW    1<<PTMOD1       ; 1:1 prescale,1:1 postscale, up/down
         MOVWF    PTCON0
;
         MOVLW    1<<PWMEN2|1<<PWMEN1|1<<PMOD1|1<<PMOD0
         MOVWF    PWMCON0
;
         MOVLW    0               ; 1:1 Postscale
         MOVWF    PWMCON1
;
         MOVLW    LOW  PTPER_VAL
         MOVWF    PTPERL
         MOVLW    HIGH PTPER_VAL
         MOVWF    PTPERH
;
         CLRF     DTCON
;
         BSF      PTCON1,PTEN     ; Fire up the PWM module
__________________
"Having to do with Motion Control"
motion is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 08:05 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.