Author Topic: PC PWM initialization and use on PIC18F4431  (Read 5377 times)

0 Members and 1 Guest are viewing this topic.

Offline RebelgiumTopic starter

  • Supreme Robot
  • *****
  • Posts: 637
  • Helpful? 0
  • It's called the future ... We like it here
PC PWM initialization and use on PIC18F4431
« on: June 16, 2008, 05:46:55 PM »
I'm not the most experienced programmer, and I have some problems trying to program my PIC to use PWM to control some motors.
The PIC18F4431 is a powerull PIC specially designed for motor control, it has four PWM duty cycle registers and eight PWM pins.
The peripheral I'm using is the PCPWM (Power Control PWM).

But I just can't seem to find how to initialize this peripheral!
I would be very thankfull for a short summarization of what registers I have to program, and in what order. C code or assembly are also fine.

Also I'm not sure what to put in most of them.
This is my goal:
I want PWM0,2,5 and 6 to be independantly controllable PWM pins.
The period can be the same for all, but the duty cycle has to be modifyable in my code.

I more or less have these filled in:

but which ones do I also have to program? How do I program the period? the duty cycle?
And how does PWM "work" in code? Does it interrupt every period? Or what?

All I want is a peripheral outputting these four PWM signals, and I can change the duty cycle in my code.

To relax after some hard work on robotics: A very fun free online text based MMORPG

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: PC PWM initialization and use on PIC18F4431
« Reply #1 on: June 20, 2008, 04:01:02 PM »
I recall from the 16F family that the period is given by timer2, and the duty cycle is set up in individual registers. The device datasheet had some good examples for these PICs (check out CCPM modules)
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline threewheeler7

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
Re: PC PWM initialization and use on PIC18F4431
« Reply #2 on: August 02, 2008, 10:19:59 AM »
well it is nothing like setting up the 16f parts. i am working on a 4 brushed motor controller with one of these.


Get Your Ad Here