Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 03, 2016, 03:25:19 03:25


Login with username, password and session length


Pages: [1]
Print
Author Topic: HOW TO USE HPWM3/4/5 IN PIC18F8722  (Read 1978 times)
0 Members and 1 Guest are viewing this topic.
siriwat1977
Inactive

Offline Offline

Posts: 4

Thank You
-Given: 2
-Receive: 0


« on: September 30, 2008, 08:41:46 20:41 »

HOW TO USE HPWM3 / 4 / 5 ON PORTG.0  PORTG.3   PORTG.4

EX

duty_1          var byte
duty_2          var byte
duty_3          var byte
duty_4          var byte
duty_5          var byte

mot1        VAR  PORTC.2   'HPWM1
mot2        VAR  PORTC.1     'HPWM2
mot3        var  PORTG.0       'HPWM3
mot4        var  PORTG.3         'HPWM4
mot5        var  PORTG.4           'HPWM5
   



    adcon1 = 7
    TRISC = %00000000
    TRISG = %00000


    duty_1  = 255
    duty_2  = 255
    duty_3  = 255
    duty_4  = 255
    duty_5  = 255
    gosub drive0
   


gogo: 
        GOSUB   forward150
     
        GoTo gogo
End

drive:
    HPWM 1,duty_1,800
    HPWM 2,duty_2,800
    HPWM 3,duty_3,800
    HPWM 4,duty_4,800
    HPWM 5,duty_5,800
    Return
     
drive0:
    HPWM 1,0,800
    HPWM 2,0,800
    HPWM 3,0,800
    HPWM 4,0,800
    HPWM 5,0,800
    Return
   

forward150:
High  mot1
High  mot2
High  mot3
High  mot4
High  mot5
    duty_1  = 100
    duty_2  = 100
    duty_3  = 100
    duty_4  = 100
    duty_5  = 100
GoSub drive
pause 100
Return

from ex 

HPWM1 AND HPWM2 IS WORK

BUT NO SIGNAL OUT PORT G.0  G.3  G.4

THANK YOU  Smiley
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #1 on: January 11, 2009, 02:48:50 02:48 »

Where are you setting your control registers?
adcon1 is only 1 port of 3, to control for analog control
you need to read data sheet.

this is small part of setup needed. for one port.
1. Set the PWM period by writing to the PR2 (PR4) register.
2. Set the PWM duty cycle by writing to the CCPRxL register and CCPxCON<5:4> bits.
3. Make the CCPx pin an output by clearing the appropriate TRIS bit.
4. Set the TMR2 (TMR4) prescale value, then enable Timer2 (Timer4) by writing to T2CON
(T4CON).
5. Configure the CCPx module for PWM operation.
Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC