Log in

View Full Version : 18F4620 HPWM Half Bridge Mod problem



showtime
- 31st October 2007, 00:16
Hello my friends,
I would like to drive two mosfets which are built Half Bridge. I have read whole forum but i can't succeed. The code and ISIS file is attached. The circuit on the proto board is tried but the result is negative. Only P1A is OK.

Regards.

Bruce
- 31st October 2007, 14:05
HPWM is intended for standard CCP PWM modules. It does not work for enhanced PWM
modules. You'll need to set things up manually.

I don't have an 18F4620 to test this with, but see if this doesn't work;


DEFINE OSC 20

Duty VAR WORD ' 5%=25, 95%=450

TRISC.2=0
TRISD.5=0

T2CON = %00000101 ' Timer2 ON, prescale 1:4
PR2 = 124 ' 10kHz
CCP1CON = %10001100' half-bridge with P1A & P1B

Loop:
For Duty = 25 TO 450 ' from 5% to 95% duty
CCP1CON.4 = Duty.0 ' Setup 10-bit duty cycle as
CCP1CON.5 = Duty.1 ' a 10-bit word
CCPR1L = Duty >> 2
PAUSE 250
Next
Goto loop

End

RodSTAR
- 31st October 2007, 17:09
I was fighting with a 18F4550 and it's 4 multiplexed PWM's (P1-P4). I had no time to study about it. My timeless and fast solution was I just used an ordinary pwm PIC (16F628a) and a (fast) 4052 multiplexer and forgot about enhanced pwm stuff for a 1/256th microstepper unipolar stepper motor controller I made. Also used a SN754410NE bridge.

Cheap, fast & easy...

(The 18F4550 i left it for another USB proyect)


RodSTAR

showtime
- 31st October 2007, 20:14
Hi Bruce thank you for reply, It is not working. I think something is wrong or missing for this situation.

Hi rodstar, that is possible. Deadtime is very important for me. I have to put a deadtime in the PWM signals.

Bruce
- 31st October 2007, 20:24
Is it still only showing a PWM signal on P1A? Are you running this in ISIS or on a real PIC?
More info would help.

Edit: I ran this through MPSIM with the logic analyzer on P1A and P1B. Sure looks like it works.


DEFINE OSC 20
Duty VAR WORD ' 5%=25, 95% = 450
TRISC.2=0
TRISD.5=0
T2CON = %00000101 ' Timer2 ON, prescale 1:4
PR2 = 124 ' 10kHz
CCP1CON = %10001100' half-bridge with P1A & P1B
PWM1CON = %10001111' set dead-time

Loop:
For Duty = 25 TO 450 ' from 5% to 95% duty
CCP1CON.4 = Duty.0 ' Setup 10-bit duty cycle as
CCP1CON.5 = Duty.1 ' a 10-bit word
CCPR1L = Duty >> 2
PAUSEUS 24
Next
Goto loop

End
Screen capture of MPSIM logic analyzer attached.

Might be a problem with ISIS or your config settings?

showtime
- 31st October 2007, 22:35
Hi Bruce , Thank you for interest.

The problem is not simulation. I have just tried your code on the proto board. It is not working. I programmed your code. Nothing was changed.

Did you use some fuse setting that i didn't see in your code. I think something is wrong with this PIC model because my 18F458 and 16f690 and 16f684 is working Half bridge Mod properly in ISIS and proto board.

Thank you again.

Bruce
- 31st October 2007, 23:05
Here's the config settings I used when running this through MPSIM.

__CONFIG _CONFIG1H, _OSC_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L

I have attached the .hex & .bas files I used.

After looking at one of many errata sheets for the 18F4620, I doubt I'll be in
any huge hurry to try this one.

The Rev A silicon Errata sheet shows a boat-load of problems with the ECCP
module. It could very well be a silicon bug. Good luck...;o}

showtime
- 31st October 2007, 23:55
Thank you very much for valuable helps. The last code was the same. I will research more. Maybe one mounth later i will work with other PIC wich have not got big bugs if I can't succeed.

Best regards.

showtime
- 2nd November 2007, 12:55
18F458 is working very well with the same code but 18F4620 is not. I think there is a PIC bug.