Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] HELP WITH (THE POWER CONTROL PWM MODULE) PIC18F1330

Status
Not open for further replies.

elvito

Newbie level 5
Newbie level 5
Joined
Feb 18, 2010
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
VENEZUELA
Visit site
Activity points
1,408
GOOD EVENING GUYS, I'M USING THE P18F1330 AND I'M HAVING SOME PROBLEMS IN ORDER TO GET THE PWM PERIOD I NEED. I'VE ALREADY READ THE DATASHEET AND THIS IS WHAT I HAVE:

LIST P=18F1330
INCLUDE "P18F1330.INC"



ORG 0X0000
GOTO START


ORG 0X0008
GOTO INTER


ORG 0X0018
BTFSS INTCON3,INT3IF
RETFIE
BSF PORTA,4
CALL T_2S
BCF PORTA,4
BCF INTCON3,INT3IF
RETFIE

INTER BTFSC PIR3,PTIF
GOTO PWM
BTFSS INTCON3,INT2IF
RETFIE
BSF PORTA,3
CALL T_2S
BCF PORTA,3
BCF INTCON3,INT2IF
RETFIE

PWM BCF PIR3,PTIF
RETFIE


START MOVLW B'01110011'
MOVWF OSCCON
; BSF OSCTUNE,PLLEN
MOVLW .7
MOVWF ADCON1
MOVLW .1
MOVWF TRISA
CLRF TRISB


BSF PIE3,PTIE
BSF IPR3,PTIP

CLRF PTMRL
CLRF PTMRH

BSF INTCON,GIE
BSF INTCON,PEIE

CLRF PORTA
CLRF PORTB

MOVLW B'00010111'
MOVWF PWMCON0

MOVLW B'00001100'
MOVWF PTCON0

MOVLW 0X08
MOVWF PTPERH
MOVLW 0X22
MOVWF PTPERL

MOVLW B'00001001'
MOVWF PWMCON1

MOVLW 0X02
MOVWF PDC0H
MOVLW 0X00
MOVWF PDC0L

MOVLW B'10000000'
MOVWF PTCON1


ESP1 BTFSC PORTB,1
GOTO ESP1
ESP2 BTFSS PORTB,1
GOTO ESP2
GOTO ESP1

END

I'M WORKING WITH A 8MHZ INTERNAL OSCILATOR, PORTB CONFIGURED AS OUTPUTS.

I ENABLED PWM BASE TIME INTERRUPT WITH A HIGH PRIORITY, PLEASE DO NOT PAY ATTENTION TO THE LOW PRIORITY INTERRUPT BECAUSE I WAS TESTING OTHER MODULES.

THEN, I ACTIVATED THE GIE AND ARRIVED WHERE MY DOUBT IS.

FOR EXAMPLE: IF I'D LIKE TO HAVE A 60HZ PERIOD WITH A 8MHZ OSCILATOR(IF I CAN'T HAVE THIS PERIOD WOULD YOU MIND GIVING ME AN EXAMPLE WITH A DIFFERENT ONE)

T(PWM)=((PTPER+1)*PTMRPS)/(8MHZ/4)
PTMRPS=256/4=64 THE 4 THAT DIVIDES THE 8MHZ, I SIMPLIFIED IT WITH THE 256 PREESCALER GETTING THE NEW ONE 64 RIGHT?

T(PWM)=16.66mS SO I'LL GET THAT THE PTPER=2082=0X0822

PLEASE CORRECT ME IF I'M WRONG WITH THE LAST FORMULA, AS YOU COULD SEE IN THE PROGRAM I PASTED I WASN'T SURE HOW TO LOAD THE DUTY CYCLE, BECAUSE THE A NOTE IN THE DATASHEET THAT SAYS:"To get the correct PWM duty cycle, always multiply the calculated PWM duty cycle value by four before writing it to the PWM Duty Cycle registers. This is due to the two additional LSBs in the PWM Duty Cycle registers which are compared against the internal Q clock for the PWM duty cycle match" BEFORE THIS QUOTE, THEY EXPLAINED SOMETHING LIKE I HAVE TWO CONSIDER THE 12 UPPER BITS OF THE PCD0 IN ORDER TO ESTABLISH THE DUTY CYCLE I NEED. ?

I'M REALLY SORRY IF I TALKED TO MUCH BUT I TRIED TO EXPLAIN MY PROBLEM THE BEST I COULD. PLEASE HELP ME WITH THIS IT'S IMPORTANT.

