PDA

View Full Version : 3 HPWM channels with PIC18F26K20



pxidr84
- 12th January 2011, 17:56
Hi everyone,

I'm new here avec I hope find help here.

I'm currently making a 3-phase variable frequency drive with PicBasic Pro and a PIC18F26K20 (28-pin, 64MHz, 3.3V). For simulation, I'm using ISIS Proteus.

I have to define 3 PWM hardware channels (one for each phase U, V and W) with the HPWM command.
My PIC have CCP1 on PORTC.2, CCP2A on PORTC.1 and CCP2B on PORTB.3.

So here my simple test program :

define OSC 64

DEFINE CCP1_REG PORTC
DEFINE CCP1_BIT 1
DEFINE CCP2_REG PORTC
DEFINE CCP2_BIT 2
DEFINE CCP3_REG PORTB
DEFINE CCP3_BIT 3

HPWM 1,127,8000
HPWM 2,100,8000
HPWM 3,50,8000

Unfortunately, in Isis, only HPWM1 and HPWM2 works well, but not the HPWM3 (no action). I don't know why.
My registers are maybe misdefined?

ScaleRobotics
- 12th January 2011, 18:04
Hello, and welcome to the forum!

From the data sheet.....

11.0 CAPTURE/COMPARE/PWM
(CCP) MODULES
PIC18F2XK20/4XK20 devices have two CCP
Capture/Compare/PWM)

See the fine print by PortB.3 CCP2^1
Note 1: RB3 is the alternate pin for CCP2 multiplexing.

If you want to look at some devices that have more, you can do a parametric search here:
http://www.microchip.com/maps/microcontroller.aspx

pxidr84
- 12th January 2011, 18:26
Hello, and welcome to the forum!

From the data sheet.....

11.0 CAPTURE/COMPARE/PWM
(CCP) MODULES
PIC18F2XK20/4XK20 devices have two CCP
Capture/Compare/PWM)

See the fine print by PortB.3 CCP2^1
Note 1: RB3 is the alternate pin for CCP2 multiplexing.

If you want to look at some devices that have more, you can do a parametric search here:
http://www.microchip.com/maps/microcontroller.aspx

Thanks for your fast answer, well I will buy the PIC18F4431 instead, with eight PWM outputs, it will be fine. :D

But I can simulate in Isis any PIC I want, so I try to feed a simulated PIC18F4431 with the same program as above (compiled with the right PIC setting of course in MicroCode Studio).

And like my PIC18F26K20, only two HPWM outputs are working. What's wrong?

ScaleRobotics
- 12th January 2011, 20:03
Check out Bruce's post here, and Darrels right above it: http://www.picbasic.co.uk/forum/showthread.php?t=7095&p=43820#post43820

Those are great chips, so you could either do it manually, or you could switch to an older chip, like the PIC18F452.

pxidr84
- 13th January 2011, 17:58
Check out Bruce's post here, and Darrels right above it: http://www.picbasic.co.uk/forum/showthread.php?t=7095&p=43820#post43820

Those are great chips, so you could either do it manually, or you could switch to an older chip, like the PIC18F452.

Thanks, I will look at it.