PS. THE BTFSS AT THE END OF THE PROGRAM IT'S A WAY OF MEASURING THE PWM DUTY CYCLE AND PERIOD USING THE DEBUGGER.

THANK YOU IN ADVANCED
 

Here is the total solution for your problem.
Enclosed is the Power control PWM module sample code.
Basically that code is pic 18f2331 microcontroller which you can modified bit and use for your purpose.

In what application you are using PIC18F1330 microcontroller?

If u have any other query related to PIC18F1330 let me know.

Hope this will solve your problem.


Regards
Chanchal
 

GOOD MORNING hanchal.chauhan, I'M WORKING ON A (VF Control of 3-Phase Induction Motors). I WANNA THANK YOU FOR YOUR ANSWER, I'M CHANGING MY PROGRAM ACCORDING TO THE .ASM YOU SENT ME.

hanchal.chauhan I'LL TELL YOU MY PROGRESS AT NIGHT. IF THERE'S SOMETHING I DON'T UNDERSTAND, IT'S THE DUTY CYCLE, YOU KNOW IT HAS TWO REGISTER PDC0H:pDC0L IF I WANNA HAVE 100% DUTY CYCLE, WHAT VALUE SHOULD I HAVE TO PUT IN THE PDC0H:pDC0L? I'M GONNA CHECK YOU PROGRAM BECAUSE MICROCHIP SAY THAT IN ORDER TO GET THE DUTY CYCLE WE WANT, WE HAVE TO CONSIDER THE UPPER 12 BITS OF PDC0H:pDC0L AS THE REAL DUTY CYCLE; DESPITE KNOWING THAT THE LOWER TWO BITS ARE CONSIDERED AS THE Q1,Q2,Q3,Q4 AND THE VALUE IN THESE TWO BITS DEPEND ON THE PRESCALER I CHOSE IN THE PTCON0.

BUT ANYWAY LET ME CHECK.

YOU ALSO TOLD ABOUT WHY I DIDN'T CHOOSE C LANGUAGE FOR ALL THIS? BECAUSE ASSEMBLER IT'S MY PREDEFINED LANGUAGE, I TRIED TO LEARN "C" BUT THE TUTORIAL I HAD, IT DIDN'T EXPLAIN AT DETAIL WHAT I NEEDED. I REALIZE IT'S OUT OF THE TOPIC WHAT I'M GONNA ASK YOU BUT DO YOU HAVE ANY C TUTORIAL THAT CAN HELP ME CHANGING MY DAILY WAY OF PROGRAMMING? SOMETIMES I'M TO TIRED OF THE SAME THING, SO I TRIED TO CHANGE BUT THE LAST TUTORIAL DIDN'T GIVE ME THE OPPORTUNITY.


THANK YOU AGAIN chanchal.chauhan
I'M GONNA START WORKING.


 

the best tutorial on pic I have ever seen, by a long shot, is by gooligum, and it is free.

Added after 1 minutes:

the best part for VF motor control really are some of the arm chips (M1 or M2 chips). they are very fast, has tons of ports, and typically have library functions / application notes / demo boards designed specifically for that.

I wouldn't use a pic for that purpose.
 

chanchal.chauhan I WANNA THANK YOU FOR THE .ASM YOU SENT ME, IT WORKED. AT THIS TIME, I'M TRYING TO GET THE DUTY CYCLE ACCORDING TO THE PERIOD.

chanchal.chauhan IF YOU HAVE ANY IDEA HOW TO DEAL WITH THE DUTY CYCLE THAT THE PIC18F1330 HAS, PLEASED LET ME KNOW.

GUYS WHAT DO YOU RECOMMEND IN ORDER TO MAINTAIN 120 DEGREE PHASE SHIFT BETWEEN SINE WAVES? USING THIS METHOD(PWM).

I'VE ALREADY READ THE APPLICATION NOTE (AN889), I TRIED TO UNDERSTAND THEIR .ASM BUT THERE WERE SOME FILES MISSING.

I'LL BE WAITING FOR YOUR ANSWER.

BY THE WAY, THANK YOU FOR THE SITE YOU RECOMMENDED ME IN ORDER TO LEARN C LANGUAJE. IT WAS EXCELLENT. THANK YOU.

IF I WANNA GIVE POINTS GUYS WHAT DO I HAVE TO DO?
 

You can update the duty cycle by changing the PDCL and PDCH register value.

Regards
Chanchal Chauhan

Added after 5 minutes:

By using the equation which has given in the data sheet u will get ur appropriate duty cycle.
All the best for ur 3 phase induction motor project.

Let me know if u have any query

Regards
Chanchal Chauhan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top